File: pandoc.Rd

package info (click to toggle)
r-cran-knitr 1.50%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 1,864 kB
  • sloc: makefile: 16; sh: 10; javascript: 8
file content (68 lines) | stat: -rw-r--r-- 2,851 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/pandoc.R
\name{pandoc}
\alias{pandoc}
\title{A Pandoc wrapper to convert documents to other formats}
\usage{
pandoc(input, format, config = getOption("config.pandoc"), ext = NA)
}
\arguments{
\item{input}{A character vector of Markdown filenames (must be encoded in
UTF-8).}

\item{format}{Name of the output format (see References). This can be a
character vector of multiple formats; by default, it is obtained from the
\code{t} field in the configuration. If the configuration is empty or the
\code{t} field is not found, the default output format will be
\code{'html'}.}

\item{config}{Path to the Pandoc configuration file. If missing, it is
assumed to be a file with the same base name as the \code{input} file and
an extension \code{.pandoc} (e.g. for \file{foo.md} it looks for
\file{foo.pandoc})}

\item{ext}{Filename extensions. By default, the extension is inferred from
the \code{format}, e.g. \code{latex} creates \code{pdf}, \code{dzslides}
creates \code{html}, and so on}
}
\value{
The output filename(s) (or an error if the conversion failed).
}
\description{
This function calls Pandoc to convert documents to other formats such as
HTML, LaTeX/PDF and Word, etc, (optionally) based on a configuration file or
in-file configurations which specify the options to use for Pandoc.
}
\details{
There are two ways to input the Pandoc configurations -- through a config
file, or embed the configurations in the input file as special comments
between \verb{<!--pandoc} and \verb{-->}.

The configuration file is a DCF file (see \code{\link{read.dcf}}). This file
must contain a field named \code{t} which means the output format. The
configurations are written in the form of \code{tag:value} and passed to
Pandoc (if no value is needed, just leave it empty, e.g. the option
\code{standalone} or \code{s} for short). If there are multiple output
formats, write each format and relevant configurations in a block, and
separate blocks with blank lines.

If there are multiple records of the \code{t} field in the configuration, the
input markdown file will be converted to all these formats by default, unless
the \code{format} argument is specified as one single format.
}
\examples{
system("pandoc -h")  # see possible output formats
}
\references{
Pandoc: \url{https://pandoc.org}; Examples and rules of the
  configurations: \url{https://yihui.org/knitr/demo/pandoc/}

  Also see R Markdown (v2) at \url{https://rmarkdown.rstudio.com}. The
  \pkg{rmarkdown} package has several convenience functions and templates
  that make it very easy to use Pandoc. The RStudio IDE also has
  comprehensive support for it, so I'd recommend users who are not familiar
  with command-line tools to use the \pkg{rmarkdown} package instead.
}
\seealso{
\code{\link{read.dcf}}
}