Learn R Programming

highlight (version 0.3.1)

renderer: highlight renderer

Description

The function builds a renderer, suitable for the renderer argument of the highlight function. In the highlight process, renderers are responsible to render the information in the target markup language.

Usage

renderer(translator, formatter, space, newline, header, footer, ...)

Arguments

translator
This argument should be a function with one argument. The translator needs to work token characters so that they display nicely in the target markup language.
formatter
The formatter should be a function with at least two arguments: the tokens and the styles. These two arguments are supplied to the formatter by the highlight function. The formatter should wrap tokens and styles into the target markup language. For exa
space
This should be a function with no argument. The output of this function should be a character vector of length one giving the representation of a space character in the target language. For example, in the latex renderer, the function returns "{\ }
newline
This should be a function with no argument. The output of the function is a character vector of length one giving the representation of a newline character in the target language.
header
This should be a function with no argument. The output of this function is a character vector of arbitrary length. The elements of the output are written before the highlighted content. headers and footers are used to embed the highlighted tokens into s
footer
This should be a function with no argument. The output of this function is written after all tokens.
...
Additional arguments. This might be used to store additional renderer specific objects.

Value

  • A renderer object. Renderer objects define the interface expected by the highlight function. At the moment, a renderer object is a list of class renderer containing elements: translator, formatter, space, newline, header and footer.

See Also

The renderer_html implements a renderer using html markup, tags and CSS.

The renderer_latex implements a latex renderer.

The renderer_verbatim implements a renderer that does not do anything.

The renderer_xterm function in the xterm256 package implements a renderer based on the 256 color mode of xterm suitable for rendering the information in an xterm console.

Examples

Run this code
# html renderer which will render the content as a document
# (starting with <html> tags
r <- renderer_html( document = T )

# html renderer suitable to render the information within 
# an already built document
r <- renderer_html( document = F )

Run the code above in your browser using DataLab