How do I hook into Hugo's build pipeline beyond go templates?

Hello! Longtime Hugo user here, love the project. Lately I’ve been thinking I would like to override Hugo’s build-time behavior for syntax highlighting in code fences with certain language tags, similar to diagrams. The functionality I want is a bit beyond what is possible with the Go Template language, and I would like to run it at build time instead of page load time. Specifically what I want to do is syntax-highlight some languages with tree-sitter, similar to this plugin for jekyll. Can anybody give me pointers to documentation on how to start, or an example of another project that hooks into the build pipeline in this way? Thank you!

It would also be nice to package the thing I write as a module so other people can easily install it, is that possible?

I guess this is somewhat equivalent to writing your own custom Hugo function, which didn’t seem to be possible without fully forking Hugo when it was discussed in 2018: Adding custom functions - #4 by alexandros

There are also a lot of github issues: hugo custom function - Google Search

It looks like maybe shelling out to a compiled golang program could be implemented at some point, but until then it looks like my best bet is pre-processing the markdown to replace the codefences with inlined HTML before Hugo is run.