options(stringr.html = TRUE) does not work
lucavalery opened this issue · comments
Since stringr 1.5.0, str_view()
generates, by default, an ANSI output in the console; with the option html = TRUE
, a html output (in the Viewer in an .R script, in html in a rendered markdown).
The documentation of stringr::str_view() specifies that it is possible to set the glopal option stringr.html = TRUE
to avoid specifying the option html = TRUE
in every call to str_view()
(thus reproducing a useful default behaviour of the older versions of stringr
):
However, this global option does not seem to work.
This code:
library(stringr)
options(stringr.html = TRUE)
c("a cat", "that dog", "a similar cat", "the penguin") |> str_view("cat")
still causes the default behaviour of printing, in the Console,
Whereas specifying the option in a single call does work, with the html in the Viewer:
c("a cat", "that dog", "a similar cat", "the penguin") |> str_view("cat", html = TRUE)
The Posit community helped to verify that indeed str_view()
does not seem to call at all stringr.html
, and that that sentence in the documentation is the only place this option is mentioned in the repo. Therefore, this could be a bug.
I am working on Posit Cloud (R version 4.3.1 and RStudio Pro 2023.09.1, Build 494.pro2), stringr 1.5.0. Thank you in advance for your attention!
That looks like a bit of documentation I forgot to update 😞 If you want this behaviour you can just make your own wrapper in an early chunk:
str_view <- function(...) {
stringr::str_view(..., html = TRUE)
}