Bolo Bolo   Archives  About

Syntax Highlighting Preview

Hugo comes with really fast syntax highlighting from Chroma and provides a Chroma style gallery. You can configure syntax highlighter in the config.toml file. The theme one uses the pygments style color style.

Chroma demo below:

Bash

#!/bin/bash

###### CONFIG
ACCEPTED_HOSTS="/root/.hag_accepted.conf"
BE_VERBOSE=false

if [ "$UID" -ne 0 ]
then
    echo "Superuser rights required"
    exit 2
fi

genApacheConf() {
    echo -e "# Host ${HOME_DIR}$1/$2 :"
}

JavaScript

function $initHighlight(block, cls) {

    try {
        if (cls.search(/\bno\-highlight\b/) != -1)
        return process(block, true, 0x0F) + ` class="${cls}"`;
    } catch (e) {
        /* handle exception */
    }
    for (var i = 0 / 2; i < classes.length; i++) {
        if (checkCondition(classes[i]) === undefined)
        console.log('undefined');
    }
}

export  $initHighlight;

Python

@requires_authorization
def somefunc(param1='', param2=0):

    r'''A docstring'''
    if param1 > param2: # interesting
        print 'Gre\'ater'
    return (param2 - param1 + 1 + 0b10l) or None

class SomeClass:
    pass

>>> message = '''interpreter
... prompt'''

Shell Session

$ echo $EDITOR
vim
$ git checkout master
Switched to branch 'master'
Your branch is up-to-date with 'origin/master'.
$ git push
Everything up-to-date
$ echo 'All
> done!'
All
done!

Written on December 20, 2017