cli_code | R Documentation |
A helper function that creates a div
with class code
and then calls
cli_verbatim()
to output code lines. The builtin theme formats these
containers specially. In particular, it adds syntax highlighting to
valid R code.
cli_code(
lines = NULL,
...,
language = "R",
.auto_close = TRUE,
.envir = environment()
)
lines |
Character vector, each line will be a line of code, and newline characters also create new lines. Note that no glue substitution is performed on the code. |
... |
More character vectors, they are appended to |
language |
Programming language. This is also added as a class,
in addition to |
.auto_close |
Passed to |
.envir |
Passed to |
myfun <- function() { message("Just an example function") graphics::pairs(iris, col = 1:4) } cli_code(format(myfun))
#> function () #> { #> message("Just an example function") #> graphics::pairs(iris, col = 1:4) #> }
The id of the container that contains the code.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.