Skip to main content

Module refs

Module refs 

Source
Expand description

The refs feature: labels and references. An author attaches a label to a construct with \label{sec:intro} and refers to it with \ref{sec:intro}, and the feature turns each reference into a link to the labeled place, showing that place’s number or title.

The terms are those of the concepts overview, Reference points, labels and anchors: a reference point (RefPoint) is one place in a document that can be referred to, numbered, or given an anchor (a heading, an equation line, a theorem, a footnote); a label is the text an author attaches to it with \label{type:label}; an anchor is the identifier a link points at, computed once for every point (ANCHORS); and a reference site (RefSite) is one place that points at a reference point, such as a \ref.

§What an author writes

  • \label{type:label}, written right after a construct that accepts labels (\section{Introduction}\label{sec:intro}). The label type is the part before the colon and says what sort of place the label marks; each construct accepts a fixed set of types (a heading accepts sec and topic). A label may be written only once in a document. A \label is a field, a macro that the construct before it reads as data, so it is available only after a construct that declares it.
  • \ref[options]{type:label}, a reference that shows what its target has to show: its number, else its content (a heading’s title, for instance), else the label as written. Several targets may be written in one \ref, separated by commas (\ref{eq:a,eq:b}), and are shown as one list. The options choose the wording of the word before a number: noprefix leaves that word out, S asks for the capitalized wording where the counter style (how the numbering feature shows a counter’s value; see counters and counter styles) declares one, and any other key asks for the wording variant of that name (abbreviated, lowercase, capital).
  • \hyperref[type:label]{text}, a reference that shows the author’s own text instead of what the target has to show.

The syntax guide shows these commands from an author’s side, under Labels and references.

§What a reference displays

A reference point states the two things a reference to it may show: a number source (NumberSource), the counter and the counter style it is numbered by, where it can be numbered at all; and content of the document, where it has any. For each target, a \ref shows the first of these that exists:

  1. the number this document gave the point;
  2. else the point’s content;
  3. else the label the reference was written with, as written.

A point that states a number source may still receive no number in a run: no numbering feature is registered, nobody declares its counter, or a counter it is numbered within has no value yet. A point that ends up with neither a number nor content has nothing to show (an unnumbered float with no caption, an equation in a registry without the numbering feature), and a reference to it is the Error NothingToShow (flm.refs.nothing-to-show).

The number is read from the counter table of the numbering feature, which the \ref lowering rule reads optionally, through a peer declaration (PeerName): in a registry without that feature, a reference shows the point’s content or its label. The counter style of the point decides what a number looks like (the word before it, the delimiters around it, how several numbers are joined), and the options written on a \ref choose among the wording variants that the style declares. The key S asks for the variant CAPITAL_VARIANT where the style declares it and for the usual wording otherwise. Any other key asks for the variant of its own name, and where the counter style of a numbered target does not declare that variant, the reference is the Error UndeclaredVariant.

A \ref with several targets is written as one list. Its first items are the numbers, one item per counter style, each written by that style with consecutive numbers collapsed into a range; then come the other targets, one item each, in the order the reference wrote them. The items are joined by the texts of the feature’s configuration, RefsConfig: Eq. (1) and Thm. 1.1, Eq. (1), Thm. 1.1, and A note. Another feature that shows a reference from a command of its own calls lower_reference, which writes the items.

A point’s content (a heading’s title, for instance) is copied out of the frozen tree into a synthesized value, a small tree held in a table, when the anchors stage writes the point’s target. Content that the point’s element built itself because no node of the tree holds it (the bullet beside a list’s item, ContentRef::Synthesized) is already such a tree and is shared rather than copied. The \ref rule splices the synthesized value into the nodes it stages (builds into the lowered tree; see Lowerer): the value is first brought up to date by value catch-up, which runs the plan’s rewrites and the per-tree stages the lowering depends on over the value alone, and is then lowered through the rules. A \ref written inside a heading’s title therefore resolves exactly like one written in the body.

§What the feature registers

The refs feature (Refs, a FlmFeature) registers:

  • Two elements. REF (flm.ref), the \ref element, and HYPERREF (flm.hyperref), the \hyperref element. A node of either declares its reference sites through the Referencing aspect, one per target, and goes through the same stages; the two differ in what they display. The feature registers no element for the \label written after a construct: like every tack-on field, its node carries the language’s field element (FIELD).
  • A scoped package. A scoped package (ScopedPackageDef) is a set of element declarations that can be written only inside the environment bodies and arguments whose declarations refer to it by name (scoped packages). LABEL_PACKAGE (flm.refs.label, built by label_package) holds \label as a command, for the arguments that refer to it, such as the optional argument of \footnote.
  • Two argument roles. An argument role states what an argument holds (ArgDef::role). TARGET_ARG_ROLE (flm.refs.target) is the role of the target argument of \ref and \hyperref, the label or labels a reference points to. DEFINED_LABEL_ARG_ROLE (flm.refs.defined-label) is the role of the argument of \label, the label it attaches to a construct, in the \label field and in the scoped package’s \label command.
  • Four tables. LABELS (flm.labels): the first point that wrote each label, the labels written more than once, and the labels refused for their type. ANCHORS (flm.anchors): each point’s anchor, or none. REF_TARGETS (flm.refs.targets): for each label, the point, its link target and what a reference to it shows. REF_RESOLUTIONS (flm.refs.resolutions): how each reference site resolved.
  • An external table. EXTERNAL_INDEX (flm.refs.external-index): labels of other documents, with their link targets and the content a reference to them shows. An external table is a table that no stage of the run writes: the caller installs its value when the run is constructed (Externals). The resolve stage reads it when the caller has installed it.
  • Four stages. SCAN records the first point that wrote each label; ANCHORS_STAGE gives every point its anchor and writes the targets; RESOLVE resolves every reference site; CHECK_LABELS reports the duplicate labels and the labels of a type their point does not accept. The check provides the capability of its own name, a member of the flm.validated collection of capabilities, which every standard workflow demands (asks the plan to provide; see PlanRequest). The documentation of each constant says what its stage reads and writes.
  • Render options. RefsRenderOptions, set per render request: whether an unresolved reference is an Error or a Warning.
  • A configuration. RefsConfig, the texts that join the items of a reference to several targets. A feature’s configuration is the plain Rust value the feature is constructed from; it is fixed when the registry is built (settings, options and configuration).
  • Lowering rules, per backend. On every backend, REF_RULE lowers a \ref to a flm.pres.link to each target, around the number, the content or the label it shows, and HYPERREF_RULE lowers a \hyperref to a link around the author’s text; a target that nothing resolves becomes a flm.pres.span styled as an unresolved reference instead of a link. The HTML backend writes the link as an <a> element (References in HTML). On the latex-recomposed backend, the rules of the submodule latex are the default instead: they leave the resolution to LaTeX and write \label, \flmRef and \flmHyperref around safe labels (see Recomposing to LaTeX below).
  • The stages and tables of the recomposed LaTeX, in the submodule safe_labels: the safe labels the recomposed LaTeX writes in place of the document’s labels.

§Anchors

An anchor is the identifier a link points at for a reference point. The element of the point chooses how it is formed (AnchorPolicy), and the anchors stage computes it once:

  • <type>-<label> from the first label the point keeps: sec-intro (label_anchor);
  • <prefix>--<title> for an unlabeled heading: sec--Introduction (title_anchor);
  • <prefix>--<position><four letters> for an unlabeled point whose element asks for its position (an equation line, a list item, an xnote): eq--8otbc for the eighth equation line (auto_anchor);
  • <prefix>-<numbers> from the number the document gave the point, for an element that asks for it (a theorem, a float): theorem-2-3 (value_anchor); a point the document did not number takes its first label instead;
  • an identifier the element gives itself, used as given.

The element states the prefix, so that the anchor of a point begins the same way whether it was labeled or not. The prefix, the parts of a label, a title and a number text go through one encoder, encode_anchor: a text made only of ASCII letters, digits, ., - and single spaces is reproduced exactly, each space written _; any other text is stripped of accents, every run of other characters is replaced by _ or -, and ~ and six hexadecimal digits of a hash of the text as written are appended. No counter takes part in a label’s anchor, so one label always yields one anchor, regardless of what else the document contains.

An anchor made from a title is never refused: where another point already holds the anchor it would take (another heading with the same title, or a point whose anchor encodes alike), it takes the next free number (sec--Introduction-2), and nothing is reported. Any other anchor that another point already holds is a collision: the Error AnchorCollision is reported, the first point keeps the anchor, and the second gets none.

§Label types

A reference point declares which label types may be written for it (RefPoint::accepts): a heading accepts sec and topic, so \section{X}\label{eq:x} defines no label. A point that declares AcceptedRefTypes::Any accepts every type; a feature declares it for a construct that fixes no set. A label of a type the point does not accept defines nothing: no reference resolves through it, and a point whose every label was refused gets no anchor from a label. CHECK_LABELS reports it as LabelTypeNotAccepted (flm.refs.label-type-not-accepted).

A text that is not spelled type:label at all is no label: the construct keeps it among the point’s malformed texts, and the label scan reports it at the field where it was written, as BadLabel (flm.refs.bad-label). The scan reports a \ref or \hyperref target that is not spelled type:label the same way.

§Duplicate labels and unresolved references

A label written for two points is the Error DuplicateLabelCondition (flm.refs.duplicate-label), reported by CHECK_LABELS: the first point in document order keeps the label. This depends on the document alone.

A reference that nothing resolves is reported as Unresolved (flm.refs.unresolved): an Error by default, a Warning under RefsRenderOptions with unresolved: allow. Either way, the reference shows its own text marked as unresolved: the label text for a \ref, the author’s text for a \hyperref. In a plan that renders nothing, such as one of the check workflow, it is always a Warning, because whether a label resolves is decided per render, and a render may install an index of labels defined in other documents.

§Declaring a labeled construct in another feature

A feature gives one of its constructs labels in three steps:

  1. The element’s last argument is label_fields_arg, the trailing tack-on argument (the trailing argument that absorbs field macros; ArgStdKind::TackOn) that holds the \label fields, so that \thing{…}\label{x:y} parses. The argument of the \label field has the argument role DEFINED_LABEL_ARG_ROLE, which this feature declares; the other feature declares that role as a peer (FeatureBuilder::peer_argument_role), so that a registry without the references feature still builds.
  2. The element carries the Referenceable aspect, whose implementation reads those fields with label_uses, splits them with point_labels, and returns the point (or points) the node declares.
  3. Each point states the label types it accepts in its accepts field: a list of types, or AcceptedRefTypes::Any for a construct that fixes none.

A construct with a recomposition rule of its own writes its labels there with stage_label and stage_label_group (submodule latex). No other rule writes a label, because a field node that reaches a backend is an error.

Two kinds of \label are not tack-on fields. Inside a display-math environment’s body, the math feature declares \label as a command of its own (math::lines); inside an argument that refers to the scoped package LABEL_PACKAGE (a construct whose labels are written in an argument of their own, as in \footnote[\label{fn:x}]{…}), this feature’s package declares it. Both are field nodes of the same field name: label_use reads one such node, and label_uses_in reads every one of a run of nodes.

§Recomposing to LaTeX

The latex-recomposed backend writes the document back as LaTeX and leaves the resolution of references to LaTeX. LaTeX label keys must avoid certain characters, so the recomposed LaTeX writes a safe label (SafeLabels) in place of each FLM label: ref1, ref2, … in the order the document first mentions the labels. The submodule safe_labels holds the document-scope stage SAFE_LABELS_STAGE, which writes the table SAFE_LABELS (flm.labels.safe), and the per-tree stage VALUE_SAFE_LABELS_STAGE, which writes the table VALUE_SAFE_LABELS (flm.labels.safe.value) for the references of a synthesized value. The submodule latex holds the recomposition rules REF_LATEX_RULE and HYPERREF_LATEX_RULE, the helpers stage_label and stage_label_group that a labeled construct’s own rule writes its labels with, and the render options RefsRecomposeOptions. This feature registers those rules too; it declares the backend and the two LaTeX constructs they stage as peer declarations (PeerName), so that a registry without the LaTeX features still builds, with those rules set aside (excluded from rule selection). The rendering guide describes the result under References and safe labels.

§Items for other features

Re-exports§

pub use content::CopyError;
pub use content::auto_anchor;
pub use content::content_value;
pub use content::encode_anchor;
pub use content::label_anchor;
pub use content::title_anchor;
pub use content::value_anchor;
pub use content::value_of;
pub use latex::HYPERREF_LATEX_RULE;
pub use latex::HyperrefLatexRule;
pub use latex::LABEL_COMMAND;
pub use latex::LabelSpelling;
pub use latex::REF_LATEX_RULE;
pub use latex::RefLatexRule;
pub use latex::RefsRecomposeOptions;
pub use latex::SafeLabelMode;
pub use latex::ZCREF_COMMAND;
pub use latex::label_spelling;
pub use latex::read_target_at_lowering;
pub use latex::reference_type_words;
pub use latex::stage_label;
pub use latex::stage_label_group;
pub use latex::stage_labels_with_display_text;
pub use latex::stage_ref_options;
pub use latex::stage_reference_type_setup;
pub use latex::stage_spelling;
pub use latex::target_spelling;
pub use safe_labels::REF_DOMAIN;
pub use safe_labels::SAFE_LABELS;
pub use safe_labels::STAGE as SAFE_LABELS_STAGE;
pub use safe_labels::SafeLabels;
pub use safe_labels::SafeLabelsStage;
pub use safe_labels::VALUE_SAFE_LABELS;
pub use safe_labels::VALUE_STAGE as VALUE_SAFE_LABELS_STAGE;
pub use safe_labels::ValueSafeLabels;
pub use safe_labels::ValueSafeLabelsStage;
pub use safe_labels::label_key;
pub use safe_labels::value_name;

Modules§

latex
The LaTeX side of the refs feature: the recomposition rules that write \ref and \hyperref back as LaTeX for the latex-recomposed backend, the helpers with which a construct’s own rule writes its labels, and the render options RefsRecomposeOptions that shape both.
safe_labels
Safe labels: the keys that the recomposed LaTeX writes in place of the document’s own labels, numbered in document order by a stage of the refs feature and recorded in the table SAFE_LABELS.

Structs§

AnchorCollision
The error that is reported when two reference points receive the same anchor (flm.refs.anchor-collision).
Anchors
The anchors table, flm.anchors (ANCHORS): every reference point of the document with the anchor the anchors stage (ANCHORS_STAGE) computed for it, or no anchor when the point has nothing to form one from (no label it keeps, under a policy that needs one) or when an earlier point already holds the same one.
BadLabel
The error that is reported when a label, or a target of a \ref or a \hyperref, does not have the form type:label (id flm.refs.bad-label).
DisplayUnavailable
The error that is reported when the content that a reference displays for a reference point cannot be copied (id flm.refs.display-unavailable).
DuplicateLabel
A label written for two reference points, as Labels records it. The label scan (SCAN) records the fact; the label check (CHECK_LABELS) reports it as flm.refs.duplicate-label.
DuplicateLabelCondition
The error that is reported when a label is defined twice in a document (flm.refs.duplicate-label). This is the case when the same label is written for two different reference points, such as two headings.
ExternalIndex
The external index, flm.refs.external-index (EXTERNAL_INDEX): from a label of another document to its target.
ExternalTarget
A target of the external index: where a link to a label of another document leads, and what a reference to it shows. What it shows is content (a synthesized value), not a string, so that a reference to another document is rendered the same way as one inside this document.
HyperrefElement
The per-value data of the flm.hyperref element, and the element’s Referencing implementation: it returns the one reference site a \hyperref node declares, or none when its target is not spelled type:label. See the module documentation.
HyperrefRule
The implementation of HYPERREF_RULE: it stages the text the author wrote inside a flm.pres.link to the target, or inside a flm.pres.span styled as an unresolved reference where nothing resolved the target. See the module documentation.
LabelTypeNotAccepted
The error that is reported when a label has a type that the labeled construct does not accept (id flm.refs.label-type-not-accepted).
LabelUse
One \label written on a node, as label_uses, label_uses_in and label_use return it: the text as written, the span of the \label node, and the label when the text is spelled type:label.
Labels
The label table, flm.labels (LABELS): for every label, the first point that wrote it; the labels written more than once; and the labels refused because the point they were written for does not accept their type.
NothingToShow
The error that is reported when a reference refers to a reference point that has neither a number nor content to display (id flm.refs.nothing-to-show).
PointDisplay
The two things a reference to a point may show, as the anchors stage (ANCHORS_STAGE) records them: the number source and the content that the RefPoint states, with the content copied out of the document.
RefElement
The per-value data of the flm.ref element, and the element’s Referencing implementation: it returns the reference sites a \ref node declares, one per target spelled type:label. See the module documentation.
RefResolutions
The resolutions table, flm.refs.resolutions (REF_RESOLUTIONS): how every reference site resolved, for every node whose element carries the Referencing aspect.
RefRule
The implementation of REF_RULE: it stages what each target of the reference shows (its number, its content or its label), linked to that target, as one list joined by the texts of RefsConfig. See the module documentation.
RefTarget
What a label resolves to inside the document: the point that keeps it, the link target (# followed by the anchor) and what a reference to it shows.
RefTargetText
One target written in a reference command: the text as written, with the whitespace around it trimmed, and the label when that text is spelled type:label.
RefTargets
The targets table, flm.refs.targets (REF_TARGETS): from a label to what it resolves to inside the document. It combines the label table and the anchors, and the anchors stage (ANCHORS_STAGE), which runs once for the document, writes it. A label whose point received no anchor (a point that lost an anchor collision, or that has nothing to form an anchor from) has no entry, so a reference to it resolves to nothing in the document.
Refs
The refs feature (FlmFeature): it registers the \ref and \hyperref elements, the scoped package of \label, six stages (four that check and resolve labels and references, and two that serve the recomposed LaTeX), the tables they write, the render options and the lowering rules. See the module documentation.
RefsConfig
The configuration of the refs feature: the texts that join the items of a reference to several targets.
RefsRenderOptions
The render options of the refs feature. They are set per render request (crate::model::options).
RefusedLabel
A label whose type the point it was written for does not accept, as Labels records it. The label scan (SCAN) records the fact; the label check (CHECK_LABELS) reports it as flm.refs.label-type-not-accepted.
SiteId
The identity of one reference site: the address of the node that declares it and the site’s index among that node’s sites.
StageFailed
The error that is reported when a stage of the refs feature fails because of an error in the program (id flm.refs.stage-failed).
UndeclaredVariant
The error that is reported when a \ref asks for a wording variant that the counter style of a target does not declare (id flm.refs.undeclared-variant).
Unresolved
The error that is reported when a reference refers to an undefined label (flm.refs.unresolved). A label is defined when it is written for a reference point of the document, or when it is listed in the external index (EXTERNAL_INDEX) that the caller installed for the run.

Enums§

Designation
What a reference to a label shows, as designation gives it: the number, the content or the label of the module documentation’s “What a \ref shows”.
Resolution
How one reference site resolved.
UnresolvedRefs
The severity with which a reference to an undefined label is reported (Unresolved). This is the type of the option unresolved of RefsRenderOptions.

Constants§

ABBREVIATED_VARIANT
The counter style variant of the abbreviated words, abbreviated (Lem.~4 rather than Lemma~4), which \ref[abbreviated]{…} requests.
ANCHORS
The typed name of the anchors table, flm.anchors, an Anchors, which the anchors stage (ANCHORS_STAGE) writes.
ANCHORS_STAGE
The name of the anchors stage, flm.refs.anchors.
CAPITAL_KEY
The key of a \ref’s options that asks for the capitalized wording, S.
CAPITAL_VARIANT
The counter style variant that the key CAPITAL_KEY selects, capital: the wording a counter style declares for a reference that opens a sentence (Equation~(3) rather than Eq.~(3)).
CHECK_LABELS
The name of the label check stage, flm.refs.check-labels, and of the capability that this stage provides.
DEFINED_LABEL_ARG_ROLE
The argument role of a label that a \label attaches to a construct, flm.refs.defined-label: the role of the argument of the \label field (label_field) and of the \label command of the scoped package LABEL_PACKAGE. The feature declares it; a feature whose declarations hold either declares the role as a peer (FeatureBuilder::peer_argument_role), so that a registry without this feature still builds.
EXTERNAL_INDEX
The typed name of the external index, flm.refs.external-index, an ExternalIndex: an external table, whose value the caller installs when it constructs the run (Externals), and which no stage writes.
FEATURE
The feature’s registered name, refs.
FIELDS_ARG
The name of the trailing tack-on argument a construct holds its \label fields in, fields: the argument label_fields_arg declares and label_uses reads.
HYPERREF
The \hyperref element’s type name, flm.hyperref.
HYPERREF_RULE
The name of the \hyperref lowering rule, flm.hyperref.lower.default, whose implementation is HyperrefRule: the default for flm.hyperref on every backend except latex-recomposed.
LABELS
The typed name of the label table, flm.labels, a Labels, which the label scan (SCAN) writes.
LABEL_FIELD
The \label field’s name, label: what an author writes after the backslash, and the name under which a construct declares the field.
LABEL_PACKAGE
The name of the scoped package that holds \label as a command, flm.refs.label: an argument whose declaration refers to it (ArgDef::scoped) accepts \label{type:label}. See label_package.
LINK_KIND
The kind token written on the link that a \ref or a \hyperref produces, ref: it tells a backend, or a stylesheet, that the link comes from a reference (see the payload conventions). The HTML backend writes it as data-flm-kind="ref".
LOWERCASE_VARIANT
The counter style variant of the words written all in lowercase, lowercase (lemma~4 rather than Lemma~4), which \ref[lowercase]{…} requests.
NO_PREFIX_KEY
The key of a \ref’s options that leaves out the word before a number (the prefix, such as “Eq.”), noprefix.
OPTIONS_ARG
The name of a \ref’s options argument, options.
REF
The \ref element’s type name, flm.ref.
REF_RESOLUTIONS
The typed name of the resolutions table, flm.refs.resolutions, a RefResolutions, which the resolve stage (RESOLVE) writes and the lowering rules of references read.
REF_RULE
The name of the \ref lowering rule, flm.ref.lower.default, whose implementation is RefRule: the default for flm.ref on every backend except latex-recomposed.
REF_TARGETS
The typed name of the targets table, flm.refs.targets, a RefTargets, which the anchors stage (ANCHORS_STAGE) writes and the resolve stage (RESOLVE) reads.
RESOLVE
The name of the resolve stage, flm.refs.resolve.
SCAN
The name of the label scan stage, flm.refs.scan.
TARGET_ARG
The name of the target argument of a \ref, a \hyperref and a \label, target: the argument that holds the label.
TARGET_ARG_ROLE
The argument role of a label that a reference points to, flm.refs.target: the role of the target argument (TARGET_ARG) of \ref and \hyperref. The feature declares it; a feature with a reference command of its own sets it on that command’s target argument and, so that a registry without this feature still builds, declares the role as a peer (FeatureBuilder::peer_argument_role), as the math feature does for \eqref.
TEXT_ARG
The name of the argument holding a \hyperref’s displayed text, text.

Functions§

auto_anchor
The anchor formed from a point’s position, for an unlabeled point such as an equation line: <prefix>--<position><four letters>, as in eq--8otbc.
content_value
The synthesized value of the content reference content on node: the nodes ContentRef::nodes designates, copied through value_of; Ok(None) when the reference designates nothing on node.
designation
Returns what a reference to the label label, whose target in this document is target, shows: what a \ref{label} written with no display option shows, decided by the code that lower_reference decides it with. counters is the run’s counter table (COUNTERS), absent where the numbering feature is not registered or did not run; a target is then shown by its content or its label.
encode_anchor
Encodes one text for an anchor (the identifier a link points at; see ANCHORS): a label’s type, the label after the colon, or a heading title’s plain text.
feature
The Refs feature with the default configuration, ready to be listed in a package entry (PackageEntry).
field_text
The text of a \label node (the characters of its target argument, trimmed), or None when the node is not a \label field, has no target argument, or holds something that is not characters: a command, or a placeholder of a user definition’s template that was not expanded (chars_text). The text is not checked for the type:label spelling.
hyperref_args
The arguments of \hyperref, in order: the optional target label, then the text to display for it.
hyperref_element
The element value of every \hyperref node, shared as ref_element’s is for every \ref node.
hyperref_target
The target of a \hyperref node (the label written in the brackets) as characters with the whitespace around it trimmed, and the label when that text is spelled type:label.
label_anchor
The anchor formed from a label: <type>-<label>, each part through encode_anchor.
label_field
The \label field of label_fields_arg: repeatable, with one character-group argument named TARGET_ARG. A construct that accepts other fields beside \label lists this one among them in its own tack-on argument, which it declares under the name FIELDS_ARG so that label_uses reads it.
label_fields_arg
The trailing tack-on argument that a labeled construct declares as its last argument, so that \thing{…}\label{x:y} parses: one repeatable \label field with one character-group argument, under the names that label_uses reads (FIELDS_ARG, LABEL_FIELD, TARGET_ARG).
label_package
The scoped package LABEL_PACKAGE, declared by owner: one command, \label{type:label}, whose one character-group argument is named TARGET_ARG and whose element is named flm.field (field_element), so that its node is a field node named LABEL_FIELD, which label_use reads as it reads a tack-on \label.
label_use
Reads one \label node, wherever it is written (a field absorbed by a labeled element, the \label command the math feature declares inside a display-math environment’s body, or the command of the scoped package LABEL_PACKAGE): its text as written, its span, and the label when the text is spelled type:label. None when node is not a \label node, has no target argument, or holds something that is not characters (field_text).
label_uses
Every \label field written on node, in its FIELDS_ARG argument, in document order. Empty for a node with no such argument.
label_uses_in
Every \label node of nodes, in their order, read as label_uses reads the fields written on a node. A construct whose labels are written in a run of nodes of their own calls it: the content of an argument that refers to the scoped package LABEL_PACKAGE, such as the optional argument of \footnote. Every other node of the run is skipped; a construct that must refuse anything but labels in that argument looks for the other nodes itself.
lower_reference
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.
point_labels
Splits the \labels a construct read into the two lists a reference point holds: the labels spelled type:label, in the order they were written, and the texts that are not, each with the span to report it at and its position in the whole list.
ref_args
The arguments of \ref, in order: the key-value options, then the target label. A feature declaring a reference-like command of its own can reuse this list.
ref_display_options
A \ref node’s display options, read from its key-value options argument: a key other than NO_PREFIX_KEY requests the wording variant of its own name (the last such key wins), and NO_PREFIX_KEY leaves out the word before a number. An absent or unreadable argument gives the default options.
ref_element
The element value of every \ref node. It is one shared value, like the label field’s, so that no caller can create a second element value of type flm.ref (an element is identified by its value, not by its name).
ref_targets
The targets of a \ref node, in the order they were written: its target argument read as characters and split at the commas (split_targets).
reference_targets
The targets of node when it is a \ref or a \hyperref: ref_targets for a \ref, the one target of hyperref_target for a \hyperref, and None for any other node.
split_targets
The targets written in the text of a reference’s target argument: the text split at the commas, each part trimmed and parsed as a label.
title_anchor
The anchor formed from a title, for an unlabeled heading: <prefix>--<title>, each part through encode_anchor.
value_anchor
The anchor formed from the number the document gave a point: <prefix>-<numbers>, as in theorem-2-3.
value_of
Copies nodes into a synthesized value under the recursion guard policy guard, as content of the document shown a second time (ValueContent::Shown): the content that a reference shows of the point it designates. anchor is a node of the tree that holds nodes (usually the node that carries the point); nodes must belong to anchor’s tree, and when nodes is empty, the copy’s root takes its span and parsing state from anchor. It calls copy_run_into_value.