$linuxjunkies
>

pandoc(1)

Pandoc converts documents between different markup and word processing formats.

UbuntuDebianFedoraArch

Synopsis

pandoc [OPTIONS] [INPUT_FILE...]

Description

Pandoc is a universal document converter that reads from one format and writes to another. It supports a wide range of input and output formats including Markdown, HTML, LaTeX, Word, PDF, EPUB, and many others. Pandoc is commonly used for converting between markup languages, generating documentation, and batch-processing documents.

The command reads from input files (or stdin if none specified) and writes to stdout by default. You can specify the input and output formats explicitly, though Pandoc will attempt to infer them from file extensions.

Common options

FlagWhat it does
-f FORMAT, --from=FORMATSpecify input format (e.g., markdown, html, latex, docx, pdf)
-t FORMAT, --to=FORMATSpecify output format (e.g., html, pdf, docx, epub, markdown)
-o FILE, --output=FILEWrite output to FILE instead of stdout
-s, --standaloneProduce a standalone document with headers and footers
--template=FILEUse FILE as template for generating output
-V KEY=VAL, --variable=KEY:VALSet template variable KEY to VAL
--css=URLLink to CSS stylesheet in HTML output
--toc, --table-of-contentsInclude table of contents in output
-N, --number-sectionsNumber section headings in output
--highlight-style=STYLESpecify syntax highlighting style (e.g., pygments, kate, monochrome)
-M KEY=VAL, --metadata=KEY:VALSet metadata field KEY to VAL
--verbosePrint diagnostic information to stderr

Examples

Convert Markdown file to HTML

pandoc README.md -o README.html

Convert Markdown to PDF with explicit format specification

pandoc document.md -t pdf -o document.pdf

Convert HTML to Markdown, piping output to a file

pandoc -f html -t markdown website.html > converted.md

Generate standalone HTML with table of contents from Markdown

pandoc article.md -s --toc -o article.html

Convert Markdown to Beamer presentation PDF

pandoc presentation.md -t beamer -o slides.pdf

Convert Word document to Markdown

pandoc -f docx document.docx -t markdown -o document.md

Combine multiple Markdown files into EPUB with numbered sections

pandoc chapter*.md --toc -N -o book.epub

Generate HTML with custom CSS and language metadata

pandoc notes.md -s --css=style.css -V lang=en -o notes.html