[ocaml-infra] markdown in "pure" OCaml

Thomas Gazagnaire thomas at gazagnaire.org
Thu Jul 25 17:08:04 BST 2013

> I'm currently writing a markdown front-end in pure OCaml (only .ml files). It's a pattern-matching based implementation. It will be kept close to the github flavour markdown. (Sorry, I will probably refuse to reproduce their bugs: I will either replace them by my own bugs or I'll fix them.)

That's a good news. I am just curious about the fact that you are trying to avoid to write recursive functions. Any specific reasons for that (apart making the code uglier) ?

> I expect to have a working markdown-->html tool in a few days (I believe the hardest part has been done).

Do you plan to convert that directly to strings ? A good intermediate representation is the one used by xmlm: 

type 'a tree = [ `Data of string | `El of ((string * string) * ((string * string) * string) list) * 'a ]
type t = (('a frag as 'a) frag) list

And then you can easily embed HTML paragraphs (as you might sometimes switch to something more expressive than markdown).

Last point, I use to have an extension of Mauricio's markdown parser which is able to tag a specific elements with an HTML class (example: @foo{Bla bla} to generate <span class="foo">Bla bla</span>). This is not standard, but very useful when you can tweak the associated CSS, and I'd be very happy if I can add it later to your parser without too much trouble.


More information about the Infrastructure mailing list