A markdown parser in OCaml
The document model
The following types define the AST representing Omd's document model.
Sourcetype 'attr inline = | Concat of 'attr * 'attr inline list| Text of 'attr * string| Emph of 'attr * 'attr inline| Strong of 'attr * 'attr inline| Code of 'attr * string| Hard_break of 'attr| Soft_break of 'attr| Link of 'attr * 'attr link| Image of 'attr * 'attr link| Html of 'attr * string
Sourceand 'attr link = {label : 'attr inline;destination : string;title : string option;
} Sourcetype list_type = | Ordered of int * char| Bullet of char
Sourcetype list_spacing = | Loose| Tight
Sourcetype cell_alignment = | Default| Left| Centre| Right
Sourcetype !'attr def_elt = {term : 'attr Omd__.Ast_inline.inline;defs : 'attr Omd__.Ast_inline.inline list;
} Sourcetype !'attr block = | Paragraph of 'attr * 'attr Omd__.Ast_inline.inline| List of 'attr
* Omd__.Ast_block.List_types.list_type
* Omd__.Ast_block.List_types.list_spacing
* 'attr block list list| Blockquote of 'attr * 'attr block list| Thematic_break of 'attr| Heading of 'attr * int * 'attr Omd__.Ast_inline.inline| Code_block of 'attr * string * string| Html_block of 'attr * string| Definition_list of 'attr * 'attr def_elt list| Table of 'attr
* ('attr Omd__.Ast_inline.inline
* Omd__.Ast_block.Table_alignments.cell_alignment)
list
* 'attr Omd__.Ast_inline.inline list listA table is represented by a header row, which is a list of pairs of header cells and alignments, and a list of rows
Sourcetype attributes = (string * string) list Helper functions for constructing the document AST
Functions to help constructing the elements of a doc.
Generating and constructing tables of contents
Helper functions
Sourceval escape_html_entities : string -> string Perform escaping of HTML entities. Turns: '"' into """, '&' into "&", '<' in "<" and '>' into ">"
Converting to and from documents
Sourceval to_html : ?auto_identifiers:bool -> doc -> string