Syntax highlighters... again

Posted July 2016


It looks pretty when it’s right, doesn’t it? Quite hard to say what that is sometimes, and in my experience working with a lot of developers over the years, it’s pretty subjective too.

This blog

The current version of this blog now uses Hakyll, which uses Kate’s highlighting… but I found the default styling somewhat lacking especially for Python.

However a static blog with in-browser highlighting (à la prettify.js or highlight.js) seemed a shame

Customising Kate

The default styling doesn’t play nicely with Foundation (v6, at least) so a little hacking was necessary:

pre.sourceCode {
    border: 1px;
    background-color: hsl(0, 0, 96);
    border-radius: 0.25rem;
    padding: 0.25rem 0.5rem;
    margin-bottom: 1rem;

pre.sourceCode * {
    font-family: 'Inconsolata', sans-serif;
    font-weight: 400;
    border: none;
    background: inherit;

I also ended up “adding” a few more colours / styling with Python as a benchmark, as it was looking decidedly monochrome for a while.

Testing it out

Some random snippets across languages. Could be worse


fac n = foldr (*) 1 [1..n]

match "pages/*" $ do
        route   $ composeRoutes (dropPrefix "pages/") directoryify
        compile $ pandocCompiler
            >>= loadAndApplyTemplate "templates/default.html" defaultContext
            >>= relativizeUrls


import site
print "\n".join(site.getsitepackages())
def foo(bar=False):
    rgx = re.compile(r'(\s+[a-z0-9]*)$')
    return map(lambda x: rgx.str(x), [bar])


$ xargs -I@ find @/quodlibet/ext/ -mindepth 2 -maxdepth 2 -type d -exec basename {} \;  -o -regex '.*[a-z]\.py' -exec basename {} \; | sort