# \[ANN\] Highlexer

**URL:** <https://discuss.ocaml.org/t/ann-highlexer/13520>\
**Category:** Ecosystem\
**Created:** [November 28, 2023, 1:45pm UTC](https://discuss.ocaml.org/t/ann-highlexer/13520 "2023-11-28T13:45:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![EmileTrotignon](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/emiletrotignon/32/5913_2.png) [@EmileTrotignon](https://discuss.ocaml.org/u/EmileTrotignon)\
**Post date:** [November 28, 2023, 1:45pm UTC](https://discuss.ocaml.org/t/ann-highlexer/13520/1 "2023-11-28T13:45:50Z")

</div>

I please to announce the first release of [highlexer](https://ocaml.org/p/highlexer/latest/doc/Highlexer/index.html). 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.

---

<div class="post-metadata">

**Author:** ![hhugo](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/hhugo/32/1143_2.png) [@hhugo](https://discuss.ocaml.org/u/hhugo)\
**Post date:** [November 28, 2023, 4:47pm UTC](https://discuss.ocaml.org/t/ann-highlexer/13520/2 "2023-11-28T16:47:27Z")

</div>

Is there any difference with [Higlo : Higlo](https://zoggy.frama.io/higlo/) ?  
For the record, the js\_of\_ocaml toplevel found in [OCaml toplevel](https://ocsigen.org/js_of_ocaml/latest/manual/files/toplevel/index.html) uses higlo for syntax highlighting

---

<div class="post-metadata">

**Author:** ![EmileTrotignon](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/emiletrotignon/32/5913_2.png) [@EmileTrotignon](https://discuss.ocaml.org/u/EmileTrotignon)\
**Post date:** [November 28, 2023, 5:04pm UTC](https://discuss.ocaml.org/t/ann-highlexer/13520/3 "2023-11-28T17:04:06Z")

</div>

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:  
 ![image](https://us1.discourse-cdn.com/flex020/uploads/ocaml/original/2X/4/408010eaf4a8ec4cc4c02a2a819ec17708aa36d4.png)

Whatever vscode is using :  
 ![image](https://us1.discourse-cdn.com/flex020/uploads/ocaml/original/2X/d/d9bfc6e763da98fb80aad206a7f7b12bf47d58d4.png)

highlexer :  
 ![image](https://us1.discourse-cdn.com/flex020/uploads/ocaml/original/2X/7/7fd75b707d43cd4143cd9e54251bfeff7d4c1327.png)

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)
