A Pandoc wrapper to convert Markdown documents to other formats
This function calls Pandoc to convert Markdown 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.
pandoc(input, format, config = getOption("config.pandoc"), ext = NA, encoding = getOption("encoding"))
- a character vector of the Markdown filenames
- the output format (see References); it can be a character
vector of multiple formats; by default, it is obtained from the
tfield in the configuration (if the configuration is empty or the
tfield is not found, the default output
- the Pandoc configuration file; if missing, it is assumed to be
a file with the same base name as the
inputfile and an extension
foo.mdit looks for foo.pandoc)
- the filename extensions; by default, the extension is inferred
html, and so on
- the encoding of the input file; see
There are two ways to input the Pandoc configurations -- through a config
file, or embed the configurations in the markdown file as special comments
The configuration file is a DCF file (see
read.dcf). This file
must contain a field named
t which means the output format. The
configurations are written in the form of
tag:value and passed to
Pandoc (if no value is needed, just leave it empty, e.g. the option
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
t field in the configuration, the
input markdown file will be converted to all these formats by default, unless
format argument is specified as one single format.
- The output filename(s) (or an error if the conversion failed).
system("pandoc -h") # see possible output formats