| 1 |
% Generated by roxygen2: do not edit by hand |
| 2 |
% Please edit documentation in R/pandoc.R |
| 3 |
\name{pandoc} |
| 4 |
\alias{pandoc} |
| 5 |
\title{A Pandoc wrapper to convert documents to other formats} |
| 6 |
\usage{ |
| 7 |
pandoc(input, format, config = getOption("config.pandoc"), ext = NA) |
| 8 |
} |
| 9 |
\arguments{ |
| 10 |
\item{input}{A character vector of Markdown filenames (must be encoded in |
| 11 |
UTF-8).} |
| 12 |
|
| 13 |
\item{format}{Name of the output format (see References). This can be a |
| 14 |
character vector of multiple formats; by default, it is obtained from the |
| 15 |
\code{t} field in the configuration. If the configuration is empty or the |
| 16 |
\code{t} field is not found, the default output format will be |
| 17 |
\code{'html'}.} |
| 18 |
|
| 19 |
\item{config}{Path to the Pandoc configuration file. If missing, it is |
| 20 |
assumed to be a file with the same base name as the \code{input} file and |
| 21 |
an extension \code{.pandoc} (e.g. for \file{foo.md} it looks for |
| 22 |
\file{foo.pandoc})} |
| 23 |
|
| 24 |
\item{ext}{Filename extensions. By default, the extension is inferred from |
| 25 |
the \code{format}, e.g. \code{latex} creates \code{pdf}, \code{dzslides} |
| 26 |
creates \code{html}, and so on} |
| 27 |
} |
| 28 |
\value{ |
| 29 |
The output filename(s) (or an error if the conversion failed). |
| 30 |
} |
| 31 |
\description{ |
| 32 |
This function calls Pandoc to convert documents to other formats such as |
| 33 |
HTML, LaTeX/PDF and Word, etc, (optionally) based on a configuration file or |
| 34 |
in-file configurations which specify the options to use for Pandoc. |
| 35 |
} |
| 36 |
\details{ |
| 37 |
There are two ways to input the Pandoc configurations -- through a config |
| 38 |
file, or embed the configurations in the input file as special comments |
| 39 |
between \verb{<!--pandoc} and \verb{-->}. |
| 40 |
|
| 41 |
The configuration file is a DCF file (see \code{\link{read.dcf}}). This file |
| 42 |
must contain a field named \code{t} which means the output format. The |
| 43 |
configurations are written in the form of \code{tag:value} and passed to |
| 44 |
Pandoc (if no value is needed, just leave it empty, e.g. the option |
| 45 |
\code{standalone} or \code{s} for short). If there are multiple output |
| 46 |
formats, write each format and relevant configurations in a block, and |
| 47 |
separate blocks with blank lines. |
| 48 |
|
| 49 |
If there are multiple records of the \code{t} field in the configuration, the |
| 50 |
input markdown file will be converted to all these formats by default, unless |
| 51 |
the \code{format} argument is specified as one single format. |
| 52 |
} |
| 53 |
\examples{ |
| 54 |
system("pandoc -h") # see possible output formats |
| 55 |
} |
| 56 |
\references{ |
| 57 |
Pandoc: \url{https://pandoc.org}; Examples and rules of the |
| 58 |
configurations: \url{https://yihui.org/knitr/demo/pandoc/} |
| 59 |
|
| 60 |
Also see R Markdown (v2) at \url{https://rmarkdown.rstudio.com}. The |
| 61 |
\pkg{rmarkdown} package has several convenience functions and templates |
| 62 |
that make it very easy to use Pandoc. The RStudio IDE also has |
| 63 |
comprehensive support for it, so I'd recommend users who are not familiar |
| 64 |
with command-line tools to use the \pkg{rmarkdown} package instead. |
| 65 |
} |
| 66 |
\seealso{ |
| 67 |
\code{\link{read.dcf}} |
| 68 |
} |