| #' regexplain gadget | |||||
| #' RegExplain gadget | |||||
| #' | #' | ||||
| #' @import miniUI | #' @import miniUI | ||||
| #' @import shiny | #' @import shiny | ||||
| shiny::includeCSS(system.file("styles", "style.css", package = "regexplain")), | shiny::includeCSS(system.file("styles", "style.css", package = "regexplain")), | ||||
| shiny::includeCSS(system.file("styles", "gadget.css", package = "regexplain")), | shiny::includeCSS(system.file("styles", "gadget.css", package = "regexplain")), | ||||
| gadgetTitleBar( | gadgetTitleBar( | ||||
| "regexplain", | |||||
| "RegExplain", | |||||
| right = miniTitleBarButton("done", "Send RegEx To Console", TRUE) | right = miniTitleBarButton("done", "Send RegEx To Console", TRUE) | ||||
| ), | ), | ||||
| miniTabstripPanel( | miniTabstripPanel( | ||||
| label = HTML( | label = HTML( | ||||
| '<div style="font-size: 1.25rem;">', | '<div style="font-size: 1.25rem;">', | ||||
| 'Option Groups: ', | 'Option Groups: ', | ||||
| '<span style="color: #337ab7;">regexplain</span>,', | |||||
| '<span style="color: #5cb85c;">all</span>, ', | |||||
| '<span style="color: #f0ad4e;">base only</span>', | |||||
| '<span style="color: #337ab7;">RegExplain</span>,', | |||||
| '<span style="color: #5cb85c;">All</span>, ', | |||||
| '<span style="color: #f0ad4e;">Base only</span>', | |||||
| '</div>' | '</div>' | ||||
| ), | ), | ||||
| inline = TRUE, | inline = TRUE, | ||||
| # ---- Server - Tab - Help ---- | # ---- Server - Tab - Help ---- | ||||
| HELP_DEFAULT_TEXT <- c( | HELP_DEFAULT_TEXT <- c( | ||||
| "<div id=\"welcome-to-regexplain\" class=\"section level3\">", | |||||
| "<h3>Welcome to RegExplain</h3>", | "<h3>Welcome to RegExplain</h3>", | ||||
| "<p>If you’re new to regular expressions, one of the best places to start is <a href=\"http://stringr.tidyverse.org/articles/regular-expressions.html\">the regular expressions vignette</a> from <code>stringr</code>. The chapter on strings in <a href=\"http://r4ds.had.co.nz/strings.html\">R for Data Science</a> is also an excellent first resource.</p>", | "<p>If you’re new to regular expressions, one of the best places to start is <a href=\"http://stringr.tidyverse.org/articles/regular-expressions.html\">the regular expressions vignette</a> from <code>stringr</code>. The chapter on strings in <a href=\"http://r4ds.had.co.nz/strings.html\">R for Data Science</a> is also an excellent first resource.</p>", | ||||
| "<p><strong>Exploring or looking for a challenge?</strong> Click on <i>Try These Examples</i> to see what you can do with this addin.</p>", | "<p><strong>Exploring or looking for a challenge?</strong> Click on <i>Try These Examples</i> to see what you can do with this addin.</p>", | ||||
| "<div id=\"getting-started\" class=\"section level4\">", | |||||
| "<h4>Getting Started</h4>", | "<h4>Getting Started</h4>", | ||||
| "<ul>", | "<ul>", | ||||
| "<li><p><i class=\"fa fa-file-text-o\"></i> Enter or edit the <strong>Text</strong> you want to search.</p></li>", | "<li><p><i class=\"fa fa-file-text-o\"></i> Enter or edit the <strong>Text</strong> you want to search.</p></li>", | ||||
| "<li><p><i class=\"fa fa-table\"></i> Test the <strong>Output</strong> of your regular expression with common functions, including <i>search and replace</i> functions.</p></li>", | "<li><p><i class=\"fa fa-table\"></i> Test the <strong>Output</strong> of your regular expression with common functions, including <i>search and replace</i> functions.</p></li>", | ||||
| "<li><p><i class=\"fa fa-support\"></i> Get <strong>Help</strong> and look up the regular expression syntax.</p></li>", | "<li><p><i class=\"fa fa-support\"></i> Get <strong>Help</strong> and look up the regular expression syntax.</p></li>", | ||||
| "</ul>", | "</ul>", | ||||
| "</div>", | |||||
| "<div id=\"escaping-characters\" class=\"section level4\">", | |||||
| "<h4>Escaping characters</h4>", | "<h4>Escaping characters</h4>", | ||||
| "<p>In order to store a backslash (<code>\\</code>) as a character in R, backslashes need to be escaped…with another backslash! To write a literal <code>\\</code> in an R character string, you need to actually store <code>"\\\\"</code>.</p>", | "<p>In order to store a backslash (<code>\\</code>) as a character in R, backslashes need to be escaped…with another backslash! To write a literal <code>\\</code> in an R character string, you need to actually store <code>"\\\\"</code>.</p>", | ||||
| "<p>In regular expressions, <code>\\w</code> stands for any alphabetical character, but to store it in a string in R you need <code>"\\w"</code>.</p>", | "<p>In regular expressions, <code>\\w</code> stands for any alphabetical character, but to store it in a string in R you need <code>"\\w"</code>.</p>", | ||||
| "<p>Inside <strong>RegExplain</strong>, however, standard regular expressions can be used so that you can easily copy patterns from other places. When you click on the <span class=\"btn btn-xs btn-primary\">Send RegEX to Console</span> button, the necessary extra <code>\\</code> will be included.</p>", | "<p>Inside <strong>RegExplain</strong>, however, standard regular expressions can be used so that you can easily copy patterns from other places. When you click on the <span class=\"btn btn-xs btn-primary\">Send RegEX to Console</span> button, the necessary extra <code>\\</code> will be included.</p>", | ||||
| "<p>An extra backslash is still needed to match a literal <code>\\</code> in standard regular expressions. This means that you will need to enter <code>\\\\</code> in the <strong>RegEx</strong> tab, and the output to R will be <code>"\\\\\\\\"</code>.</p>", | |||||
| "</div>") | |||||
| "<p>An extra backslash is still needed to match a literal <code>\\</code> in standard regular expressions. This means that you will need to enter <code>\\\\</code> in the <strong>RegEx</strong> tab, and the output to R will be <code>"\\\\\\\\"</code>.</p>" | |||||
| ) | |||||
| source(system.file("shiny", "help_server.R", package = "regexplain"), local = TRUE) | source(system.file("shiny", "help_server.R", package = "regexplain"), local = TRUE) | ||||
| #' @importFrom dplyr "%>%" mutate filter group_by summarize select | #' @importFrom dplyr "%>%" mutate filter group_by summarize select | ||||
| #' @importFrom utils getFromNamespace installed.packages packageVersion | #' @importFrom utils getFromNamespace installed.packages packageVersion | ||||
| #' @importFrom rlang .data | |||||
| #' @keywords internal | #' @keywords internal | ||||
| "_PACKAGE" | "_PACKAGE" |
| --- | --- | ||||
| title: "regexplain" | |||||
| title: "RegExplain" | |||||
| output: github_document | output: github_document | ||||
| --- | --- | ||||
| #### Planned improvements | #### Planned improvements | ||||
| - Make better use of the opening view of **Help** tab to explain the gadget. | |||||
| - **v0.1.6!** Make better use of the opening view of **Help** tab to explain the gadget. | |||||
| Also add one or more additional tabs with an overview of regular expressions, | Also add one or more additional tabs with an overview of regular expressions, | ||||
| with links to R4DS and `vignette('regular-expressions', package = 'stringr')`. | with links to R4DS and `vignette('regular-expressions', package = 'stringr')`. | ||||
| Maybe also a **Try This** feature that sets the `text` and `pattern` with | Maybe also a **Try This** feature that sets the `text` and `pattern` with | ||||
| regex challenges (possibly borrowed from R4DS). | regex challenges (possibly borrowed from R4DS). | ||||
| - Add a global search option to the **Regex** tab. Groups would be lost, but I | |||||
| can still highlight global matches. | |||||
| - ~~Add a global search option to the **Regex** tab. Groups would be lost, but I | |||||
| can still highlight global matches.~~ | |||||
| - Add "flavors" menu to **Regex** tab. Automatically sets options to common flavors. | |||||
| Mainly for clarity when switching between "base"" style and "tidyverse/stringr" defaults. | |||||
| - ~~Add "flavors" menu to **Regex** tab. Automatically sets options to common flavors. | |||||
| Mainly for clarity when switching between "base"" style and "tidyverse/stringr" defaults.~~ | |||||
| - **Done in v0.1.5!** Add replacement functions somewhere. Maybe to **Output** tab with `g?sub` and | - **Done in v0.1.5!** Add replacement functions somewhere. Maybe to **Output** tab with `g?sub` and | ||||
| `str_replace(_all)?` as options with an additional "replacement" field that | `str_replace(_all)?` as options with an additional "replacement" field that |
| regexplain | |||||
| RegExplain | |||||
| ================ | ================ | ||||
| <!-- [](commits/master) --> | <!-- [](commits/master) --> | ||||
| state and is being actively | state and is being actively | ||||
| developed.](http://www.repostatus.org/badges/latest/active.svg)](http://www.repostatus.org/#active) | developed.](http://www.repostatus.org/badges/latest/active.svg)](http://www.repostatus.org/#active) | ||||
| [](https://cran.r-project.org/package=regexplain) | [](https://cran.r-project.org/package=regexplain) | ||||
| <!-- [](/commits/master) --> | |||||
| <!-- [](/commits/master) --> | |||||
| <!-- Links --> | <!-- Links --> | ||||
| #### Planned improvements | #### Planned improvements | ||||
| - Make better use of the opening view of **Help** tab to explain the | |||||
| gadget. Also add one or more additional tabs with an overview of | |||||
| regular expressions, with links to R4DS and | |||||
| - **v0.1.6\!** Make better use of the opening view of **Help** tab to | |||||
| explain the gadget. Also add one or more additional tabs with an | |||||
| overview of regular expressions, with links to R4DS and | |||||
| `vignette('regular-expressions', package = 'stringr')`. Maybe also a | `vignette('regular-expressions', package = 'stringr')`. Maybe also a | ||||
| **Try This** feature that sets the `text` and `pattern` with regex | **Try This** feature that sets the `text` and `pattern` with regex | ||||
| challenges (possibly borrowed from R4DS). | challenges (possibly borrowed from R4DS). | ||||
| - Add a global search option to the **Regex** tab. Groups would be | |||||
| lost, but I can still highlight global matches. | |||||
| - ~~Add a global search option to the **Regex** tab. Groups would be | |||||
| lost, but I can still highlight global matches.~~ | |||||
| - Add “flavors” menu to **Regex** tab. Automatically sets options to | |||||
| - ~~Add “flavors” menu to **Regex** tab. Automatically sets options to | |||||
| common flavors. Mainly for clarity when switching between “base”" | common flavors. Mainly for clarity when switching between “base”" | ||||
| style and “tidyverse/stringr” defaults. | |||||
| style and “tidyverse/stringr” defaults.~~ | |||||
| - **Done in v0.1.5\!** Add replacement functions somewhere. Maybe to | - **Done in v0.1.5\!** Add replacement functions somewhere. Maybe to | ||||
| **Output** tab with `g?sub` and `str_replace(_all)?` as options with | **Output** tab with `g?sub` and `str_replace(_all)?` as options with |
| % Generated by roxygen2: do not edit by hand | |||||
| % Please edit documentation in R/help_ui.R | |||||
| \name{generate_help_ui} | |||||
| \alias{generate_help_ui} | |||||
| \title{Generates Help Tab UI} | |||||
| \usage{ | |||||
| generate_help_ui(cheatsheet_only = TRUE) | |||||
| } | |||||
| \arguments{ | |||||
| \item{cheatsheet_only}{If TRUE then returns just basic regex | |||||
| explainer UI.} | |||||
| } | |||||
| \description{ | |||||
| Generates Help Tab UI | |||||
| } | |||||
| \keyword{internal} |
| % Generated by roxygen2: do not edit by hand | |||||
| % Please edit documentation in R/regex_gadget.R | |||||
| \name{get_templates} | |||||
| \alias{get_templates} | |||||
| \title{Loads Regex Pattern Templates} | |||||
| \usage{ | |||||
| get_templates() | |||||
| } | |||||
| \description{ | |||||
| Sourced from \href{https://projects.lukehaas.me/regexhub}{Regex Hub} | |||||
| and available at \url{https://github.com/lukehaas/RegexHub}. Copyright | |||||
| Luke Haas licensed under the MIT license available at | |||||
| \url{https://github.com/lukehaas/RegexHub/commit/3ab87b5a4fd2817b42e2e45dcf040d4f0164ea37}. | |||||
| } | |||||
| \keyword{internal} |
| % Please edit documentation in R/regex_gadget.R | % Please edit documentation in R/regex_gadget.R | ||||
| \name{regex_gadget} | \name{regex_gadget} | ||||
| \alias{regex_gadget} | \alias{regex_gadget} | ||||
| \title{regexplain gadget} | |||||
| \title{RegExplain gadget} | |||||
| \usage{ | \usage{ | ||||
| regex_gadget(text = NULL, start_page = if (is.null(text)) "Text" else | regex_gadget(text = NULL, start_page = if (is.null(text)) "Text" else | ||||
| "RegEx") | "RegEx") | ||||
| \code{"Output"}, or \code{"Help"}} | \code{"Output"}, or \code{"Help"}} | ||||
| } | } | ||||
| \description{ | \description{ | ||||
| regexplain gadget | |||||
| RegExplain gadget | |||||
| } | } |