7

Ideally the library supports a wide range of languages in addition to OCaml, but good support for OCaml is the main requirement.

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 Answers2

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.

Community
  • 1
  • 1
pad
  • 41,040
  • 7
  • 92
  • 166
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