🔍 An RStudio addin slash regex utility belt
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

65 líneas
1.6KB

  1. if (!exists('HELP_DEFAULT_TEXT')) HELP_DEFAULT_TEXT <- "<p>Select a category from the left sidebar.</p>"
  2. help_text <- reactiveVal(HELP_DEFAULT_TEXT)
  3. make_html_table <- function(x) {
  4. select(x, .data$regexp, .data$text) %>%
  5. knitr::kable(
  6. col.names = c("Regexp", "Text"),
  7. escape = FALSE,
  8. format = "html")
  9. }
  10. make_help_tab_text <- function(category = NULL, group = NULL) {
  11. x <- cheatsheet
  12. if (!is.null(category)) x <- filter(x, .data$category == !!category)
  13. if (!is.null(group)) x <- filter(x, .data$group == !!group)
  14. x %>%
  15. make_html_table() %>%
  16. help_text()
  17. }
  18. output$help_text_selected <- renderUI({
  19. help_body <- help_text()
  20. if (inherits(help_body, "shiny.tag.list")) {
  21. help_body
  22. } else HTML(help_body)
  23. })
  24. observeEvent(input$help_default, {
  25. help_text(HELP_DEFAULT_TEXT)
  26. })
  27. observeEvent(input$help_cat_character_classes_regular, {
  28. make_help_tab_text("character classes", "regular")
  29. })
  30. observeEvent(input$help_cat_character_classes_prebuilt, {
  31. make_help_tab_text("character classes", "pre-built")
  32. })
  33. observeEvent(input$help_cat_anchors, {
  34. make_help_tab_text("anchors")
  35. })
  36. observeEvent(input$help_cat_escaped_general, {
  37. make_help_tab_text("escaped characters", "general")
  38. })
  39. observeEvent(input$help_cat_escaped_hex, {
  40. make_help_tab_text("escaped characters", "hex")
  41. })
  42. observeEvent(input$help_cat_escaped_control, {
  43. make_help_tab_text("escaped characters", "control characters")
  44. })
  45. observeEvent(input$help_cat_groups, {
  46. make_help_tab_text("groups")
  47. })
  48. observeEvent(input$help_cat_quantifiers, {
  49. make_help_tab_text("quantifiers")
  50. })