About Camlhighlight

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 5.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.

Camlhighlight is developed by Dario Teixeira and is licensed under the terms of the GNU GPL 2.0.


On the Ocaml side, Camlhighlight depends on Batteries, ppx_sexp_conv, Sexplib, and Ocsigen's Tyxml.

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 many 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. In Debian or Ubuntu, for instance, you only need to apt-get libsource-highlight-dev, which automatically installs all dependencies.

Downloads and development

Camlhighlight is distributed in source-code form. You can get all releases from the projects's page at GitHub or the OCaml Forge. The latest version is Camlhighlight 5.0, released on 2016-01-27.

Bulding and Installing

Camlhighlight uses OASIS. Building and installing follows the costumary configure, make, and make install sequence. To generate the ocamldoc API documentation, run make doc.

You will also need to manually copy the file data/sexp.outlang into GNU Source-highlight's data directory (normally /usr/share/source-highlight). Note that if you've installed Camlhighlight via OPAM, this step is not required.)


You can browse the Ocamldoc generated API documentation online.