pandoc: Convert Between Document Formats
pandoc -o output.html input.md converts between dozens of markup and document formats, inferring formats from the file extensions.
Pandoc is the universal document converter. Most CI uses are Markdown to HTML or DOCX; the format is usually inferred from extensions, but -f/-t make it explicit.
What it does
pandoc reads the input in a source format, builds an internal document model, and writes it in the target format. Formats are inferred from -o and the input extension, or set explicitly with -f (from) and -t (to). --standalone produces a full document with header/footer.
Common usage
pandoc -o output.html input.md
# explicit formats, standalone with a table of contents
pandoc -f markdown -t html --standalone --toc -o out.html input.md
# combine several files into one DOCX
pandoc intro.md chapters/*.md -o book.docxOptions
| Flag | What it does |
|---|---|
| -o <file> | Output file (format inferred from extension) |
| -f <format> | Input (from) format |
| -t <format> | Output (to) format |
| -s / --standalone | Produce a complete standalone document |
| --toc | Include a table of contents |
| --template <file> | Use a custom output template |
| --metadata-file <f> | Supply document metadata |
In CI
Pin the pandoc version, since output changes across releases; the official Docker image (pandoc/core, pandoc/latex) is the most reproducible option. For HTML and DOCX no extra tools are needed; PDF output needs a separate engine (see the PDF page).
Common errors in CI
pandoc: input.md: openBinaryFile: does not exist (No such file or directory) means the input path is wrong. Unknown input format ... or Unknown output format ... means an unsupported -f/-t value or an unrecognized extension. pandoc: Could not find data file templates/default.html means a custom template path is wrong.