highlight function performs syntax highlighting based on the
results of the parse and the investigation
of a detective.highlight(file, output = stdout(), detective = simple_detective, renderer,
encoding = "unknown", parse.output = parse(file, encoding = encoding,
keep.source = TRUE), styles = detective(parse.output), expr = NULL,
final.newline = FALSE, showPrompts = FALSE,
prompt = getOption("prompt"), continue = getOption("continue"),
initial.spaces = TRUE, size = c("normalsize", "tiny", "scriptsize",
"footnotesize", "small", "large", "Large", "LARGE", "huge", "Huge"),
show_line_numbers = FALSE, ...)parse.output is givensink function
is used to redirect the standard output to the output.parserenderer_html
and renderer_latexparse.parse. If this is given, the
arguments file and encoding are not usedNULLrenderer_html and renderer_latex are the
two implementation of renderers currently available in this package. simple_detective is an example detective which does a very
simple investigation.
tf <- tempfile()
dump( "jitter", file = tf )
highlight( file = tf, detective = simple_detective,
renderer = renderer_html( document = TRUE ) )
highlight( file = tf, detective = simple_detective,
renderer = renderer_latex( document = TRUE ) )Run the code above in your browser using DataLab