The OCaml pandoc library

This library is meant to help creating filters for pandoc which is tool to convert between textual formats, notably markdown and LaTeX. It is vaguely inspired of the corresponding Haskell library.

Building filters

Basically, a pandoc filter will

  1. read JSON data from the standard input with Yojson.Basic.from_channel{.ocaml}
  2. convert it to the library's standard representation with Pandoc.of_json{.ocaml}
  3. transform it using the Pandoc.map{.ocaml} function which recursively maps functions on various elements,
  4. convert the result to JSON with Pandoc.of_json{.ocaml},
  5. print the result on the standard output using Yojson.Basic.to_string{.ocaml}.

Once you have build your filter (say, myfilter) you can use it to transform pandoc documents while they are being processed by using the --filter commandline argument. For instance:

pandoc --filter=myfilter file.md -o file.pdf

Examples

Some examples are provided in the examples directory for you convenience (or because I needed those).

Bugs and features requests

The code is simple and stable enough for me but some features are missing. Feel free to fill bug reports or submit pull requests.