1
- rm(list = ls())
2
- options(shiny.trace = FALSE )
1
+ rm(list = ls())
2
+ options(shiny.trace = FALSE )
3
3
4
4
library(shiny )
5
5
library(shinyBS )
@@ -12,38 +12,53 @@ library(htmltools)
12
12
source(" helper_functions.R" )
13
13
source(" regexplainer.R" )
14
14
15
- buy_me_stuff_button_html <- sample(c(' www/buy_me_coffee_button.html' ,
16
- ' www/buy_me_beer_button.html' ),
15
+ buy_me_stuff_button_html = sample(c(" www/buy_me_coffee_button.html" ,
16
+ " www/buy_me_beer_button.html" ),
17
17
size = 1 )
18
18
19
- safe_slashes <- purrr :: possibly(half_slashes , otherwise = NULL , quiet = FALSE )
20
- safe_highlight_test_str <- purrr :: possibly(highlight_test_str , otherwise = NULL , quiet = FALSE )
21
- safe_html_format_match_list <- purrr :: possibly(html_format_match_list , otherwise = NULL , quiet = FALSE )
22
- safe_get_match_list <- purrr :: possibly(get_match_list , otherwise = NULL , quiet = FALSE )
23
- safe_regexplain <- purrr :: possibly(regexplain , otherwise = NULL , quiet = FALSE )
19
+ purr_possibly = function (.f , otherwise = NULL , quiet = FALSE ) {
20
+ purrr :: possibly(.f , otherwise = otherwise , quiet = quiet )
21
+ }
22
+
23
+ safe_slashes = purr_possibly(half_slashes )
24
+ safe_highlight_test_str = purr_possibly(highlight_test_str )
25
+ safe_html_format_match_list = purr_possibly(html_format_match_list )
26
+ safe_get_match_list = purr_possibly(get_match_list )
27
+ safe_regexplain = purr_possibly(regexplain )
28
+
29
+ highlight_color_pallete = " Set3"
30
+
24
31
25
- highlight_color_pallete <- " Set3"
32
+ mgsub = function (pattern , replacement , text.var , leadspace = FALSE ,
33
+ trailspace = FALSE , fixed = TRUE , trim = TRUE ,
34
+ order.pattern = fixed , ... ) {
35
+ # ' @description I wanted qdap::mgsub() w/o having to have full qdap package,
36
+ # ' which has had issues deploying around rJava i think...
26
37
27
- mgsub = function (pattern , replacement , text.var , leadspace = FALSE , trailspace = FALSE ,
28
- fixed = TRUE , trim = TRUE , order.pattern = fixed , ... ) {
29
38
if (leadspace | trailspace )
30
- replacement <- spaste(replacement , trailing = trailspace , leading = leadspace )
31
-
39
+ replacement = spaste(replacement ,
40
+ trailing = trailspace ,
41
+ leading = leadspace )
42
+
32
43
if (fixed && order.pattern ) {
33
- ord <- rev(order(nchar(pattern )))
34
- pattern <- pattern [ord ]
44
+ ord = rev(order(nchar(pattern )))
45
+ pattern = pattern [ord ]
35
46
if (length(replacement ) != 1 )
36
- replacement <- replacement [ord ]
47
+ replacement = replacement [ord ]
37
48
}
38
49
if (length(replacement ) == 1 )
39
- replacement <- rep(replacement , length(pattern ))
40
-
50
+ replacement = rep(replacement , length(pattern ))
51
+
41
52
for (i in seq_along(pattern )) {
42
- text.var <- gsub(pattern [i ], replacement [i ], text.var , fixed = fixed , ... )
53
+ text.var = gsub(pattern [i ], replacement [i ], text.var , fixed = fixed , ... )
43
54
}
44
-
55
+
45
56
if (trim )
46
- text.var <-
47
- gsub(" \\ s+" , " " , gsub(" ^\\ s+|\\ s+$" , " " , text.var , perl = TRUE ), perl = TRUE )
57
+ text.var = gsub(
58
+ " \\ s+" ,
59
+ " " ,
60
+ gsub(" ^\\ s+|\\ s+$" , " " , text.var , perl = TRUE ),
61
+ perl = TRUE
62
+ )
48
63
text.var
49
64
}
0 commit comments