Expand description
Page-reference resolution and its layout fixpoint (issue #72).
@page(label) resolves to the printed page number of label’s target.
Unlike a section or figure number, that page number is only known after
layout, so it cannot be resolved in the single lowering pass: a page
reference’s rendered width can shift pagination, which can move the target
to a different page, which changes the number. The fixpoint drives layout
repeatedly until the label→page map stabilizes.
Responsibilities are split by which input each step needs:
validate_page_referencesruns at lower time, where the label index exists, and reports an undeclared@page(x)asMOS0033, exactly like an undeclared@x. (It lives inresolvenext to the index.)resolve_page_referencesruns each fixpoint iteration with a label→page map from layout and rewrites each page reference’s text to the number.resolve_page_reference_fixpointis the driver. Layout is injected as a closure so this module keeps nomos-layoutdependency (the one-way crate flow holds) and the loop is unit-testable with a mock layout.
Enums§
- Page
Fixpoint Outcome - The result of driving page references to a fixpoint.
Functions§
- resolve_
page_ reference_ fixpoint - Drive page-reference resolution to a fixpoint against an injected
layout. - resolve_
page_ references - Rewrite every
@page(label)reference’s visible text to its target’s page number, drawn fromlabel_pages(a label→1-based-page map produced by layout). Returns whether any text changed, so the fixpoint driver can tell when the document settled.