Published on

pandoc: Why It's Awesome, and How I Use It

Authors
  • avatar
    Name
    Teddy Xinyuan Chen
    Twitter
Table of Contents

I love pandoc

It has everything you can ask for. It's like a classic UNIX tool that follows the KISS principle.

For binary ebook formats that pandoc doesn't support (yet), I use ebook-convert from Calibre.

My terminal app of choice is kitty, also made by the same author of calibre.

How I Use it

Ad-Hoc Format Conversion

For example, epub -> md with -t gfm-raw_html (disables raw_html extension to get clean md output)

As a Static Site Generator

As a static site generator for simple HTML pages and slides, see this post.

For HW Assignments

I write everything in markdown with LaTeX math and convert it to the requested format desired by the professor or other group members (who loves .docx, while I was in Fudan).

Academic Writing

After hours of Googling and lots of experiment and lots of debugging, I finally figured out how to use pandoc to convert a TeX template, a .bib file, and a markdown file (with minimal tex in it, tex are for citing / referencing / including graphics) into a publishing-grade PDF paper, and it saved me so much time without having to mess with LaTeX directly.

Non-standard Uses

I sometimes hack together some Lua / Pyhon pandoc filter to deal with texts in specific formats.

Shell Aliases I Have in my .*shrc

# only showing part of them here
pdc_zh_cn_pingfang='pandoc --pdf-engine=xelatex -V mainfont='\''PingFang SC'\'
pdc_zh_hk_pingfang='pandoc --pdf-engine=xelatex -V mainfont='\''PingFang HK'\'
pdc_zh_tw_pingfang='pandoc --pdf-engine=xelatex -V mainfont='\''PingFang TC'\'
pdcfmdbareuri='command pandoc -f markdown+autolink_bare_uris -V colorlinks=true --pdf-engine=xelatex'
pdcfmdtex='command pandoc -f markdown+tex_math_single_backslash+autolink_bare_uris -V colorlinks=true --pdf-engine=xelatex'
pdcgeoa6='pandoc -V geometry:a6paper'
pdch='command pandoc -h | less -F'
pdchh='command pandoc -h | grep -i --'
pdchw='command pandoc -f markdown+tex_math_single_backslash+autolink_bare_uris -V colorlinks=true --pdf-engine=xelatex -V monofont="JuliaMono" -V mainfont="STIX Two Math"'
pdclse='pandoc --list-extensions'
pdclseG='pandoc --list-extensions | grep -i --'
pdclseGW='pandoc --list-extensions | grep -iw --'
pdclsif='pandoc --list-input-formats | less -F'
pdclsifG='pandoc --list-input-formats | grep -i --'
pdclsifGW='pandoc --list-input-formats | grep -iw --'
pdclsof='pandoc --list-output-formats | less -F'
pdclsofG='pandoc --list-output-formats | grep -i --'
pdclsofGW='pandoc --list-output-formats | grep -iw --'
pdcs='pandoc -s'
pdctogfmnohtml='command pandoc --to gfm-raw_html'

I defined them a long time ago and I only use a few of them regularly.

See Also

https://pandoc.org/ (this site has no favicon, as of 2024-04-17. That's very unique among software project homepages.)