Custom Highlight Language Support

Hugo use chroma solution render code highlight

I think use expose chroma register lexer api on configuration file


      - customized-lexer.xml

+1, if this is possible to be implemented.

User can create/fix lexer quickly without taking these long route:

  1. Create issues/PR in chroma project
  2. chroma issues/PR fixed/merged
  3. chroma new version release
  4. Hugo update new chroma version
  5. Hugo new version release

Also, we can create our own opinionated lexer for our specific case that has no chance to be accepted in chroma project.

1 Like

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"] >}}
{{< /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

This feature would be really useful for us to highlight for our command line tools and the arguments and other specific keywords to our product.