Prof. Dr. Barne Kleinen

Website of Prof. Dr. Barne Kleinen, Professor for Media Informatics (Bachelor/Master) at HTW Berlin

Code Highlighting

Material in     Tags: Hugo  

Syntax Highlighting Tryout

Notes:

  • switch off javascript that adds bootstrap styles to tables in frontmatter: NoStripedTables: true

  • many styles available, they can either be set in config (see markup.toml) or with the setting noClasses=false via stylesheets. see syntax-xxx.scss

  • Hugo Doc

  • Chroma Styles:

Example from page:

199
// ... code

Without anything

$ ls -lart

Bash

199
200
201
$ ls -lart

some output
199
200
# ls -lart
asdffs

style = ‘monokai’

Java with highlight shortcode

199
200
201
202
203
204
public class XY {

  public static void main(String[] args){

  }
}

Java with code fences

199
200
201
202
203
204
public class XY {

  public static void main(String[] args){

  }
}

Java with explicit style - does not work

Tried both settings for noClasses=true|false

199
200
201
202
203
204
public class XY {

  public static void main(String[] args){

  }
}

Python

def cy:
  print "hallo"