code_highlight {cli}R Documentation

Syntax highlight R code

Description

Syntax highlight R code

Usage

code_highlight(code, code_theme = NULL, envir = NULL)

Arguments

code

Character vector, each element is one line of code.

code_theme

Theme see code_theme_list().

envir

Environment to look up function calls for hyperlinks. If NULL, then the global search path is used.

Details

See code_theme_list() for the default syntax highlighting theme and how to change it.

If code does not parse, then it is returned unchanged and a cli_parse_failure condition is thrown. Note that this is not an error, and the condition is ignored, unless explicitly caught.

Value

Character vector, the highlighted code.

See Also

Other syntax highlighting: code_theme_list()

Examples

code_highlight(deparse(ls))
cat(code_highlight(deparse(ls)), sep = "\n")

[Package cli version 3.6.3 Index]