Description Details Author(s) See Also Examples
Syntax highlighter for R based on output from the R parser
| Package: | highlight |
| Type: | Package |
| Version: | 0.3.1 |
| Date: | 2011-12-05 |
| License: | GPL (>= 2) |
| LazyLoad: | yes |
Romain Francois
Maintainer: Romain Francois <romain@r-enthusiasts.com>
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.
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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.