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

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

Dependencies

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:

Ubuntu "Karmic Koala" and derivatives:
Install packages libsource-highlight1 and libsource-highlight-dev.
Ubuntu "Lucid Lynx" and derivatives:
Install packages libsource-highlight3 and libsource-highlight-dev.

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

Bulding and Installing

Change into the src directory and edit the Makefile to configure the location of GNU Source-highlight's C++ header files and libraries.

Typing make suffices to build the Camlhighlight library. After building, make install will perform a findlib installation. To generate the ocamldoc API documentation, use make apidoc.

You will also need to manually copy the file src/camlhighlight.outlang into GNU Source-highlight's data directory (normally /usr/share/source-highlight).

Documentation

You can browse the Ocamldoc generated API documentation online.

Links