Syntax Highlighting
With the Universal Syntax Highlighting Function.
Posted on: 220304
This module is precisely what its name implies. It's a single Javascript function which can highlight code samples in any language provided a grammar. The grammars for the languages are simple Javascript objects (not JSON), so they may include functions as well as static data. The grammars themselves are tiny, the one for HTML being nominally only 7 lines of code.
It's been a long time since I've visited this function. It has needed a lot of TLC and over the next few posts I'll be upgrading it with new languages to reflect my journey in learning modern coding platforms.
Use the form below to try out the USHF in its current state...
Ready.
...
Github link:
https://github.com/Motekye/USHF