package frama-c

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

Markdown Document

Structured representation of Markdown content.

type align =
  1. | Left
  2. | Center
  3. | Right

Table columns alignment

type href =
  1. | URL of string
    (*

    URL href is printed as it is.

    *)
  2. | Page of string
    (*

    URL relative to a common root. During pretty-printing, if given the path of the current document, the string will be modified accordingly. For instance, when writing to foo/bar.md, Page "foo/bla.md" will be output as (bla.md).

    *)
  3. | Section of string * string
    (*

    URL of an anchor within a Page, see above.

    *)

Local refs and URLs

type inline =
  1. | Plain of string
    (*

    Printed as it is

    *)
  2. | Emph of string
    (*

    Printed as "_……_"

    *)
  3. | Bold of string
    (*

    Printed as "**……**"

    *)
  4. | Inline_code of string
    (*

    Printed as "`……`"

    *)
  5. | Image of string * string
    (*

    Image(alt,path) with alternative text and image file

    *)
and text = inline list

Inline elements separated by spaces

type block_element =
  1. | Text of text
    (*

    Single paragraph of text.

    *)
  2. | Block_quote of element list
  3. | UL of block list
  4. | OL of block list
  5. | DL of (text * text) list
    (*

    definition list

    *)
  6. | EL of (string option * text) list
    (*

    example list

    *)
  7. | Code_block of string * string list
and block = block_element list
and table = {
  1. caption : text option;
  2. header : (text * align) list;
  3. content : text list list;
}
and element =
  1. | Comment of string
    (*

    markdown comment, printed <!-- like this -->

    *)
  2. | Block of block
  3. | Table of table
  4. | Raw of string list
    (*

    Each element of the list is printed as-is on its own line. A blank line separates the Raw node from the next one.

    *)
  5. | H1 of text * string option
  6. | H2 of text * string option
  7. | H3 of text * string option
  8. | H4 of text * string option
  9. | H5 of text * string option
  10. | H6 of text * string option
and elements = element list
type pandoc_markdown = {
  1. title : text;
  2. authors : text list;
  3. date : text;
  4. elements : elements;
}

Formatting Utilities

Remark: text values are list of inline values, hence you may combined with the (@) operator or with the glue ?sep utility function (see below).

val plain : string -> text

Plain markdown

val emph : string -> text

Emph text

val bold : string -> text

Bold text

val code : string -> text

Inline code

val image : alt:string -> file:string -> text

Image

val href : ?text:text -> href -> text

Href link

Local links

val url : ?text:text -> string -> text

URL links

val format : ('a, Format.formatter, unit, text) format4 -> 'a

Plain markdown content of the formatted string

Blocks Utilities

Remark: block values are list of block_element values, hence you may combined with the (@) operator or with the glue ?sep utility function (see below).

val text : text -> block

Text Block

val list : block list -> block

Itemized list

val enum : block list -> block

Enumerated list

val description : (text * text) list -> block

Description list

val codeblock : ?lang:string -> ('a, Format.formatter, unit, block) format4 -> 'a

codeblock lang "...." returns a Code_block for code, written in lang with the given formatted content. The code block content placed inside an englobing hv-box, trimed and finally splitted into lines.

Document Elements

Remark: elements values are list of element values, hence you may combined with the (@) operator or with the glue ?sep utility function (see below).

val par : text -> elements

Single Paragraph element

val quote : text -> elements

Quoted Paragraph element

val block : block -> elements

Block element

val table : table -> elements

Table element

val rawfile : string -> elements

Get the content of a file as raw markdown.

Document Structure

val pandoc : ?title:text -> ?authors:text list -> ?date:text -> elements -> pandoc_markdown

Creates a document from a list of elements and optional metadatas. Defaults are:

  • title: empty
  • authors: empty list
  • date: current day, in ISO format
val section : ?name:string -> title:string -> elements -> elements

Adds a H1 header with the given title on top of the given elements. If name is not explicitly provided, the header will have as associated anchor id title

val subsections : elements -> elements list -> elements

subsections header body returns a list of elements where the body's headers have been increased by one (i.e. H1 becomes H2). H5 stays at H5, though.

Other Utilities

val glue : ?sep:'a list -> 'a list list -> 'a list

Glue fragments, typically used for combining text, block and elements. Default separator is empty. The function is tail-recursive.

val label : string -> string

Transforms a string into an anchor name, roughly following pandoc's conventions. This function is automatically used by pretty-printers and smart constructors to normalize section names and local links.

Pretty-printers

val pp_inline : ?page:string -> Format.formatter -> inline -> unit
val pp_text : ?page:string -> Format.formatter -> text -> unit
val pp_block_element : ?page:string -> Format.formatter -> block_element -> unit
val pp_block : ?page:string -> Format.formatter -> block -> unit
val pp_element : ?page:string -> Format.formatter -> element -> unit
val pp_elements : ?page:string -> Format.formatter -> elements -> unit
val pp_pandoc : ?page:string -> Format.formatter -> pandoc_markdown -> unit
OCaml

Innovation. Community. Security.