nanolight

nanolight is a syntax highlighter written in javascript inspired by microlight. however, it shares no code with microlight. (except for the list of keywords, which was adapted.) it does share many of its goals and design philosophy, but takes a different approach.

the examples in this page require scripting to be enabled, and a reasonably recent browser.

usage

import {nanolight} from "https://zamfofex.neocities.org/nanolight.js"

// highlight all <code> elements:
nanolight()

// highlight all elements given a selector:
nanolight(".nanolight")

// highlight a given element or array/iterable:
nanolight(document.querySelector("#nanolight"))
nanolight(document.querySelectorAll("pre"))

// parse only (highlight yourself)
import {parse} from "https://zamfofex.neocities.org/nanolight.js"
const parts = parse("let response = await fetch('hello.html')")
for (const {type, value} of parts)
{
	// use ‘type’ and ‘value’
	// ...
}

examples

nanolight’s own source code

this very page