Просмотр исходного кода

Options from regex tab now used throughout gadget

tags/v0.1.5
Garrick Aden-Buie 8 лет назад
Родитель
Сommit
b4c58f0ad1
3 измененных файлов: 65 добавлений и 18 удалений
  1. +1
    -1
      DESCRIPTION
  2. +8
    -1
      NEWS.md
  3. +56
    -16
      R/regex_gadget.R

+ 1
- 1
DESCRIPTION Просмотреть файл

Package: regexplain Package: regexplain
Title: Rstudio Addin to Explain, Test and Build Regular Expressions Title: Rstudio Addin to Explain, Test and Build Regular Expressions
Version: 0.1.4
Version: 0.1.5
Date: 2018-03-14 Date: 2018-03-14
Authors@R: c( Authors@R: c(
person("Garrick", "Aden-Buie", email = "g.adenbuie@gmail.com", role = c("aut", "cre")), person("Garrick", "Aden-Buie", email = "g.adenbuie@gmail.com", role = c("aut", "cre")),

+ 8
- 1
NEWS.md Просмотреть файл

# regexplain 0.1.4
## regexplain 0.1.x

### 0.1.5

* Options from **Regex** tab are extended to **Output** tab as well. Colored
options according to group where they are applied.

### 0.1.4


* Added string substitution function to **Output** tab (`g?sub`, * Added string substitution function to **Output** tab (`g?sub`,
`str_replace(_all)?`) with replacement field `str_replace(_all)?`) with replacement field

+ 56
- 16
R/regex_gadget.R Просмотреть файл

placeholder = "Enter regex, single \\ okay"), placeholder = "Enter regex, single \\ okay"),
checkboxGroupInput( checkboxGroupInput(
'regex_options', 'regex_options',
label = "",
label = HTML(
'<div style="font-size: 1.25rem;">',
'Option Groups: ',
'<span style="color: #337ab7;">regexplain</span>,',
'<span style="color: #5cb85c;">all</span>, ',
'<span style="color: #f0ad4e;">base only</span>',
'</div>'
),
inline = TRUE, inline = TRUE,
width = "90%", width = "90%",
choices = c("Break Lines" = "text_break_lines",
"Ignore Case" = "ignore.case",
"Perl Style" = "perl",
"Fixed" = "fixed",
"Use Bytes" = "useBytes"
# , "Invert" = "invert"
),
choiceValues = list(
"text_break_lines",
"ignore.case",
"fixed",
"perl",
"useBytes"),
choiceNames = list(
HTML('<span style="color: #337ab7;">Break Lines</span>'),
HTML('<span style="color: #5cb85c;">Ignore Case</span>'),
HTML('<span style="color: #5cb85c;">Fixed/Literal</span>'),
HTML('<span style="color: #f0ad4e;">Perl Style</span>'),
HTML('<span style="color: #f0ad4e;">Use Bytes</span>')),
selected = c('text_break_lines') selected = c('text_break_lines')
) )
), ),
fillCol( fillCol(
flex = c(1, 3), flex = c(1, 3),
inputPanel( inputPanel(
width = "100%;",
selectInput('regexFn', label = 'Apply Function',
choices = regexFn_choices),
tags$div(
width = "100%;",
selectInput('regexFn', label = 'Apply Function',
choices = regexFn_choices),
tags$span(class = "help-block",
style = "font-size:1.25rem; margin-top:-10px; margin-bottom:0px; margin-left:4px;",
"Adjust options in Regex tab")
),
uiOutput("output_sub") uiOutput("output_sub")
), ),
# verbatimTextOutput('output_result', placeholder = TRUE) # verbatimTextOutput('output_result', placeholder = TRUE)
x <- if (regexPkg == "base") { x <- if (regexPkg == "base") {
if (req_sub_arg) { if (req_sub_arg) {
req(replacement()) req(replacement())
regexFn(pattern(), replacement(), rtext())
regexFn(pattern(), replacement(), rtext(),
ignore.case = 'ignore.case' %in% input$regex_options,
perl = 'perl' %in% input$regex_options,
fixed = 'fixed' %in% input$regex_options,
useBytes = 'useBytes' %in% input$regex_options)
} else { } else {
regexFn(pattern(), rtext())
regexFn(pattern(), rtext(),
ignore.case = 'ignore.case' %in% input$regex_options,
perl = 'perl' %in% input$regex_options,
fixed = 'fixed' %in% input$regex_options,
useBytes = 'useBytes' %in% input$regex_options)
} }
} else if (regexPkg == "stringr") { } else if (regexPkg == "stringr") {
if (req_sub_arg) { if (req_sub_arg) {
req(replacement()) req(replacement())
regexFn(rtext(), pattern(), replacement())
regexFn(
rtext(),
stringr::regex(
pattern(),
ignore_case = 'ignore.case' %in% input$regex_options,
literal = 'fixed' %in% input$regex_options
),
replacement()
)
} else { } else {
regexFn(rtext(), pattern())
regexFn(
rtext(),
stringr::regex(
pattern(),
ignore_case = 'ignore.case' %in% input$regex_options,
literal = 'fixed' %in% input$regex_options
)
)
} }
} else { } else {
"Um. Not sure how I got here." "Um. Not sure how I got here."
}) })
} }


viewer <- shiny::paneViewer(700)
viewer <- shiny::paneViewer(minHeight = 1000)
runGadget(ui, server, viewer = viewer) runGadget(ui, server, viewer = viewer)
} }



Загрузка…
Отмена
Сохранить