highlight-package | R Documentation |
Syntax highlighter for R based on output from the R parser
The main function of the package is highlight
.
highlight
delegates rendering the document to
renderer
s, 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.
## 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.