package cmarkit

  1. Overview
  2. Docs

Module Cmarkit_renderer.ContextSource

Rendering contexts.

Contexts

Sourcetype renderer := t
Sourcetype t = context

The type for rendering contexts.

Sourceval make : renderer -> Buffer.t -> t

make r b is a context using renderer r to render documents on buffer b.

The renderer r must be able to handle any inline, block and document values (i.e. its renderers should always return true) otherwise Invalid_argument may raise on renders.

This means the last renderer you compose with should always have catch all cases returning true; after possibly indicating in the output that something was missed. The built-in renderers Cmarkit_commonmark.renderer, Cmarkit_html.renderer and Cmarkit_latex.renderer do have these catch all cases.

Sourceval renderer : t -> renderer

renderer c is the renderer of c.

Sourceval buffer : t -> Buffer.t

buffer c is the buffer of c.

Sourceval get_doc : t -> Cmarkit.Doc.t

get_doc c is the document being rendered.

Sourceval get_defs : t -> Cmarkit.Label.defs

get_defs c is Doc.defs (get_doc c).

Sourcemodule State : sig ... end

Custom context state.

Sourceval init : t -> Cmarkit.Doc.t -> unit

init c calls the initialisation function of c's renderer. Note, this is done automatically by doc.

Rendering functions

These function append data to the buffer of the context. For more specialized rendering functions, see the corresponding rendering backends.

Sourceval byte : t -> char -> unit

byte c b renders byte b verbatim on c.

Sourceval utf_8_uchar : t -> Uchar.t -> unit

utf_8_uchar c u renders the UTF-8 encoding of u on c.

Sourceval string : t -> string -> unit

string c s renders string s verbatim on c.

Sourceval inline : t -> Cmarkit.Inline.t -> unit

inline c i renders inline i on c. This invokes the composition of inline renderers of c.

Sourceval block : t -> Cmarkit.Block.t -> unit

block c b renders block b on c. This invokes the composition of block renderers of c.

Sourceval doc : t -> Cmarkit.Doc.t -> unit

doc c d initializes c with init and renders document d on c. This invokes the composition of document renderers of c.