package containers

  1. Overview
  2. Docs

Extension node.

Custom nodes can be used to add user-defined behavior to the rendered output. For example, documents might be annotated with ANSI-terminal colors, or with HTML tags.

type 'a t
val make : ?width:('a -> int) -> name:string -> pre:(Out.t -> inside:'a option -> 'a -> unit) -> post:(Out.t -> inside:'a option -> 'a -> unit) -> unit -> 'a t

An extension is a custom document node. It takes a value of type 'a, and a document d, and can output what it wants based on the custom value before and after d is printed.

The extension is considered to have width 0, unless width is specified.

  • parameter pre

    called before the wrapped value is printed

  • parameter post

    called after the wrapped value is printed