name: pandoc description: "Document conversion between formats with Pandoc"
Pandoc
Use the bash tool with pandoc for document format conversion.
Setup
# Check if installed
command -v pandoc
# Install — macOS
brew install pandoc
# Install — Ubuntu/Debian
sudo apt install pandoc
# PDF output also requires LaTeX:
# Ubuntu/Debian: sudo apt install texlive-latex-base
# macOS: brew install --cask mactex (or basictex for lighter install)
Common Conversions
pandoc input.md -o output.pdf
pandoc input.md -o output.docx
pandoc input.md -o output.html --standalone
pandoc input.docx -o output.md
pandoc input.html -o output.md
With Styling
pandoc input.md -o output.pdf --template=template.tex
pandoc input.md -o output.html --css=style.css --standalone
pandoc input.md -o output.pdf -V geometry:margin=1in
Batch
for f in *.md; do pandoc "$f" -o "${f%.md}.pdf"; done
Metadata
pandoc input.md -o output.pdf --metadata title="Title" --metadata author="Author"
Tips
- Use --standalone (-s) for complete HTML documents
- Use --toc for automatic table of contents
- PDF output requires LaTeX (texlive) or use --pdf-engine=wkhtmltopdf
- Use read_file to check input, write_file to save templates