View source: R/pygments-engine.r
knitr_pygments_engine | R Documentation |
Pygments is a generic syntax highlighter suitable for use in code hosting, forums, wikis or other applications that need to prettify source code. This knitr engine only highlights code, it will not execute it.
knitr_pygments_engine(options)
options |
knitr options (required parameter) |
This requires setting of two options, pyg.ext
which should be a file
extension recognized by the pygments lexer (i.e. py
for Python) and
an optional styling (pyg.sty
) for the code output. One of autumn
,
borland
, bw
, colorful
, default
, emacs
,
friendly
, fruity
, github
, manni
, monokai
,
murphy
, native
, pastie
, perldoc
, tango
,
trac
, vim
, vs
, zenburn
.
It will use default
if none are
specified. Styles nabbed from https://github.com/richleland/pygments-css.
You can install pygments
via pip install pygments
.
There is currently a limitation of one highlight style per knitr document.
echo
should be FALSE
and results
should be asis
.
However this function will automagically add them if they aren't there. Also,
this function requrires the system program pygmentize
to be on the
executable PATH
. It won't work without it.
Bob Rudis
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.