Skip to main content

Module session

Module session 

Source
Expand description

A retained pipeline: every stage kept, and only what an edit changed run again.

layout_book is a pure function of its inputs, so every call rebuilds every stage. A process that renders one book and exits wants that. A live preview does not, because the common event there is a small change to one input while the others stand. A session retains the output of each stage and works out the deepest stage an edit reaches: a colour serves the display structure back, page furniture repaints, @page geometry re-fragments over cached lines, and only the measure or the text itself breaks lines again.

§Section-local lines

Line breaking is section-local: where the breaks fall depends on the measure, the face and the text, not on where the section starts vertically. Line placement depends on position and belongs to fragmentation. So the cache stores breaks, shaped runs and advances, and no page coordinates at all. An edit to one chapter re-breaks that chapter and re-fragments the book, which for a whole novel costs about what tracking the pages that moved would.

Two preconditions make that sound, and both are checked rather than remembered. The first is a uniform measure: masters that resolve different content widths make breaking depend on which page a line lands on. The second is that no inline text depends on pagination, which the parser guarantees: counter(page) is legal only inside a margin box. When either one fails, the session re-breaks everything instead of serving stale lines.

A reference that prints a page is the one piece of inline text that pagination decides, and it is set on a pass of its own. The first pass sets a placeholder where the number goes, so its lines are section-local like any others. The second builds again only the sections whose references print a page, and keys each one by the folios it prints.

The parts have a file each: edit is what a host changes, output is what it asks for, inspect answers what styled one node and where it landed, stage runs the stages, invalidate decides which of them an edit reaches, and key fingerprints one section.

Structs§

Session
A retained pipeline: content, styling, and every stage between them and the page.
Stages
How many times each stage has run since the session was made.

Enums§

AddFontError
Why a face did not reach a session’s registry.
AddImageError
Why an image did not reach a session’s asset table.