pub struct NumberSource {
pub counter: Name,
pub instances: Vec<NodeId>,
pub style: Name,
pub advance: Vec<u32>,
pub number_format: Option<String>,
}Expand description
What a reference point is numbered by: the counter it counts in, the counter style its number is shown in, the scoped instances it counts under, the levels of the counter it advances, and optionally a number template of its own.
A counter is a dotted name under which things are counted in document
order (CounterDecl),
and a counter style says how a counter value is shown
(CounterStyleDecl). A
point that is to carry a number gives a number source in
RefPoint::number, and the numbering feature
(numbering) numbers every point
that gives one; no setting of the numbering feature turns numbering off for
a point. A point that is not to
carry a number gives none: a line of an equation* environment, a heading
written with a star, a heading of a kind that the headings configuration
does not number. The element decides from the node and from its feature’s
configuration, fixed when the registry was built, since an aspect reads no
option; the same document is therefore numbered the same way on every
output.
The counter and the counter style are given by name. A point that gives a counter or a counter style that no feature declares is reported by the numbering stage, not here.
§Scoped instances
A point may count in a scoped instance of its counter rather than in
the counter’s single sequence through the document. A scoped instance is an
independent sequence of the counter’s values attached to a node, usually
the environment the point is written in, and it covers exactly that node’s
content: two sibling environments are two instances, and each starts again
from the counter’s initial value. The point lists the instances it counts
under in instances, outermost first, the last
being its own. An instance inside another is numbered within the current
value of the enclosing instance, so the item of a nested list reads 2.(b)
or (b) depending on what the counter writes for its enclosing levels. The
numbering guide describes the whole mechanism.
Fields§
§counter: NameThe name of the counter the point counts in, such as
flm.headings.section or flm.math.equation. The feature that
declares the counter owns its name; points of several reference kinds,
from any feature, may count in one counter.
instances: Vec<NodeId>The scoped instances of the counter that the point counts under, outermost first: nodes of the tree of the node the aspect was asked about, which contain the point’s node and each hold one sequence of the counter’s values. The last is the point’s own instance; each one encloses the next. Empty for a point that counts in the counter’s single sequence through the document, as nearly every point does.
Each instance must be a node that contains the point’s node (never the
node that carries the point itself) and must enclose the next instance;
otherwise the point is not numbered and the numbering stage reports the
Error flm.numbering.instance-not-enclosing. An instance is given by
its node’s identifier, as in ContentRef::Node, because an aspect is
given a node of one tree and not the tree’s place in the document; the
numbering stage records the instance as the full NodeAddr of that
node.
style: NameThe name of the counter style the point’s number is shown in, which gives the number format, the word before the number and the delimiters.
advance: Vec<u32>Which levels of the counter this point advances, in the order it advances them.
A counter value is a number with optional sub-numbers: level 0 is the
number, level 1 the first sub-number, and advancing a level resets the
deeper levels to zero. Most points advance [0] and show (3), then
(4). A group of sub-numbered lines is written by advancing two levels
at once on the first line and the deeper level alone on the rest: the
first line advances [0, 1] and shows (3a), the lines after it
advance [1] and show (3b), (3c), and the next equation advances
[0] and shows (4).
number_format: Option<String>A number template of the point’s own, or None to use the number
format of the counter style (style) as
declared.
The text is a number template
(NumberTemplate):
every #{name} is the number in the format name (#{arabic},
#{alph}, #{roman}, …), every other character is written as given,
and markup may surround the number: (#{alph}), #{Roman}.. The text
is the author’s input, like the text of a \tag; for example, a list’s
reference template written ref=(#{alph}), or label=(#{alph}) alone.
The aspect passes it on as written, without compiling it, since an
aspect has no language to compile it with. The numbering stage compiles
each distinct text once per run and per counter style, and records the
point in the counter style style with its
number format replaced by this template, so that the point’s number and
every reference to it use the template: (b), Item~(b). A template
that does not compile is reported as the Error
flm.numbering.bad-number-format, and the point is numbered with the
counter style as declared.
Trait Implementations§
Source§impl Clone for NumberSource
impl Clone for NumberSource
Source§impl Debug for NumberSource
impl Debug for NumberSource
impl Eq for NumberSource
Source§impl Hash for NumberSource
impl Hash for NumberSource
Source§impl PartialEq for NumberSource
impl PartialEq for NumberSource
impl StructuralPartialEq for NumberSource
Auto Trait Implementations§
impl Forget for NumberSource
impl Freeze for NumberSource
impl Move for NumberSource
impl RefUnwindSafe for NumberSource
impl Send for NumberSource
impl Sync for NumberSource
impl Unpin for NumberSource
impl UnsafeUnpin for NumberSource
impl UnwindSafe for NumberSource
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
Source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
Source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
Source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more