knitr (version 1.3)

pandoc: A Pandoc wrapper to convert Markdown documents to other formats

Description

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.

Usage

pandoc(input, format = "html", config = getOption("config.pandoc"))

Arguments

input
a character vector of the Markdown filenames
format
the output format (see References); it can be a character vector of multiple formats
config
the Pandoc configuration file; if missing, it is assumed to be a file with the same base name as the input file and an extension .pandoc (e.g. for foo.md it looks for foo.pandoc)

Value

  • The output filename(s) (or an error if the conversion failed).

Details

There are two ways to input the Pandoc configurations -- through a config file, or embed the configurations in the markdown file as special comments between .

The configuration file is a DCF file (see read.dcf). This file must contain a field named format 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 standalone or s for short). If there are multiple output formats, write each format and relevant configurations in a block, and separate blocks with blank lines.

References

Pandoc: http://johnmacfarlane.net/pandoc/; Examples and rules of the configurations: http://yihui.name/knitr/demo/pandoc

See Also

read.dcf

Examples

Run this code
system("pandoc -h")  # see possible output formats

Run the code above in your browser using DataCamp Workspace