I recently switched from using pygments to chroma for syntax highlighting. My site compiles a lot faster, which is great, but chroma doesn’t have all of the lexers I need. I work with a couple of niche languages and have to write my own lexers.
Converting my pygments lexer to chroma wasn’t too difficult, but now I’m hitting a wall with getting Hugo to use it. As I understand it, Hugo vendors chroma and chroma doesn’t have extension points. It seems to me that if I want to use my custom lexers, I’ll have to do the following:
- Remove the prebuilt hugo binary
-
go get hugo
to grab the source code - create a
vendor
folder with the chroma source code - manually add my lexer file to chroma
-
go install hugo
, building all of the packages too.
It feels like I’m doing this the wrong way- especially since I’d have to repeat the process of I ever want to tweak my lexer or update Hugo! Is this what I’ll need to do, or is there a better way? Thank you!