pub fn lower_reference(
cx: &mut LowerCx<'_>,
lw: &mut dyn Lowerer,
node: &NodeRef<'_, Flm>,
targets: &[RefTargetText],
display: &RefDisplayOptions,
) -> Result<Vec<Vec<BuildId>>, LowerError>Expand description
Lowers a reference to targets, with the display options display, into
the items it shows: a command of another feature calls this function to
show a reference exactly as a \ref does, instead of writing that
behavior again.
Returns the list of items, in order, each a sequence of staged nodes
linked to its own target: first one item per counter style for the
targets the document numbered, then one item per other target. The module
documentation says what each item shows. The \ref rule joins the items
with the texts of RefsConfig, even a single item,
which receives one_pre and one_post. A command of another feature
writes the items as it needs. Two do so: the mathematics feature’s
\eqref, whose one target shows what \ref[noprefix] would show, writes
its one item without one_pre and one_post (both empty by default),
because that feature cannot read this feature’s joining texts; and the
theorems feature’s back-reference from a proof to its theorem.
node is the node being lowered, whose address identifies the reference
sites the resolve stage (RESOLVE) wrote for it;
targets are the targets of that
node, in the order they were written, as ref_targets
reads them; display holds the display options. A wording variant written
as a key that the counter style of a numbered target does not declare is
reported at node (UndeclaredVariant); the
key S is a preference and is never reported.
The calling rule must declare that it produces
flm.pres.link and
flm.pres.span and that it reads
flm.refs.resolutions (REF_RESOLUTIONS). It should also declare an
optional read of COUNTERS, with a peer declaration of that table
(FeatureBuilder::peer_table),
so that a target the document numbered shows its number.
The calling element must declare, through
Referencing, one reference site
per target of targets that has a label, in the order those targets are
written: the resolution of a target is read by its place among the
labeled targets. A target without a label uses no site and is shown
unresolved, as the text it was written with. If the element declares its
sites in any other way, the rule reports flm.run.missing-entry at the
node and fails, which looks like a fault of the pipeline although the
mistake is in the calling feature.
§Errors
Returns LowerError when a node could not be built, when the calling
rule did not declare what this function stages or reads, when a table
could not be read, or when the reference site of a target is missing from
flm.refs.resolutions (a fault of an earlier step, reported at the node
before the error is returned).