13 13 through an AST, and writes to many output formats. Agents use it primarily for:
14 14 format conversion, PDF generation, content extraction, and document pipelines with Lua filters.
16 -**Version**: targets pandoc 3.x (tested on 3.6). Features like `--sandbox`, `--syntax-highlighting`,
16 +**Version**: targets pandoc 3.x (tested on 3.6). Features like `--sandbox`,
17 17 `--variable-json`, and the modern Table AST require pandoc ≥ 3.0.
19 19 **Official docs**: <https://pandoc.org/MANUAL.html>
184 184 pandoc doc.md -s --css=style.css -o doc.html
186 186 #
With syntax highlighting style 187 -pandoc doc.md -s --syntax-highlighting=kate -o doc.html
187 +pandoc doc.md -s --highlight-style=kate -o doc.html
189 189 #
Section divs (wrap in <section> tags) 190 190 pandoc doc.md -s --section-divs -o doc.html
273 273 pandoc slides.md -t beamer -V aspectratio=169 -o slides.pdf
280 +| `default` | Clean, minimal |
281 +| `metropolis` | Modern, flat (requires metropolis package) |
282 +| `Madrid` | Classic academic |
283 +| `CambridgeUS` | Formal with colors |
284 +| `Warsaw` | Sidebar navigation |
285 +| `Boadilla` | Compact footline |
286 +| `Singapore` | Clean with mini frames |
288 +Set with `-V theme=NAME`. Use `-V colortheme=NAME` for color schemes (crane, dolphin, orchid, whale, etc.).
278 292 Slides are separated by headings. The `--slide-level` option controls which heading level creates slides:
464 +##
7. EPUB Generation 468 +pandoc book.md -o book.epub
471 +pandoc ch1.md ch2.md ch3.md metadata.yaml -o book.epub
474 +pandoc book.md --epub-cover-image
=cover.png -o book.epub
477 +pandoc book.md --css
=epub.css -o book.epub
480 +pandoc book.md --epub-embed-font
=DejaVuSans.ttf -o book.epub
483 +pandoc book.md --split-level
=2 -o book.epub
486 +pandoc book.md --epub-metadata
=meta.xml -o book.epub
489 +###
EPUB YAML Metadata 494 +author: "Author Name"
495 +rights: "Creative Commons"
497 +cover-image: cover.png
498 +stylesheet: epub.css
502 +###
EPUB Metadata XML 505 +<
dc:rights>Creative Commons</
dc:rights>
506 +<
dc:language>en</
dc:language>
513 +Typst is a modern, fast alternative to LaTeX for PDF generation. No TeX installation needed.
517 +pandoc doc.md -t typst -o doc.typ
520 +pandoc doc.md --pdf-engine
=typst -o doc.pdf
525 +| Variable | Example | Effect |
526 +|----------|---------|--------|
527 +| `papersize` | `a4`, `us-letter` | Paper size |
528 +| `margin` | `{x: 2cm, y: 3cm}` | Page margins (dict) |
529 +| `mainfont` | `"Noto Sans"` | Body font |
530 +| `fontsize` | `12pt` | Body font size |
531 +| `codefont` | `"Fira Code"` | Code font |
532 +| `mathfont` | `"New Computer Modern"` | Math font |
533 +| `columns` | `2` | Number of columns |
534 +| `linestretch` | `1.5` | Line spacing |
535 +| `section-numbering` | `1.A.1` | Section numbering schema |
536 +| `page-numbering` | `1` or `i` | Page numbering schema |
538 +Typst is significantly faster than LaTeX for large documents and has better error messages.
501 593 Templates control standalone output structure. Variables are interpolated with `$var$` syntax.
539 -##
9. Citations & Bibliography 631 +##
11. Citations & Bibliography 572 -##
10. Content Extraction & Processing 664 +##
12. Content Extraction & Processing 593 -##
11. Defaults Files 685 +##
13. Defaults Files 595 687 Reusable YAML config files instead of long CLI commands:
624 -##
12. Common Agent Pipelines 716 +##
14. Common Agent Pipelines 626 718 ###
Web Page → Clean Markdown 643 735 -V linkcolor=blue \
644 736 --toc --toc-depth=3 \
646 - --syntax-highlighting=kate
738 + --highlight-style=kate
649 741 ### Docx → Markdown (with images)
661 753 pandoc analysis.ipynb
\ 662 754 -s --embed-resources
\ 663 755 --css=report.css
\ 664 - --syntax-highlighting=tango
\ 756 + --highlight-style=tango
\ 703 -##
13. Key CLI Options Reference 795 +##
15. Key CLI Options Reference 705 797 | Option | Effect |
706 798 |--------|--------|
729 821 | `--bibliography=FILE` | Bibliography file |
730 822 | `-d` / `--defaults=FILE` | Defaults file |
731 823 | `--sandbox` | Restrict file access |
732 -| `--syntax-highlighting=STYLE` | Highlighting style or `none` |
824 +| `--highlight-style=STYLE` | Highlighting style or `none` |
733 825 | `-H` / `--include-in-header` | Include raw in header |
734 826 | `-B` / `--include-before-body` | Include before body |
735 827 | `-A` / `--include-after-body` | Include after body |
744 836 | Code | Meaning |
745 837 |------|---------|
760 -##
15. Helper Scripts 852 +##
17. Helper Scripts (Cross-Platform) 762 -See `scripts/` directory:
854 +All scripts are written in Lua and run via `pandoc lua` — works on Linux, macOS, and Windows.
764 -- `pandoc-batch-convert.sh` — Batch convert files between formats
765 -- `pandoc-md-to-pdf.sh` — Markdown to polished PDF with sensible defaults
766 -- `pandoc-web-to-md.sh` — Fetch URL and convert to clean Markdown
767 -- `pandoc-wordcount.lua` — Count words in document body
858 +pandoc lua scripts/pandoc-batch-convert.lua md html -s --toc
861 +pandoc lua scripts/pandoc-md-to-pdf.lua report.md
862 +pandoc lua scripts/pandoc-md-to-pdf.lua report.md draft.pdf --draft
865 +pandoc lua scripts/pandoc-web-to-md.lua https://example.com page.md
868 +pandoc --lua-filter
=scripts/pandoc-wordcount.lua doc.md
769 871 ###
Lua Filter Library 771 -See `references/` directory:
873 +See `references/filters/` directory:
773 -- `filters/strong-to-smallcaps.lua` — Convert **bold** to SMALL CAPS
774 -- `filters/center-images.lua` — Center images in HTML/LaTeX
775 -- `filters/meta-vars.lua` — Replace `%var%` placeholders with metadata values
776 -- `filters/extract-headings.lua` — Extract document outline
777 -- `filters/add-meta-date.lua` — Auto-set date metadata
778 -- `filters/remove-empty-paras.lua` — Strip empty paragraphs
875 +- `strong-to-smallcaps.lua` — Convert **bold** to SMALL CAPS
876 +- `center-images.lua` — Center images in HTML/LaTeX
877 +- `meta-vars.lua` — Replace `%var%` placeholders with metadata values
878 +- `extract-headings.lua` — Extract document outline
879 +- `add-meta-date.lua` — Auto-set date metadata
880 +- `remove-empty-paras.lua` — Strip empty paragraphs
881 +- `admonitions.lua` — Style `:::note`/`:::warning`/`:::tip` div blocks
883 +###
Reusable Defaults Files 885 +See `references/defaults/` directory:
887 +- `pdf-report.yaml` — Polished PDF report with TOC, numbered sections, XeLaTeX
893 +When processing untrusted input, use `--sandbox` to restrict file access:
897 +pandoc --sandbox untrusted.md -o safe.html
900 +pandoc --sandbox --lua-filter
=my-filter.lua untrusted.md -o out.html
904 +- Binary formats (docx, odt) may fail in sandbox mode unless pandoc was compiled with `embed_data_files`
905 +- Filters and PDF engines run outside sandbox
906 +- Best for: converting untrusted Markdown/HTML to safe output