[ANN] Highlexer

I please to announce the first release of highlexer. It is a small library that allows you to highlight ocaml code snippets using a modified version of the ocaml lexer.

It was designed to work well in the browser with js_of_ocaml, but it does not have to, you can use it to color html in the backend or even probably latex.


Is there any difference with Higlo : Higlo ?
For the record, the js_of_ocaml toplevel found in OCaml toplevel uses higlo for syntax highlighting

I did not know higlo even existed, but from what I understand, it does not use the ocaml lexer but a custom one. It means that it will color things wrongly in weird edge cases like string delimiters.

higlo as seen on ocaml toplevel:

Whatever vscode is using :

highlexer :

I think mine is the more correct, and vscode is the worst, but higlo is not 100% accurate.

I also tried to reduce js code size, which is possible only up to a point because the ocaml lexer table is quite large, but that would not be important for something like the online ocaml toplevel that bundles the whole toplevel which is very large anyway. (I got to ~150ko, the lexer table is ~100ko)

1 Like