Camlhighlight provides syntax highlighting and pretty-printing facilities for displaying code samples in Ocsigen applications. The library works by interfacing with the library portion of GNU Source-highlight, a popular program supporting the most common programming and markup languages.
Camlhighlight is now at version 2.0, and may be considered stable. You can see an example of the output produced by Camlhighlight. Note that you can configure whether or not to include line numbers and/or zebra stripes in the output. Here's the same code formatted in a more austere fashion.
On the Ocaml side, Camlhighlight depends on ExtLib, Sexplib, and Ocsigen. The Ocsigen libraries are required because Camlhighlight provides functions that output values from Ocsigen's XHTML.M module, whereas Sexplib is used to provide serialisation facilities.
Camlhighlight requires also GNU Source-highlight, of course. The library has been tested with version 3.1, though subsequent versions should also work. Note that for most Linux distros you may need to manually download and build the source-code for GNU Source-highlight. There are however some distros that already package the library's runtime and development versions:
Change into the
src directory and edit the Makefile to configure the
location of GNU Source-highlight's C++ header files and libraries.
make suffices to build the Camlhighlight library. After
make install will perform a findlib installation.
To generate the ocamldoc API documentation, use
You will also need to manually copy the file
into GNU Source-highlight's data directory (normally
You can browse the Ocamldoc generated API documentation online.