The render_*()
functions set built-in output hooks for LaTeX, HTML,
Markdown, reStructuredText, AsciiDoc, and Textile. The hooks_*()
functions return a list of the output hooks for the corresponding format.
render_html()hooks_html()
render_asciidoc()
hooks_asciidoc()
render_latex()
hooks_latex()
render_sweave()
hooks_sweave(envirs = c("Sinput", "Soutput", "Schunk"))
render_listings()
hooks_listings(envirs = c("Sinput", "Soutput", "Schunk"))
render_markdown(strict = FALSE, fence_char = "`")
hooks_markdown(strict = FALSE, fence_char = "`")
render_jekyll(highlight = c("pygments", "prettify", "none"), extra = "")
hooks_jekyll(highlight = c("pygments", "prettify", "none"), extra = "")
render_rst(strict = FALSE)
hooks_rst(strict = FALSE)
render_textile()
hooks_textile()
NULL
for render_*
functions; corresponding hooks are
set as a side effect. A list of output hooks for hooks_*()
functions.
Names of LaTeX environments for code input, output, and chunk.
Boolean; whether to use strict markdown or reST syntax. For markdown, if
TRUE
, code blocks will be indented by 4 spaces, otherwise they are
put in fences made by three backticks. For reST, if TRUE
, code is
put under two colons and indented by 4 spaces, otherwise it is put under the
sourcecode directive (this is useful for e.g. Sphinx).
A single character to be used in the code blocks fence. This can be e.g. a backtick or a tilde, depending on your Markdown rendering engine.
Which code highlighting engine to use: if pygments
,
the Liquid syntax is used (default approach Jekyll); if prettify
,
the output is prepared for the JavaScript library prettify.js
; if
none
, no highlighting engine will be used, and code blocks are simply
indented by 4 spaces).
Extra tags for the highlighting engine. For pygments
, this
can be 'linenos'
; for prettify
, it can be 'linenums'
.
There are three variants of Markdown documents: ordinary Markdown
(render_markdown(strict = TRUE)
, which calls
hooks_markdown(strict = TRUE)
), extended Markdown (e.g., GitHub
Flavored Markdown and Pandoc; render_markdown(strict = FALSE)
, which
calls hooks_markdown(strict = FALSE)
), and Jekyll (a blogging system
on GitHub; render_jekyll()
, which calls hooks_jekyll()
).
For LaTeX output, there are three variants: knitr's default style
(render_latex()
, which calls hooks_latex()
and uses the LaTeX
framed package), Sweave style (render_sweave()
, which calls
hooks_sweave()
and uses Sweave.sty
), and listings style
(render_listings()
, which calls hooks_listings()
and uses LaTeX
listings package).
Default HTML output hooks are set by render_html()
(which calls
hooks_html()
); render_rst()
(which calls hooks_rst()
) is
for reStructuredText; render_textile()
(which calls
hooks_textile()
) is for Textile, and render_asciidoc()
(which
calls hooks_asciidoc()
) is AsciiDoc.
The render_*()
functions can be used before knit()
or in the
first chunk of the input document (ideally this chunk has options
include = FALSE
and cache = FALSE
) so that all the following
chunks will be formatted as expected.
You can also use knit_hooks
to set the format's hooks with the
hooks_*()
functions; see references for more info on further
customizing output hooks.
See output hooks in https://yihui.org/knitr/hooks/, and some examples in https://bookdown.org/yihui/rmarkdown-cookbook/output-hooks.html
Jekyll and Liquid: https://github.com/jekyll/jekyll/wiki/Liquid-Extensions; prettify.js: https://code.google.com/archive/p/google-code-prettify
# below is pretty much what knitr::render_markdown() does:
knitr::knit_hooks$set(knitr::hooks_markdown())
# you can retrieve a subset of the hooks and set them, e.g.,
knitr::knit_hooks$set(knitr::hooks_markdown()["source"])
knitr::knit_hooks$restore()
Run the code above in your browser using DataLab