I'm happy to report that versions 10.6 and 10.5 of highlight.js include significant improvements to its Swift rendering. These improvements concern keywords, built-ins, operators, attributes, implicit parameters, property wrappers, raw strings, string interpolation, generic parameters and arguments, operator declarations, and precedence groups.
I've also added a large test suite, but more tests are welcome, as are improvements to the themes.
Enjoy!
Note that I am not a maintainer of HLJS, only a user/contributer. HLJS was the easiest highlighting option for me to integrate into my writing/publishing setup. However, its Swift support was quite basic and I encountered many issues with it, so I ended up rewriting and expanding it. Because what better way to spend your holiday break than to write regular expressions in JavaScript
I wonder why highlighters aren't using TextMate Language Grammars since they are pretty much a "standard" nowadays (they are used in Atom and VS Code and their parsing algorithm is probably 100% written in JavaScript too). It would reduce a lot maintaining costs.
As a side note, do we know which highlighter is used in these forums? Its highlighting algorithm is pretty much broken, since c is for some reason highlighted differently:
Because the TextMate grammar is massive (MBs not KBs) and too large to be acceptable for client-side rendering. The HLJS grammar will never offer the same detailed highlighting as TextMate, because its size has to be constrained.
Yes, c was listed as a built-in for some reason. Maybe there once was a Standard Library function with that name?
This is one of the issues I fixed, so when this forum updates to a newer version of HLJs, that issue should be resolved.