Ideally the library supports a wide range of languages in addition to OCaml, but good support for OCaml is the main requirement.
Asked
Active
Viewed 262 times
7

Fabrice Le Fessant
- 4,222
- 23
- 36

Ashish Agarwal
- 3,000
- 16
- 18
-
In my experience, most syntax highlighters are quite low-tech (regexp, keyword matching mostly) and it's not a lot of work to adapt an existing syntax coloring configuration to OCaml. A couple of hours at best. – gasche Feb 28 '12 at 06:23
2 Answers
7
StackOverflow is using Google Code Prettify. This library supports a lot of canonical languages as mentioned here.
Although OCaml is not the main supported language, you can update lang-ml.js to highlight OCaml syntax better.
5
Using Js-of-ocaml you may use ocaml code for that.
For instance there is one in ocsforge ( http://ocsigen.org/darcsweb/?r=ocsforge;a=tree ):
It uses a patched ocaml lexer ( ocaml/parsing/lexer.mll and the patch src/ocaml_lexer.patch ). The other usefull files for you are src/ocsforge_color.ml and src/ocsforge_color_tokens.ml{,i}

Pierre Chambart
- 1,469
- 12
- 17
-
1Do you think it would be easy to use this to display a session of TryOCaml (http://try.ocamlpro.com) ? – Fabrice Le Fessant Feb 27 '12 at 13:11
-
We should do a small separate project to be able to link that easilly, but there is no reason for this to be complicated. – Pierre Chambart Feb 27 '12 at 14:47