1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
|
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/prettycode.R
\name{code_highlight}
\alias{code_highlight}
\title{Syntax highlight R code}
\usage{
code_highlight(code, code_theme = NULL, envir = NULL)
}
\arguments{
\item{code}{Character vector, each element is one line of code.}
\item{code_theme}{Theme see \code{\link[=code_theme_list]{code_theme_list()}}.}
\item{envir}{Environment to look up function calls for hyperlinks.
If \code{NULL}, then the global search path is used.}
}
\value{
Character vector, the highlighted code.
}
\description{
Syntax highlight R code
}
\details{
See \code{\link[=code_theme_list]{code_theme_list()}} for the default syntax highlighting theme and
how to change it.
If \code{code} does not parse, then it is returned unchanged and a
\code{cli_parse_failure} condition is thrown. Note that this is not an error,
and the condition is ignored, unless explicitly caught.
}
\examples{
code_highlight(deparse(ls))
cat(code_highlight(deparse(ls)), sep = "\n")
}
\seealso{
Other syntax highlighting:
\code{\link{code_theme_list}()}
}
\concept{syntax highlighting}
|