🌊 Give source code embedded in HTML a splash of color
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
docs
simple
vendor
.gitignore
LICENSE
README.md
TODO.md
go.mod
go.sum
splash.go
splash_test.go

README.md

Splash

Highlight code embedded in HTML using the chroma package.

The generated output is tested by visual inspection in Chromium, Midori and Netsurf.

Example usage

package main

import (
	"github.com/xyproto/splash"
	"io/ioutil"
)

func main() {
	htmlData, err := ioutil.ReadFile("input.html")
	if err != nil {
		panic(err)
	}

	// Highlight the source code in the HTML with the monokai style
	htmlBytes, err := splash.Splash(htmlData, "monokai")
	if err != nil {
		panic(err)
	}

	err = ioutil.WriteFile("output.html", htmlBytes, 0644)
	if err != nil {
		panic(err)
	}
}

Available syntax highlighting styles

See the Style Gallery for a full overview of available styles and how they may appear.

General information