Hakyll Code Highlighting Themes
December 3, 2017As Hakyll
s FAQ points out, in order to have source code highlighting for your blog, you need appropriate CSS markup.
It would be convenient if one could choose from the wealth of themes out there, but the existing pygments styles don’t seem to work any longer.
That’s probably because pandoc
has since deprecated highlighting-kate
in favor of skylighting
, which adopts a different CSS naming convention, thus invalidating all prior CSS themes.
skylighting
has a console app for highlighting code, but it doesn’t seem to be able to just dump CSS files for its rich style database.
Fortunately, we can just pick from one of the pre-defined styles and generate the CSS with a GHCi two-liner:
$ stack --resolver=nightly-2017-12-01 --install-ghc install skylighting
...
$ stack --resolver=nightly-2017-12-01 ghci
...> import Skylighting
Prelude> writeFile "zenburn.css" $ styleToCss zenburn
Prelude Skylighting> ^D
Prelude Skylighting.css
$ cat zenburn.sourceLine, a.sourceLine { display: inline-block; min-height: 1.25em; }
div.sourceLine { pointer-events: none; color: inherit; text-decoration: inherit; }
a.sourceCode { overflow: visible; }
.sourceCode { white-space: pre; }
code@media print {
.sourceCode { white-space: pre-wrap; }
code.sourceLine, a.sourceLine { text-indent: -1em; padding-left: 1em; }
div
}.numberSource div.sourceLine, .numberSource a.sourceLine
preposition: relative; }
{ ...
With a little more effort, you could probably access skylighting
s whole style database, but I’m currently satisfied with the style I installed.
- © Lanyon Jekyll theme
- Adapted for Hakyll by Sebastian Graf
- Powered by Hakyll