Debian Codegraph @

man/output_type.Rd

raw
1 % Generated by roxygen2: do not edit by hand
2 % Please edit documentation in R/utils.R
3 \name{is_latex_output}
4 \alias{is_latex_output}
5 \alias{is_html_output}
6 \alias{pandoc_to}
7 \alias{pandoc_from}
8 \title{Check the current input and output type}
9 \usage{
10 is_latex_output()
11
12 is_html_output(fmt = pandoc_to(), excludes = NULL)
13
14 pandoc_to(fmt, exact = FALSE)
15
16 pandoc_from(exact = FALSE)
17 }
18 \arguments{
19 \item{fmt}{A character vector of output formats to be checked against. If not
20 provided, \code{is_html_output()} uses \code{pandoc_to()}, and
21 \code{pandoc_to()} returns the output format name.}
22
23 \item{excludes}{A character vector of output formats that should not be
24 considered as HTML format. Options are: markdown, epub, epub2, html, html4, html5,
25 revealjs, s5, slideous, slidy, and gfm.}
26
27 \item{exact}{Whether to return or use the exact format name. If not, Pandoc
28 extensions will be removed from the format name, e.g., \samp{latex-smart}
29 will be treated as \samp{latex}.}
30 }
31 \description{
32 The function \code{is_latex_output()} returns \code{TRUE} when the output
33 format is LaTeX; it works for both \file{.Rnw} and R Markdown documents (for
34 the latter, the two Pandoc formats \code{latex} and \code{beamer} are
35 considered LaTeX output). The function \code{is_html_output()} only works for
36 R Markdown documents and will test for several Pandoc HTML based output
37 formats (by default, these formats are considered as HTML formats:
38 \code{c('markdown', 'epub', 'epub2', 'html', 'html4', 'html5', 'revealjs', 's5',
39 'slideous', 'slidy', 'gfm')}).
40 }
41 \details{
42 The function \code{pandoc_to()} returns the Pandoc output format, and
43 \code{pandoc_from()} returns Pandoc input format. \code{pandoc_to(fmt)}
44 allows to check the current output format against a set of format names. Both
45 are to be used with R Markdown documents.
46
47 These functions may be useful for conditional output that depends on the
48 output format. For example, you may write out a LaTeX table in an R Markdown
49 document when the output format is LaTeX, and an HTML or Markdown table when
50 the output format is HTML. Use \code{pandoc_to(fmt)} to test a more specific
51 Pandoc format.
52
53 Internally, the Pandoc output format of the current R Markdown document is
54 stored in \code{knitr::\link{opts_knit}$get('rmarkdown.pandoc.to')}, and the
55 Pandoc input format in
56 \code{knitr::\link{opts_knit}$get('rmarkdown.pandoc.from')}
57 }
58 \note{
59 See available Pandoc formats, in
60 \href{https://pandoc.org/MANUAL.html}{Pandoc's Manual}
61 }
62 \examples{
63 # check for output formats type
64 knitr::is_latex_output()
65 knitr::is_html_output()
66 knitr::is_html_output(excludes = c("markdown", "epub"))
67 # Get current formats
68 knitr::pandoc_from()
69 knitr::pandoc_to()
70 # Test if current output format is 'docx'
71 knitr::pandoc_to("docx")
72 }