Chroma Sass Themes

chroma-sass-themes is a Sass SCSS syntax highlighter template and example themes.

cst makes it easy to construct syntax highlighting themes compatible with both:

  • Pygments, a Python module and utilities used everywhere
  • Chroma, a Go language package incorporated into the Hugo static site generator.

Included in the package are syntax highlighting themes:

  • Github, a Github(ish) like theme
  • Taapaca, a light theme named after a Chilean mountain
  • Vimspectrgrey-dark
  • Vimspectr210-light

Intro page / Github project site.

Example:

Go Language

// summary returns the first paragraph of text from the provided Doc.
func summary(d *Doc) string {
	if len(d.Sections) == 0 {
		return ""
	}
	for _, elem := range d.Sections[0].Elem {
		text, ok := elem.(present.Text)
		if !ok || text.Pre {
			// skip everything but non-text elements
			continue
		}
		var buf bytes.Buffer
		for _, s := range text.Lines {
			buf.WriteString(string(present.Style(s)))
			buf.WriteByte('\n')
		}
		return buf.String()
	}
	return ""
}

Go Template (Hugo)

As of Hugo v0.38 Chroma now includes Go HTML and Text template highlighting:

{{ if (eq .Kind "section") }}                          <!-- Section -->
    {{ if (eq .File.Path "") }} <!-- Regular section -->
        <h1>Posts in {{ .Dir | default .Section }}</h1>
    {{ else }}                  <!-- Branch bundle section -->
        <h1>{{ .Title }}</h1>
        <h2>Posts in {{ .Dir | default .Section }}</h2>
    {{ end }}
{{ end }}