cli icon indicating copy to clipboard operation
cli copied to clipboard

Feature request: fallback to a default `code_highlight()` theme if RStudio theme is unavailable

Open rossellhayes opened this issue 3 years ago • 2 comments

If you try to use code_highlight() in RStudio when using a theme that is not included in code_theme_list(), you receive a warning message and the code is returned unhighlighted:

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}

It would be preferable to fallback to a default theme if cli does not recognize the current RStudio theme: perhaps to cli:::code_theme_default_term() or "Textmate (default)". The warning message could be preserved and could also indicate that the user can choose a code highlighting theme using options().

rossellhayes avatar Jun 15 '22 01:06 rossellhayes

Thanks, makes sense. Do you want to submit a PR? No pressure. :)

gaborcsardi avatar Jun 15 '22 12:06 gaborcsardi

Sure, I can put that together!

rossellhayes avatar Jun 15 '22 17:06 rossellhayes