Debian Codegraph @

man/output_hooks.Rd

raw
1 % Generated by roxygen2: do not edit by hand
2 % Please edit documentation in R/hooks-html.R, R/hooks-asciidoc.R,
3 % R/hooks-latex.R, R/hooks-md.R, R/hooks-rst.R, R/hooks-textile.R
4 \name{render_html}
5 \alias{render_html}
6 \alias{hooks_html}
7 \alias{render_asciidoc}
8 \alias{hooks_asciidoc}
9 \alias{render_latex}
10 \alias{hooks_latex}
11 \alias{render_sweave}
12 \alias{hooks_sweave}
13 \alias{render_listings}
14 \alias{hooks_listings}
15 \alias{render_markdown}
16 \alias{hooks_markdown}
17 \alias{render_jekyll}
18 \alias{hooks_jekyll}
19 \alias{render_rst}
20 \alias{hooks_rst}
21 \alias{render_textile}
22 \alias{hooks_textile}
23 \title{Set or get output hooks for different output formats}
24 \usage{
25 render_html()
26
27 hooks_html()
28
29 render_asciidoc()
30
31 hooks_asciidoc()
32
33 render_latex()
34
35 hooks_latex()
36
37 render_sweave()
38
39 hooks_sweave(envirs = c("Sinput", "Soutput", "Schunk"))
40
41 render_listings()
42
43 hooks_listings(envirs = c("Sinput", "Soutput", "Schunk"))
44
45 render_markdown(strict = FALSE, fence_char = "`")
46
47 hooks_markdown(strict = FALSE, fence_char = "`")
48
49 render_jekyll(highlight = c("pygments", "prettify", "none"), extra = "")
50
51 hooks_jekyll(highlight = c("pygments", "prettify", "none"), extra = "")
52
53 render_rst(strict = FALSE)
54
55 hooks_rst(strict = FALSE)
56
57 render_textile()
58
59 hooks_textile()
60 }
61 \arguments{
62 \item{envirs}{Names of LaTeX environments for code input, output, and chunk.}
63
64 \item{strict}{Boolean; whether to use strict markdown or reST syntax. For markdown, if
65 \code{TRUE}, code blocks will be indented by 4 spaces, otherwise they are
66 put in fences made by three backticks. For reST, if \code{TRUE}, code is
67 put under two colons and indented by 4 spaces, otherwise it is put under the
68 \samp{sourcecode} directive (this is useful for e.g. Sphinx).}
69
70 \item{fence_char}{A single character to be used in the code blocks fence.
71 This can be e.g. a backtick or a tilde, depending on your Markdown rendering
72 engine.}
73
74 \item{highlight}{Which code highlighting engine to use: if \code{pygments},
75 the Liquid syntax is used (default approach Jekyll); if \code{prettify},
76 the output is prepared for the JavaScript library \file{prettify.js}; if
77 \code{none}, no highlighting engine will be used, and code blocks are simply
78 indented by 4 spaces).}
79
80 \item{extra}{Extra tags for the highlighting engine. For \code{pygments}, this
81 can be \code{'linenos'}; for \code{prettify}, it can be \code{'linenums'}.}
82 }
83 \value{
84 \code{NULL} for \code{render_*} functions; corresponding hooks are
85 set as a side effect. A list of output hooks for \code{hooks_*()}
86 functions.
87 }
88 \description{
89 The \code{render_*()} functions set built-in output hooks for LaTeX, HTML,
90 Markdown, reStructuredText, AsciiDoc, and Textile. The \code{hooks_*()}
91 functions return a list of the output hooks for the corresponding format.
92 }
93 \details{
94 There are three variants of Markdown documents: ordinary Markdown
95 (\code{render_markdown(strict = TRUE)}, which calls
96 \code{hooks_markdown(strict = TRUE)}), extended Markdown (e.g., GitHub
97 Flavored Markdown and Pandoc; \code{render_markdown(strict = FALSE)}, which
98 calls \code{hooks_markdown(strict = FALSE)}), and Jekyll (a blogging system
99 on GitHub; \code{render_jekyll()}, which calls \code{hooks_jekyll()}).
100
101 For LaTeX output, there are three variants: \pkg{knitr}'s default style
102 (\code{render_latex()}, which calls \code{hooks_latex()} and uses the LaTeX
103 \pkg{framed} package), Sweave style (\code{render_sweave()}, which calls
104 \code{hooks_sweave()} and uses \file{Sweave.sty}), and listings style
105 (\code{render_listings()}, which calls \code{hooks_listings()} and uses LaTeX
106 \pkg{listings} package).
107
108 Default HTML output hooks are set by \code{render_html()} (which calls
109 \code{hooks_html()}); \code{render_rst()} (which calls \code{hooks_rst()}) is
110 for reStructuredText; \code{render_textile()} (which calls
111 \code{hooks_textile()}) is for Textile, and \code{render_asciidoc()} (which
112 calls \code{hooks_asciidoc()}) is AsciiDoc.
113
114 The \code{render_*()} functions can be used before \code{knit()} or in the
115 first chunk of the input document (ideally this chunk has options
116 \code{include = FALSE} and \code{cache = FALSE}) so that all the following
117 chunks will be formatted as expected.
118
119 You can also use \code{\link{knit_hooks}} to set the format's hooks with the
120 \code{hooks_*()} functions; see references for more info on further
121 customizing output hooks.
122 }
123 \examples{
124 # below is pretty much what knitr::render_markdown() does:
125 knitr::knit_hooks$set(knitr::hooks_markdown())
126
127 # you can retrieve a subset of the hooks and set them, e.g.,
128 knitr::knit_hooks$set(knitr::hooks_markdown()["source"])
129
130 knitr::knit_hooks$restore()
131 }
132 \references{
133 See output hooks in \url{https://yihui.org/knitr/hooks/}, and
134 some examples in
135 \url{https://bookdown.org/yihui/rmarkdown-cookbook/output-hooks.html}
136
137 Jekyll and Liquid:
138 \url{https://github.com/jekyll/jekyll/wiki/Liquid-Extensions}; prettify.js:
139 \url{https://code.google.com/archive/p/google-code-prettify}
140 }