Expand description
This module defines the refpoints feature, which collects the reference
points of a document in the table REFPOINTS (flm.refpoints).
A reference point (RefPoint) is a place in a document that can be
referred to, numbered, or given an anchor, such as a heading, an equation
line, a theorem or a footnote. An element declares the reference points of
each of its nodes through the Referenceable aspect. A node can have
several reference points; for instance, a display-math environment has one
reference point for each equation line. The concepts overview explains how
reference points relate to labels and anchors (Reference points, labels
and anchors).
Several features work on the reference points of a document. The
refs feature collects the labels of the
reference points and computes their anchors, the
numbering feature numbers them,
and the xnotes feature finds the
footnotes and other notes among them. These features read the reference
points from the table REFPOINTS and do not call the Referenceable
aspect themselves. Therefore the aspect is called only once for each node
in a run, and content that an element builds for a reference point
(ContentRef::Synthesized) is built only once and shared by all readers
of the table.
§What the feature registers
The refpoints feature offers no command or environment. It registers the
following items:
- The table
REFPOINTS(flm.refpoints), whose value is aRefPoints. The table contains oneRefPointRecordfor each reference point of the run. A reference point is identified by aPointId: the address of its node and its index among the reference points of that node. - The stage
SCAN(flm.refpoints.scan), which writes this table. The stage runs once for each tree. It uses the element index (ELEMENT_INDEX) to find the nodes of the tree whose element carries theReferenceableaspect, and records their reference points in tree order: the root, then its descendants in preorder.
A stage reads the table like any other table: it declares the read with
Needs::reads(REFPOINTS) and obtains the table with StageCx::get.
A stage that runs once for the whole document and needs the reference
points in document order calls RefPoints::in_document_order.
§Features that require the table
The stages of the refs, numbering and xnotes features require the
table REFPOINTS. A registry that contains one of these features must
therefore also contain the refpoints feature. The refpoints feature in
turn requires the element index, so the registry must also contain the
index feature.
A registry that lacks the refpoints feature still builds. However, every
plan made from it fails with
PlanError::NeedsUndeclared:
a stage reads the table flm.refpoints, and this table is not declared in
any feature. This holds even for a plan that does not schedule the stages
that read the table, because the needs of every registered stage are
resolved when a plan is made.
§Synthesized values
A synthesized value
is a small tree that a stage builds during a run, outside the document’s
trees, for instance the text displayed for a reference. Before a stage
renders a synthesized value, it calls StageCx::resolve_value, which
performs value catch-up:
the stages that run once for each tree and that the calling stage depends
on run over the synthesized value. The stage SCAN is among these stages
if the calling stage depends on it, directly or through other stages. The
table REFPOINTS computed during the catch-up then contains only the
reference points of the synthesized value.
A synthesized value is not part of the document, so it may not define a
label. If the table computed during the catch-up contains a reference
point with a label, the catch-up fails with
StoreError::DocumentFactInValue.
A synthesized value may contain reference points without a label.
Structs§
- RefPoint
Record - A
RefPointRecordis one entry of the tableREFPOINTS. It contains a reference point as theReferenceableaspect of its node returned it, together with the identifier of the reference point and the span of the node. - RefPoints
- A
RefPointsis the value of the tableREFPOINTS(flm.refpoints). It contains oneRefPointRecordfor each reference point of the trees of the run. - Refpoints
- The
refpointsfeature, which registers the tableREFPOINTSand the stageSCANthat writes this table. The module documentation describes the table and the features that read it. - Stage
Failed - The error that is reported when the stage
SCANcannot read the element index or cannot write the table of reference points (idflm.refpoints.stage-failed).
Constants§
- FEATURE
- The feature’s registered name,
refpoints. - REFPOINTS
- The name of the table of reference points,
flm.refpoints, whose value is aRefPoints. To read the table in a stage, declare the read withNeeds::reads(REFPOINTS). - SCAN
- The name of the stage that writes the table of reference points
REFPOINTS,flm.refpoints.scan.
Functions§
- feature
- Returns the
Refpointsfeature as a shared feature object, for instance to list it in aPackageEntry.