knitr_pygments_engine: knitr engine for the pygments syntax highlighting (w/o...

View source: R/pygments-engine.r

knitr_pygments_engineR Documentation

knitr engine for the pygments syntax highlighting (w/o execution)

Description

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.

Usage

knitr_pygments_engine(options)

Arguments

options

knitr options (required parameter)

Details

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.

Note

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.

Author(s)

Bob Rudis

References

http://pygments.org/


hrbrmstr/knitrengines documentation built on Sept. 17, 2023, 2:29 a.m.