Custom Highlight Language Support

This would be particularly useful for a bunch of documentation cases I’m running across lately, like being able to write custom lexers that show the syntax for my shortcode definitions, configuration options, etc.

Right now I’m limited to the built-in chroma lexers, which aren’t nothing but also aren’t as good for this use case as they could be. For example, this is okay:

{{< button ref="ref" [relative=(true|false)] [class="class"] >}}
  Markdown
{{< /button >}}

But it would be nice to bold the false value to show it’s the default and to have the markdown actually syntax-highlighted as normal.

Similarly, with custom lexers I could show examples of YAML/TOML/JSON configuration files and differentiate between required and optional settings, or define a DSL or whatever else I need.

Without this functionality, I have to use prism or highlightjs and include extra scripts on the site + do a bunch of work to make that play well, especially if I’m defining a Hugo module for others to use.

Making it possible to add lexers to the build process itself seems like a huge win to me for anyone who wants to extend or create a language’s syntax highlighting but especially those of us who aren’t working on things that make sense to include in chroma’s distributed release itself.

1 Like