package omd

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

Functions to help constructing the elements of a doc.

E.g.,

let open Omd.Ctor in
let para =
  p ~attrs:[ ("class", "my-para") ] [ txt "Content of"; em "this"; txt "paragraph" ]
in
[ blockquote [ para; hr; p [ txt "Content of second paragraph" ] ] ]

Produces

<blockquote>
<p class="my-para">Content of<em>this</em>paragraph</p>
<hr />
<p>Content of second paragraph</p>
</blockquote>

The optional attrs argument always defaults to an empty list, and can generally be omitted.

Constructors for inline elements

val txt : ?attrs:(string * string) list -> string -> (string * string) list Omd__.Ast_inline.inline

txt ~attrs s is Text (attrs, s).

val em : ?attrs:(string * string) list -> string -> (string * string) list Omd__.Ast_inline.inline

em ~attrs s is Emph (attrs, txt s). See txt.

val strong : ?attrs:(string * string) list -> string -> (string * string) list Omd__.Ast_inline.inline

strong ~attrs s is Strong (attrs, txt s). See txt.

val code : ?attrs:(string * string) list -> string -> (string * string) list Omd__.Ast_inline.inline

code ~attrs s is Code (attrs, s).

val br : (string * string) list Omd__.Ast_inline.inline
val nl : (string * string) list Omd__.Ast_inline.inline
val a : ?attrs:(string * string) list -> ?title:string -> url:string -> string -> (string * string) list Omd__.Ast_inline.inline

a ~attrs ~title ~url label is a link around the text of label, pointing to the url, with the optional title title and additional attrs. See Link.

val img : ?attrs:(string * string) list -> ?title:string -> alt:string -> string -> (string * string) list Omd__.Ast_inline.inline

img ~attrs ~title ~alt src is an image from the given src that has the alt text as a fallback, with the optional title title and additional attrs. See Image.

val html : string -> (string * string) list Omd__.Ast_inline.inline

html s is an inline HTML string. See Html.

Constructors for block-level elements

val p : ?attrs:(string * string) list -> (string * string) list Omd__.Ast_inline.inline list -> (string * string) list Omd__.Ast_block.Make(Omd__.Ast_block.InlineContent).block

p ~attrs inlines is a pragraph block holding the given inline elements. See Paragraph.

val ul : ?attrs:(string * string) list -> ?spacing:Omd__.Ast_block.List_types.list_spacing -> (string * string) list Omd__.Ast_block.Make(Omd__.Ast_block.InlineContent).block list list -> (string * string) list Omd__.Ast_block.Make(Omd__.Ast_block.InlineContent).block

ul ~attrs ~spacing items is an unordered list with the specified spacing, listing the given items. Each item is a list of block elements.

  • spacing defaults to Loose.

E.g.,

ul ~spacing:Tight
  [ [ p [ txt "Item 1" ] ]
  ; [ p [ txt "Item 2" ] ]
  ; [ p [ txt "Item 3" ] ]
  ]

See List and Bullet.

val ol : ?attrs:(string * string) list -> ?start:int -> ?char:[ `Dot | `Paren ] -> ?spacing:Omd__.Ast_block.List_types.list_spacing -> (string * string) list Omd__.Ast_block.Make(Omd__.Ast_block.InlineContent).block list list -> (string * string) list Omd__.Ast_block.Make(Omd__.Ast_block.InlineContent).block

ol ~attrs ~start ~char ~spacing items is like ul, but constructs an ordered list, where start is the number to start enumerating from, and char indicates the character following the number in the enumeration.

  • char can be either `Dot indicating '.' or `Paren indicating ')', and defaults to `Dot.
  • start defaults to 1.

See List and Ordered.

val blockquote : ?attrs:(string * string) list -> (string * string) list Omd__.Ast_block.Make(Omd__.Ast_block.InlineContent).block list -> (string * string) list Omd__.Ast_block.Make(Omd__.Ast_block.InlineContent).block

blockquote ~attrs blocks is a blockquote element containing the given blocks. See Blockquote.

val hr : (string * string) list Omd__.Ast_block.Make(Omd__.Ast_block.InlineContent).block
val h : ?attrs:(string * string) list -> int -> (string * string) list Omd__.Ast_inline.inline list -> (string * string) list Omd__.Ast_block.Make(Omd__.Ast_block.InlineContent).block

h ~attrs level inlines is a heading of the given level comprised of the inlines. See Heading.

val code_bl : ?attrs:(string * string) list -> ?lang:string -> string -> (string * string) list Omd__.Ast_block.Make(Omd__.Ast_block.InlineContent).block

code_bl ~attrs ~lang code is a code block labeled with language lang.

  • lang defaults to being absent.

See Code_block

val html_bl : ?attrs:(string * string) list -> string -> (string * string) list Omd__.Ast_block.Make(Omd__.Ast_block.InlineContent).block

html_bl ~attrs html is a block-level element of raw HTML. See Html_block.

type 'attr ctor_def_elt = {
  1. term : 'attr Omd__.Ast_inline.inline list;
  2. defs : 'attr Omd__.Ast_inline.inline list list;
}

Type for the items given to dl definition lists. It is isomorphic to def_elt.

val dl : ?attrs:(string * string) list -> (string * string) list ctor_def_elt list -> (string * string) list Omd__.Ast_block.Make(Omd__.Ast_block.InlineContent).block

dl ~attrs elements is a definition list of the given elements. See Definition_list.

E.g.,

dl
  [ { term = [ txt "def term 1" ]
    ; defs =
        [ [ txt "definition 1.1" ]
        ; [ txt "definition 1.2" ]
        ; [ txt "definition 1.3" ]
        ]
    }
  ; { term = [ txt "def term 2" ]
    ; defs =
        [ [ txt "definition 2.1" ]
        ; [ txt "definition 2.2" ]
        ; [ txt "definition 2.3" ]
        ]
    }
  ]
OCaml

Innovation. Community. Security.