highlight-package: Syntax Highlighter for R

Description See Also Examples

Description

Syntax highlighter for R based on output from the R parser

See Also

The main function of the package is highlight.

highlight delegates rendering the document to renderers, such as the renderer_latex or renderer_html and is helped by a detective to make sense of the results from the parser. The package ships a simple_detective.

The package also defines a custom sweave driver (HighlightWeaveLatex) for latex based on the standard sweave latex driver (RweaveLatex) using highlight to perform syntax highlighting of R code chunks.

Examples

 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
## Not run: 
tf <- tempfile()
dump( "glm" , file = tf )

# rendering in html
highlight( tf, output = stdout(),
	renderer = renderer_html() )

# rendering in latex
highlight( tf, output = stdout(),
	renderer = renderer_latex() )

# Sweave driver using syntax highlighting
if( require( grid ) ){
	v <- vignette( "grid", package = "grid" )$file
	file.copy( v, "grid.Snw" )
	Sweave( "grid.Snw", driver= HighlightWeaveLatex() )
	system( "pdflatex grid.tex" )
	if (.Platform$OS.type == "windows"){
		shell.exec( "grid.pdf" )
	} else {
		system(paste(shQuote(getOption("pdfviewer")), "grid.pdf" ),
			wait = FALSE)
	}
}

unlink( tf )

## End(Not run)

highlight documentation built on Oct. 4, 2017, 5:05 p.m.