Pandoc: What are the available syntax highlighters?

user1002119 picture user1002119 · Jun 17, 2015 · Viewed 22.9k times · Source

Bullet point 18 of http://pandoc.org/demos.html#examples shows how to change the syntax highlighter used by giving an argument to --highlight-style. For example:

pandoc code.text -s --highlight-style pygments -o example18a.html
pandoc code.text -s --highlight-style kate -o example18b.html
pandoc code.text -s --highlight-style monochrome -o example18c.html
pandoc code.text -s --highlight-style espresso -o example18d.html
pandoc code.text -s --highlight-style haddock -o example18e.html
pandoc code.text -s --highlight-style tango -o example18f.html
pandoc code.text -s --highlight-style zenburn -o example18g.html

I am wondering if these are the only color schemes available. If not, how can I load a different syntax highlighter? Can I define my own?

Answer

Kurt Pfeifle picture Kurt Pfeifle · Apr 10, 2016

If your pandoc --version indicates a release of 1.15.1 (from Oct 15, 2015) or newer, then you can check if the --bash-completion parameter works for you to get a full list of available built-in highlighting styles.

Run

pandoc --bash-completion

If it works, you'll see a lot of output. And it will be useful well beyond the original question above...

If --bash-completion works, then put this line towards the end of your ${HOME}/.bashrc file (on Mac OS X or Linux -- doesn't work on Windows yet):

eval "$(pandoc --bash-completion)"

Once you open a new terminal, you can use the pandoc command with "tab completion":

pandoc --h[tab]

will yield

--help     --highlight-style  --html-q-tags

pandoc --hi[tab]

will yield

pandoc --highlight-style

Answer to original question:

Now punch the [tab] key one more time, and you'll see

espresso   haddock   kate   monochrome  pygments    tango    zenburn

It's the list of all available syntax highlighters. To shorten the precedure, you could also type

pandoc --hi[tab][tab]

to get the same result.

Usefulness of Pandoc's tab completion beyond original question:

Pandoc's bash tab completion also works for all other commandline switches:

pandoc -h[tab]

yields this -- a list of all possible command line parameters:

Display all 108 possibilities? (y or n)
--ascii                    --indented-code-classes    --template
--asciimathml              --jsmath                   --title-prefix
--atx-headers              --katex                    --to
--base-header-level        --katex-stylesheet         --toc
--bash-completion          --latex-engine             --toc-depth
--biblatex                 --latex-engine-opt         --trace
--bibliography             --latexmathml              --track-changes
--chapters                 --listings                 --variable
--citation-abbreviations   --mathjax                  --verbose
--columns                  --mathml                   --version
--csl                      --metadata                 --webtex
--css                      --mimetex                  --wrap
--data-dir                 --natbib                   --write
--default-image-extension  --no-highlight             -A
--dpi                      --no-tex-ligatures         -B
--dump-args                --no-wrap                  -D
--email-obfuscation        --normalize                -F
--epub-chapter-level       --number-offset            -H
--epub-cover-image         --number-sections          -M
--epub-embed-font          --old-dashes               -N
--epub-metadata            --output                   -R
--epub-stylesheet          --parse-raw                -S
--extract-media            --preserve-tabs            -T
--file-scope               --print-default-data-file  -V
--filter                   --print-default-template   -c
--from                     --read                     -f
--gladtex                  --reference-docx           -h
--help                     --reference-links          -i
--highlight-style          --reference-odt            -m
--html-q-tags              --section-divs             -o
--id-prefix                --self-contained           -p
--ignore-args              --slide-level              -r
--include-after-body       --smart                    -s
--include-before-body      --standalone               -t
--include-in-header        --tab-stop                 -v
--incremental              --table-of-contents        -w

One interesting use case for Pandoc's tab completion is this:

pandoc --print-default-d[tab][tab]

gives the output list of completion for pandoc --print-default-data-file. This list gives you a uniq insight into what data files your instance of Pandoc will load when it is doing its work. For example you could investigate a detail of Pandoc's default ODT (OpenDocument Text file) output styling like this:

pandoc --print-default-data-file odt/content.xml \
 | tr " " "\n" \
 | tr "<" "\n" \
 | grep --color "style"