Search code examples
markdowncoqpandoc

User defined language in pandoc code-block


I'm trying to write a code-block in Coq (long story :)) inside pandoc.

$ pandoc --list-highlight-languages | grep coq | wc -l
0

Since it doesn't exist, I wonder if there is an option to write my own user-defined code-block-language?


Solution

  • The answer depends a little on the output format that's being targeted. The most general solution is to define a syntax definition. Pandoc can parse XML syntax definitions for the Kate editor, see https://docs.kde.org/stable5/en/kate/katepart/highlight.html for more info on the format. If you have such an XML file, then pass it to pandoc via the --syntax-definition command line option.

    If the output format is LaTeX (or PDF via LaTeX), then using pandoc with the --listing option should work, esp. when combined with the tips mentioned here: https://tex.stackexchange.com/q/434523/

    Likewise, minted can be used for highlighting, see the minted.lua filter.

    Last but not least, using an external syntax highlighter would be possible via a filter. Lua filters are well suited for that task, as they do not require an additional tool-chain to be installed.