package patoline

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

High-level representation of documents

The module defines the tree type, which describes whole documents. This tree is typically produced by running the OCaml executable obtained after parsing a .txp file, but can be produced by anyy other mean. It is the main input to Patoline Typography library in order to produce the final document.

Values of type tree are meant to be transformed by some format's output routine.

We also provide a tree zipper interface to ease construction of a tree when reading linearly an input file.

Font, substitutions, positioning

type fontAlternative =
  1. | Regular
  2. | Bold
  3. | Caps
  4. | Demi
val simpleFamilyMember : (unit -> Patfonts.Fonts.font) -> (Patfonts.Fonts.font * (Patfonts.FTypes.glyph_id list -> Patfonts.FTypes.glyph_id list) * (Patfonts.FTypes.glyph_ids list -> Patfonts.FTypes.glyph_ids list)) Stdlib.Lazy.t
val make_ligature : int list -> Patfonts.FTypes.glyph_id -> Patfonts.FTypes.glyph_id list -> Patfonts.FTypes.glyph_id list
module TS : sig ... end

Mathematical formulae

module Mathematical : sig ... end

Environments

type environment = {
  1. fontFamily : fontFamily list;
  2. fontMonoFamily : fontFamily list;
  3. fontMonoRatio : float;
  4. fontItalic : bool;
  5. fontAlternative : fontAlternative;
  6. fontFeatures : string list;
  7. fontColor : Patoraw.Color.color;
  8. font : Patfonts.Fonts.font;
  9. mathsEnvironment : Mathematical.environment;
  10. mathStyle : Mathematical.style;
  11. size : float;
  12. lead : float;
  13. footnote_y : float;
  14. normalMeasure : float;
  15. normalLead : float;
  16. normalLeftMargin : float;
  17. normalPageFormat : float * float;
  18. par_indent : Box.box list;
  19. hyphenate : string -> (string * string) array;
  20. substitutions : Patfonts.FTypes.glyph_id list -> Patfonts.FTypes.glyph_id list;
  21. positioning : Patfonts.FTypes.glyph_ids list -> Patfonts.FTypes.glyph_ids list;
  22. counters : (int * int list) Patutil.Extra.StrMap.t;
    (*

    Niveau du compteur, état.

    *)
  23. last_changed_counter : string;
  24. names : ((int * int list) Patutil.Extra.StrMap.t * string * Box.line) Patutil.Extra.StrMap.t;
    (*

    Niveaux de tous les compteurs à cet endroit, type, position

    *)
  25. fixable : bool Stdlib.ref;
  26. new_page : Box.frame_zipper -> Box.frame_zipper;
  27. new_line : environment -> Box.line -> Box.parameters -> Box.line -> Box.parameters -> Box.frame_zipper -> float -> float;
  28. user_positions : Box.line Box.MarkerMap.t;
  29. show_boxes : bool;
  30. show_frames : bool;
  31. adjust_optical_alpha : float;
  32. adjust_optical_beta : float;
  33. adjust_epsilon : float;
  34. adjust_min_space : float;
  35. math_break_badness : float;
  36. stdGlue : float * float * float;
}

Environments. These are typically folded on document trees, and control many different things about the fonts, counters, or labels.

val env_accessed : bool Stdlib.ref
val names : environment -> ((int * int list) Patutil.Extra.StrMap.t * string * Box.line) Patutil.Extra.StrMap.t
val user_positions : environment -> Box.line Box.MarkerMap.t

Document content

type content =
  1. | B of environment -> Box.box list * Box.box list option Stdlib.ref
    (*

    List of boxes depending on an environment. The second parameters is a cache used when compilation is iterated to resolve names.

    *)
  2. | C of environment -> content list
    (*

    A contents list depending on the environment. This may be used to typeset the state of a counter for example.

    *)
  3. | T of string * Box.box list Patutil.Extra.IntMap.t option Stdlib.ref
    (*

    Simple text.

    *)
  4. | Env of environment -> environment
    (*

    Environment modification function. It can be used to register a name or modify the state of a counter for instance.

    *)
  5. | Scoped of environment -> environment * content list
    (*

    A scoped environment transformation applied on a (small) list of contents.

    *)
  6. | N of tree
    (*

    A document tree.

    *)

Main type used to hold document contents.

and paragraph = {
  1. par_contents : content list;
  2. par_env : environment -> environment;
  3. par_post_env : environment -> environment -> environment;
  4. par_parameters : environment -> Box.box array array -> Box.drawingBox array -> Box.parameters -> Break.figurePosition Patutil.Extra.IntMap.t -> Box.line Box.MarkerMap.t -> Box.line -> Box.line -> Box.parameters;
  5. par_badness : environment -> Box.box array array -> Box.drawingBox array -> Break.figurePosition Patutil.Extra.IntMap.t -> Box.line -> Box.box array -> int -> Box.parameters -> float -> Box.line -> Box.box array -> int -> Box.parameters -> float -> float;
  6. par_completeLine : environment -> Box.box array array -> Box.drawingBox array -> Break.figurePosition Patutil.Extra.IntMap.t -> Box.line Box.MarkerMap.t -> Box.line -> bool -> Box.line list;
  7. par_states : int list;
  8. par_paragraph : int;
}

First type of leaves in a document: paragraphs.

Second type of leaves in a document: figures.

and node = {
  1. name : string;
  2. displayname : content list;
  3. mutable boxified_displayname : Patoraw.RawContent.raw list;
  4. children : tree Patutil.Extra.IntMap.t;
  5. node_tags : (string * string) list;
  6. node_env : environment -> environment;
  7. node_post_env : environment -> environment -> environment;
  8. node_states : int list;
  9. mutable node_paragraph : int;
}

Internal node of the document tree (e.g. section, chapter...).

and tree =
  1. | Paragraph of paragraph
  2. | FigureDef of figuredef
  3. | Node of node

Type of a document tree.

val empty : node

Empty node (with no child tree).

val singleton : tree -> node

Build a node with a single child tree.

module TreeData : sig ... end

The main datatype is a zipper over a document tree. It consists in a couple whose first component is a tree. The second component represents the context identifying a position in the tree.

module DocZipper : sig ... end
type tree_zipper = DocZipper.zipper
val zipper_of_tree : DocZipper.zipper -> DocZipper.tree

Build a zipper from a tree. The resulting zipper points to the root of the tree.

val empty_zipper : DocZipper.zipper

Build a zipper whose single node is empty.

Function that takes a tree zipper (t,cxt) pointing to some node t and returns a zipper pointing to the father node of t. If this function is called on a zipper that points to the root of the tree, a new empty node is created to have t as its only child.

  • deprecated Use DocZipper.up instead
val up_n : int -> DocZipper.zipper -> DocZipper.zipper

Function that applies up n times on a zipper, effectively moving the zipper to the n-th ancestor of the currently pointed node.

Move the zipper to the root of the tree

val tree_of_zipper : DocZipper.zipper -> DocZipper.tree

Retrieve the complete tree from a zipper

Move the zipper to point to the child of the pointed node with the higher index. If the pointed tree is not a node the zipper is left unchanged.

val newChildAfter : tree_zipper -> tree -> tree_zipper

Take a zipper zip and a tree c and adds c as the last child of the pointed node. If the pointed subtree is not a node, a new node is created to hold t and c. The returned zipper points to c.

val newChildBefore : tree_zipper -> tree -> tree_zipper

Same as newChildAfter but adds the tree as the first child.

val child : tree_zipper -> int -> tree_zipper

Take a zipper pointing to a node and move it down its i-th child. If the zipper does not point to a node, Invalid_argument is raised. If the i-th child does not exists, it is created as a new empty node.

val follow : tree_zipper -> int list -> tree_zipper

Take a tree zipper and an path represented as a list of integers and move the zipper down the path (i.e. calling child on the successive indices.

module type Format = sig ... end

Module type of a document format.

module type DocumentStructure = sig ... end

Module type to be used as a document wrapper. The document structure is stored in its zipper form in a reference. Functions are provided below to edit the document tree.

val doc_tags : tree -> (string * string) list
val init_env_hook : (environment -> environment) list Stdlib.ref
val add_env_hook : (environment -> environment) -> unit
val bB : (environment -> Box.box list) -> content
val uB : (environment -> Box.box list) -> content
val tT : string -> content
val uT : string -> content
val string_of_contents : content list -> string
val _names : environment -> ((int * int list) Patutil.Extra.StrMap.t * string * Box.line) Patutil.Extra.StrMap.t
val _user_positions : environment -> Box.line Box.MarkerMap.t
val incr_counter : ?level:int -> Patutil.Extra.StrMap.key -> environment -> environment
val tags : tree -> (string * string) list
val default_new_page : (float * float) -> (Box.frame * (Patutil.Extra.IntMap.key * Box.frame) list) -> Box.frame * (Patutil.Extra.IntMap.key * Box.frame) list

Creates a new page, using 1/6th of the given lengths for margins. A page is implemented as two nested frames: the outer frame has the actual size of the whole page, while the inner frame size is the papersize minus margins.

This function returns the inner frame.

val raw_new_page : (float * float) -> (Box.frame * (Patutil.Extra.IntMap.key * Box.frame) list) -> Box.frame * (Patutil.Extra.IntMap.key * Box.frame) list

Creates a new page without any margin

val rStdGlue : (float * Box.box) Stdlib.ref
val append : Box.box array Stdlib.ref -> int Stdlib.ref -> Box.box -> unit
val concat : Box.box array Stdlib.ref -> int Stdlib.ref -> Box.box array -> int -> unit
val mappend : 'a Patutil.Extra.IntMap.t -> 'a -> 'a Patutil.Extra.IntMap.t
val nfkc : 'a -> 'a
OCaml

Innovation. Community. Security.