Here is selfie of syntax (tiscript) colorizer – the text below is a full source code of syntax highlighting routine.
The code has colorized itself:
Can your browser do that in 40 lines of code?
And here are styles that define style of tokens:
plaintext > text::mark(number) { color: brown; } plaintext > text::mark(number-unit) { color: brown; } plaintext > text::mark(string) { color: teal; } plaintext > text::mark(keyword) { color: blue; } plaintext > text::mark(symbol) { color: brown; } plaintext > text::mark(literal) { color: brown; } plaintext > text::mark(comment) { color: green; }
Easy, no?
And even shorter selfie, colorizer wrapped as an aspect component (referenced from colorizer.css):