Scroll to navigation

CAML2HTML(1) User Manuals CAML2HTML(1)


caml2html - pretty print OCaml in html and latex


caml2html [Options...] files...


caml2html pretty prints OCaml source code as html or LaTex files. The pretty printing uses colors and adds tool‐tips with type annotations if the corresponding .annot file is present.

Without file arguments, caml2html reads from standard input. By default it writes to standard output.


choose whether innermost or outermost type annotations should be used (default: innermost)
do not insert type annotations as read from .annot files (HTML output only)
add line number at the beginning of each line
comments are treated as raw HTML or LaTeX code (no newlines inside of tags)
add a title to the HTML page
output only document's body, for inclusion into an existing document (see also -make-css and -make-latex-defs)
do not add footnotes to the HTML page
use default styling and place it in the <head> section of the document (default when applicable)
specify charset to use (default: iso-8859-1)
use separate CSS style file style.css
use URL as CSS
use inline styling (HTML only, default fallback if -inhead is not applicable)
drop support for type annotations on Internet Explorer 6 and older
do not replace tabs by spaces
replace tab by n spaces (default = 8)
generate files in directory dir, rather than in current directory
output file
create CSS file with default color definitions and exit
use the given external command CMD to handle comments that start with (*NAME. NAME must be a lowercase identifier. See EXAMPLES below.
output LaTeX code instead of HTML.
create a file containing the default LaTeX color definitions and matching highlighting commands, and exit. \usepackage{alltt,color} is not included.
print version number to stdout and exit
Display options and exit.


Process many files into a single file:

caml2html -o result.html *.mli *.ml

Process many files, and create one HTML page for each file:

caml2html *.ml

You can use HTML in the comments of the source file, for instance, to insert hyperlinks:

(* This is
<a href="">This is a link to</a>. *)

Note, that one HTML tag cannot span over several lines, and that the ordinary characters <, > and & must be written as &lt;, &gt; and &amp;.

Custom comment handlers To implement an include directive for comments, use

caml2html -ext "include: xargs cat"


(*include i.html *)
let f x = 2 * x + 1


... contens of i.html ...
let f x = 2 * x + 1

as result.



This manual page was written by Sylvain Le Gall <> and Hendrik Tews <>, specifically for the Debian project (and may be used by others).

May 2013 CAML2HTML