highlight-package: Syntax highlighter for R

Description Details Author(s) See Also Examples

Description

Syntax highlighter for R based on output from the R parser

Details

Package: highlight
Type: Package
Version: 0.3.1
Date: 2011-12-05
License: GPL (>= 2)
LazyLoad: yes

Author(s)

Romain Francois

Maintainer: Romain Francois <romain@r-enthusiasts.com>

See Also

The main function of the package is highlight. The parser is a modified R parser using a very similar grammar to the standard parse function but presenting the information differently.

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

# modified R parser
p <- parser( 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)

Dasonk/highlight documentation built on May 6, 2019, 1:37 p.m.