@@ -36,13 +36,7 @@ str_view <- function(string, pattern, match = NA) {
3636 str_sub(string [has_match ], loc [has_match , , drop = FALSE ]) <-
3737 paste0(" <span class='match'>" , str_sub(string [has_match ], loc [has_match , , drop = FALSE ]), " </span>" )
3838
39- string <- str_replace_na(string )
40- bullets <- str_c(
41- " <ul>\n " ,
42- str_c(" <li>" , string , " </li>" , collapse = " \n " ),
43- " \n </ul>"
44- )
45- str_view_widget(bullets )
39+ str_view_widget(string )
4640}
4741
4842# ' @rdname str_view
@@ -68,24 +62,27 @@ str_view_all <- function(string, pattern, match = NA) {
6862 string
6963 })
7064 string <- unlist(string_list )
65+ str_view_widget(string )
66+ }
7167
68+ str_view_widget <- function (lines ) {
69+ lines <- str_replace_na(lines )
7270 bullets <- str_c(
7371 " <ul>\n " ,
74- str_c(" <li>" , string , " </li>" , collapse = " \n " ),
72+ str_c(" <li>" , lines , " </li>" , collapse = " \n " ),
7573 " \n </ul>"
7674 )
77- str_view_widget(bullets )
78- }
75+ html <- htmltools :: HTML(bullets )
7976
80- str_view_widget <- function (html ) {
8177 size <- htmlwidgets :: sizingPolicy(
8278 knitr.figure = FALSE ,
83- defaultHeight = " auto"
79+ defaultHeight = pmin(10 * length(lines ), 300 ),
80+ knitr.defaultHeight = " 100%"
8481 )
8582
8683 htmlwidgets :: createWidget(
8784 " str_view" ,
88- list (html = htmltools :: HTML( html ) ),
85+ list (html = html ),
8986 sizingPolicy = size ,
9087 package = " stringr"
9188 )
0 commit comments