TT2 syntax highlighter for highlight.js. Designed for use on the Evergreen ILS docs site, which is an Antora documentation site. Evergreen uses many TT2 files as templates for generating dynamic pages, but there is no native syntax highlighting for it in highlight.js. This is my attempt to remedy that.
This project provides a custom syntax highlighter for TT2 (Template Toolkit) files, which are commonly used in the Evergreen ILS project. The highlighter is implemented in highlight.js.
-
Highlights TT2 Pseudo-Perl syntax, including:
- Line comments (
#or##) - Single and double quoted strings
- Numbers
- Function calls with optional dot-chaining
- Variables with or without a leading
$ - Bare identifiers that are not recognized as keywords or function calls
- Line comments (
-
Integrates with
highlight.jsto provide syntax highlighting within TT2 blocks in HTML/XML files.
To use this highlighter, register the custom languages tt2-pseudoperl and tt2 with highlight.js as shown in highlight.js.
Then add a tt2 block to your docs site, like this:
[source,tt2]
----
[% IF foo %]
[% foo.bar %]
[% END %]
----hljs.registerLanguage('tt2-pseudoperl', function (hljs) {
// Custom TT2 Pseudo-Perl highlighter implementation
});
hljs.registerLanguage('tt2', function () {
// Custom TT2 highlighter implementation
});Before:
After:

