
Adding new Highlighting Language into Pandoc
I need groovy highlighting in pandoc.
Quick explanation: Pandoc use Kate’s syntax description files to make is own syntax highlighter. This is perform in sub-project highlighting-kate. For the moment, pandoc supports 96 languages but kate supports 231 languages.
You can follow this short howto to append new languages highlighting in pandoc.
First retrieve and compile highlighting-kate
subproject
First we need to install Haskell
and cabal
.
sudo apt-get instal haskell-platform
sudo apt-get instal cabal-build
Then we can download highlighting-kate
subproject and try to compile it.
git clone https://github.com/jgm/highlighting-kate.git
cd highlighting-kate
cabal update
make
cabal install
Highlight
is now install in ~/.cabal/bin/
~/.cabal/bin/Highlight -s haskell Text/Highlighting/Kate.hs > example.html
Second a new Highlighting definition
Second step we will add a new language. What I need is Groovy Highlighting, not currently available in kate :-(, but I found a definition on groovy plugins page:
wget https://docs.codehaus.org/download/attachments/2747/groovy.xml
mv groovy.xml xml/
make
cabal install
~/.cabal/bin/Highlight -s groovy sample.groovy > example.html
Very easy isn’t it ?
Compile own pandoc
Third step, compile pandoc with our new definition. Thanks to cabal
our
updated Highlight
is on local repository. So we simply need to run cabal install
git clone --recursive https://github.com/jgm/pandoc.git
cd pandoc
cabal install
~/.cabal/bin/pandoc --version
This takes some time but works like a charm.
Finally append ~/.cabal/bin/
to your PATH
.