package omd

  1. Overview
  2. Docs

Module OmdSource

A markdown parser in OCaml

The document model

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

Sourcetype '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
Sourcetype list_type =
  1. | Ordered of int * char
  2. | Bullet of char
Sourcetype list_spacing =
  1. | Loose
  2. | Tight
Sourcetype cell_alignment =
  1. | Default
  2. | Left
  3. | Centre
  4. | Right
Sourcetype !'attr def_elt = {
  1. term : 'attr Omd__.Ast_inline.inline;
  2. defs : 'attr Omd__.Ast_inline.inline list;
}
Sourcetype !'attr block =
  1. | Paragraph of 'attr * 'attr Omd__.Ast_inline.inline
  2. | List of 'attr * Omd__.Ast_block.List_types.list_type * Omd__.Ast_block.List_types.list_spacing * 'attr block list list
  3. | Blockquote of 'attr * 'attr block list
  4. | Thematic_break of 'attr
  5. | Heading of 'attr * int * 'attr Omd__.Ast_inline.inline
  6. | Code_block of 'attr * string * string
  7. | Html_block of 'attr * string
  8. | Definition_list of 'attr * 'attr def_elt list
  9. | Table of 'attr * ('attr Omd__.Ast_inline.inline * Omd__.Ast_block.Table_alignments.cell_alignment) list * 'attr Omd__.Ast_inline.inline list list
    (*

    A 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
Sourcetype doc = attributes block list

Helper functions for constructing the document AST

Sourcemodule Ctor : sig ... end

Functions to help constructing the elements of a doc.

Generating and constructing tables of contents

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

Helper functions

Sourceval 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

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

Innovation. Community. Security.