If cli::code_highlight() is called in RStudio with an unrecognized theme (i.e. a non-builtin theme), it signals a warning and doesn't highlight the code:
cli::code_highlight("1 + 1")
#> [1] "1 + 1"
#> Warning message:
#> In code_theme_default_rstudio() :
#> cli does not know this RStudio theme: a11y-dark {rsthemes}
This can be avoided by setting options("cli.code_theme"). Here's an example for the theme "base16 Gruvbox dark, soft {rsthemes}":
options(cli.code_theme = list(
reserved = "#D3869B",
number = "#FE8019",
null = "#D65D0E",
operator = "#8EC07C",
call = NULL,
string = "#B8BB26",
comment = "#BDAE93",
bracket = list(
"#8EC07C",
"#83A598",
"#FABD2F",
"#FE8019",
"#FB4934",
"#B8BB26",
"#D3869B"
)
))
Is it possible to use data from rsthemes to set options("cli.code_theme") when calling use_theme_*()?
If
cli::code_highlight()is called in RStudio with an unrecognized theme (i.e. a non-builtin theme), it signals a warning and doesn't highlight the code:This can be avoided by setting
options("cli.code_theme"). Here's an example for the theme "base16 Gruvbox dark, soft {rsthemes}":Is it possible to use data from
rsthemesto setoptions("cli.code_theme")when callinguse_theme_*()?