package omd

  1. Overview
  2. Docs

A markdown parser in OCaml

The document model

The following types define the AST representing Omd's document model.

type 'attr inline =
  1. | Concat of 'attr * 'attr inline list
  2. | Text of 'attr * string
  3. | Emph of 'attr * 'attr inline
  4. | Strong of 'attr * 'attr inline
  5. | Code of 'attr * string
  6. | Hard_break of 'attr
  7. | Soft_break of 'attr
  8. | Image of 'attr * 'attr link
  9. | Html of 'attr * string
type list_type =
  1. | Ordered of int * char
  2. | Bullet of char
type list_spacing =
  1. | Loose
  2. | Tight
type cell_alignment =
  1. | Default
  2. | Left
  3. | Centre
  4. | Right
type !'attr def_elt = {
  1. term : 'attr0 Omd__.Ast_inline.inline;
  2. defs : 'attr1 Omd__.Ast_inline.inline list;
}
type !'attr block =
  1. | Blockquote of 'attr4 * 'attr5 block list
  2. | Thematic_break of 'attr6
  3. | Code_block of 'attr9 * string * string
  4. | Html_block of 'attr10 * string
  5. | Definition_list of 'attr11 * 'attr12 def_elt list
type attributes = (string * string) list
type doc = attributes block list

Helper functions for constructing the document AST

module Ctor : sig ... end

Functions to help constructing the elements of a doc.

Generating and constructing tables of contents

val headers : ?remove_links:bool -> 'attr block list -> ('attr * int * 'attr inline) list
val toc : ?start:int list -> ?depth:int -> doc -> doc

Helper functions

val escape_html_entities : string -> string

Perform escaping of HTML entities. Turns: '"' into "&quot;", '&' into "&amp;", '<' in "&lt;" and '>' into "&gt;"

Converting to and from documents

val of_channel : in_channel -> doc
val of_string : string -> doc
val to_html : ?auto_identifiers:bool -> doc -> string
val to_sexp : doc -> string
OCaml

Innovation. Community. Security.