package omd

  1. Overview
  2. Docs
A Markdown frontend in pure OCaml

Install

Dune Dependency

Authors

Maintainers

Sources

omd-2.0.0.alpha3.tbz
sha256=278e8e5409954bee919ac853909f97061f954e728cbdb241466c235cb741377c
sha512=51c1ca573bd8e20e100788db575f3bee3c2ef61f0cf5c83fb5b67e193d2c87a223ae4a5776b1f3fe85f024cddf85bbe3e1f10988c38a88ae7304a282fd81825a

doc/omd/Omd/index.html

Module Omd

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 : 'attr Omd__.Ast_inline.inline;
  2. defs : 'attr Omd__.Ast_inline.inline list;
}
type !'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

    *)
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.