Module typesetters.silent

The sile·nt "new typesetter" for re·sil·ient.

Derived from SILE's base/default typesetter.

Some code in this file comes from SILE's core typesetter.

License: MIT. Copyright (c) The SILE Organization / Simon Cozens et al.

This file is part of re·sil·ient, a set of extensions to SILE.

License: MIT. Copyright (c) 2025 Didier Willis / Omikhkeia

Local Functions

mixin (cls, t) Naive mixins support (merging mixin tables into a class).

Class typesetters.silent

typesetter:_init (frame) Constructor
typesetter:declareSettings () Declare common settings for the typesetter.
typesetter:_initState () Initialize the typesetter state.
typesetter:initFrame (frame) Initialize the typesetter with a frame.
typesetter:getMargins () Get the current left and right margins.
typesetter:setMargins (margins) Set the current left and right margins.
typesetter:pushState () Push the current typesetter state onto the state queue,
typesetter:popState () Pop the last typesetter state from the state queue,
typesetter:isQueueEmpty () Check if the typesetter queue is empty (no pending nodes, no output).
typesetter:vmode () Check if the typesetter is in vertical mode (no pending nodes).
typesetter:debugState () Debug print of the current typesetter state.
typesetter:pushHorizontal (node) Push a horizontal node into the current horizontal list.
typesetter:pushVertical (vbox) Push a vertical node into the current vertical list.
typesetter:pushHbox (spec) Push an hbox into the current horizontal list.
typesetter:pushUnshaped (spec) Push an unshaped node into the current horizontal list.
typesetter:pushGlue (spec) Push a glue node into the current horizontal list.
typesetter:pushExplicitGlue (spec) Push an explicit glue node into the current horizontal list.
typesetter:pushPenalty (spec) Push a penalty node into the current horizontal list.
typesetter:pushMigratingMaterial (material) Push a migrating node into the current horizontal list.
typesetter:pushVbox (spec) Push a vbox node into the current vertical list.
typesetter:pushVglue (spec) Push a vglue node into the current vertical list.
typesetter:pushExplicitVglue (spec) Push an explicit vglue node into the current vertical list.
typesetter:pushVpenalty (spec) Push a penalty node into the current vertical list.
typesetter:typeset (text) Split the input text into paragraphs, and push them to the current horizontal list.
typesetter:initline () Initialize a new line if needed, entering horizontal mode and starting a new paragraph.
typesetter:endline () Leave horizontal mode and end the current paragraph.
typesetter:setpar (text) Takes an input paragraph string, and pushes it to the current horizontal list,
typesetter:shapeAllNodes (nodelist, inplace) Shape all unshaped nodes in a list (legacy compatibility function).
typesetter:getTargetLength () Get the target length for the current frame.
typesetter:registerHook (category, func) Register a hook function to be called at a certain event.
typesetter:runHooks (category, data) Run all hooks registered for a certain event.
typesetter:registerFrameBreakHook (func) Register a hook function to be called at each frame break.
typesetter:registerNewFrameHook (func) Register a hook function to be called at each new frame initialization.
typesetter:registerPageEndHook (func) Register a hook function to be called at page end.
typesetter:buildPage () Attempt to build a page from the current vertical list.
typesetter:setVerticalGlue (pageNodeList, target) Adjust vertical glues on a page to fit the target length.
typesetter:initNextFrame () Initialize the next frame for typesetting.
typesetter:outputLinesToPage (lines) Output a list of lines to the current page.
typesetter:leaveHmode (independent) Leave horizontal mode, ending the current paragraph.
typesetter:chuck () Emergency shipout everything


Local Functions

mixin (cls, t)
Naive mixins support (merging mixin tables into a class).

Parameters:

  • cls p.class Class to extend
  • t table Mixin table

Class typesetters.silent

The sile·nt typesetter class.

The typesetter does a lot of different things.

  • Managing the typesetter state (horizontal/vertical mode, node node queues etc.)
  • Shaping text into glyphs,
  • Breaking paragraphs into lines,
  • And many other things...

It's a huge beast, with many interdependent parts and several roles.

SILE's typesetter, in this author's viewpoint, has become somewhat intricate over time, with lots of obscure decisions all over the place, and loosely organized parts and undocumented behaviors. all in a big monolithic file.

The sile·nt typesetter is a rewrite of SILE's base/default typesetter, where some parts of the logic have been split into "mixin" modules, each implementing a specific feature:

There are also other deviations in the way it handles some algorithms, e.g., regarding in which order some operations are performed, in a attempt to make things more logical and easier to follow; and in some cases more efficient. The are also some API changes, as some methods have are considered internal and not part of the public-facing API. These methods are all documented, but their name starts with an underscore. Finaally, some weird code paths and non-functional features have been removed.

typesetter:_init (frame)
Constructor

Parameters:

  • frame A initial frame to attach the typesetter to.
typesetter:declareSettings ()
Declare common settings for the typesetter.
typesetter:_initState ()
Initialize the typesetter state.
typesetter:initFrame (frame)
Initialize the typesetter with a frame.

Parameters:

  • frame
typesetter:getMargins ()
Get the current left and right margins.
typesetter:setMargins (margins)
Set the current left and right margins.

Parameters:

  • margins
typesetter:pushState ()
Push the current typesetter state onto the state queue,
typesetter:popState ()
Pop the last typesetter state from the state queue,
typesetter:isQueueEmpty ()
Check if the typesetter queue is empty (no pending nodes, no output).
typesetter:vmode ()
Check if the typesetter is in vertical mode (no pending nodes).
typesetter:debugState ()
Debug print of the current typesetter state.
typesetter:pushHorizontal (node)
Push a horizontal node into the current horizontal list.

Parameters:

  • node
typesetter:pushVertical (vbox)
Push a vertical node into the current vertical list.

Parameters:

  • vbox
typesetter:pushHbox (spec)
Push an hbox into the current horizontal list.

Parameters:

  • spec
typesetter:pushUnshaped (spec)
Push an unshaped node into the current horizontal list.

Parameters:

  • spec
typesetter:pushGlue (spec)
Push a glue node into the current horizontal list.

Parameters:

  • spec
typesetter:pushExplicitGlue (spec)
Push an explicit glue node into the current horizontal list.

Parameters:

  • spec
typesetter:pushPenalty (spec)
Push a penalty node into the current horizontal list.

Parameters:

  • spec
typesetter:pushMigratingMaterial (material)
Push a migrating node into the current horizontal list.

Parameters:

  • material
typesetter:pushVbox (spec)
Push a vbox node into the current vertical list.

Parameters:

  • spec
typesetter:pushVglue (spec)
Push a vglue node into the current vertical list.

Parameters:

  • spec
typesetter:pushExplicitVglue (spec)
Push an explicit vglue node into the current vertical list.

Parameters:

  • spec
typesetter:pushVpenalty (spec)
Push a penalty node into the current vertical list.

Parameters:

  • spec
typesetter:typeset (text)
Split the input text into paragraphs, and push them to the current horizontal list.

Parameters:

  • text
typesetter:initline ()
Initialize a new line if needed, entering horizontal mode and starting a new paragraph.
typesetter:endline ()
Leave horizontal mode and end the current paragraph.
typesetter:setpar (text)
Takes an input paragraph string, and pushes it to the current horizontal list,

Parameters:

  • text
typesetter:shapeAllNodes (nodelist, inplace)
Shape all unshaped nodes in a list (legacy compatibility function).

Parameters:

  • nodelist
  • inplace
typesetter:getTargetLength ()
Get the target length for the current frame.
typesetter:registerHook (category, func)
Register a hook function to be called at a certain event.

Parameters:

  • category
  • func
typesetter:runHooks (category, data)
Run all hooks registered for a certain event.

Parameters:

  • category
  • data
typesetter:registerFrameBreakHook (func)
Register a hook function to be called at each frame break.

Convenience helper.

Parameters:

  • func
typesetter:registerNewFrameHook (func)
Register a hook function to be called at each new frame initialization.

Convenience helper.

Parameters:

  • func
typesetter:registerPageEndHook (func)
Register a hook function to be called at page end.

Convenience helper.

Parameters:

  • func
typesetter:buildPage ()
Attempt to build a page from the current vertical list.
typesetter:setVerticalGlue (pageNodeList, target)
Adjust vertical glues on a page to fit the target length.

Parameters:

  • pageNodeList
  • target
typesetter:initNextFrame ()
Initialize the next frame for typesetting.
typesetter:outputLinesToPage (lines)
Output a list of lines to the current page.

Parameters:

  • lines
typesetter:leaveHmode (independent)
Leave horizontal mode, ending the current paragraph.

Parameters:

  • independent
typesetter:chuck ()
Emergency shipout everything
generated by LDoc 1.5.0 Last updated 2025-09-14 22:28:52