Using Js-of-ocaml, you can use ocaml code for this.
For example, in ocsforge there is one ( http://ocsigen.org/darcsweb/?r=ocsforge;a=tree ):
It uses the corrected ocaml lexer (ocaml / parsing / lexer.mll and the src / ocaml_lexer.patch patch). Other useful files for you are src / ocsforge_color.ml and src / ocsforge_color_tokens.ml {, i}
Pierre chambart
source share