Module typesetters.nodes.liners
Liner nodes for supporting multi-line constructs in the 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 Omikhkeia / Didier Willis
These nodes are used to mark and track constructs that may span over several lines, with some effect applied on each line (repeatedly). as a paragraph is being typeset and line-broken.
Examples of such constructs are:
- Underlined or strikethrough content,
- Links (which can be long URLs at unpleasant places),
- Redacted content,
- etc.
The content may be line-broken, and each bit on each line will be wrapped into a box. These boxes will be formatted according to some output logic, possibly with some effects applied (e.g. decorations), besides outputting the content itself if wanted.
This modules defines three node types:
- linerEnterNode and linerLeaveNode shall always be used in pairs.
- linerBox is a box node for a single-line content.
As Sith Lords, the enter/leave nodes always come in pairs, or the Force will be unbalanced. The typesetter is responsible for introducing one at the start of some content, the other at the end. After having line-broken the paragraph, the typesetter must then look for these pairs, and for each pair found, extract the content between them, re-assemble it into a linerBox node. When doing so, it should transfer the output method from the enter node to the linerBox.
Class linerEnterNode
linerEnterNode:_init (name, outputMethod) | (Constructor) Create a new liner enter node. |
linerEnterNode:clone () | Clone a liner enter node. |
linerEnterNode:outputYourself () | Output the node. |
Class linerLeaveNode
linerLeaveNode:_init (name) | (Constructor) Create a new liner leave node. |
linerLeaveNode:clone () | Clone a liner leave node. |
linerLeaveNode:outputYourself () | Output the node. |
Class linerBox
linerBox:_init (name, outputMethod) | (Constructor) Create a new liner box. |
linerBox:append (node) | Append a content node to the liner box. |
linerBox:count () | Count the number of nodes in the liner box. |
linerBox:outputContent (typesetter, line) | Output the line box content. |
Class linerEnterNode
- linerEnterNode:_init (name, outputMethod)
-
(Constructor) Create a new liner enter node.
Parameters:
- name string Name of the liner
- outputMethod function Output method for eventual liner boxes
- linerEnterNode:clone ()
-
Clone a liner enter node.
Returns:
-
linerEnterNode
Clone of the node
- linerEnterNode:outputYourself ()
-
Output the node.
Liner enter nodes should never make it to output, so this raises an error.
Raises:
Error
Class linerLeaveNode
- linerLeaveNode:_init (name)
-
(Constructor) Create a new liner leave node.
Parameters:
- name string Name of the liner
- linerLeaveNode:clone ()
-
Clone a liner leave node.
Returns:
-
linerLeaveNode
Clone of the node
- linerLeaveNode:outputYourself ()
-
Output the node.
Liner leave nodes should never make it to output, so this raises an error.
Raises:
Error
Class linerBox
- linerBox:_init (name, outputMethod)
-
(Constructor) Create a new liner box.
Parameters:
- name string Name of the liner
- outputMethod function Output method
- linerBox:append (node)
-
Append a content node to the liner box.
This updates the box dimensions as needed.
Parameters:
- node node Node to append
- linerBox:count ()
-
Count the number of nodes in the liner box.
Returns:
-
number
Number of nodes
- linerBox:outputContent (typesetter, line)
-
Output the line box content.
This should be called from the ouput routine passed at construction,
to output the actual content of the liner.
Parameters:
- typesetter Current typesetter
- line Current line properties