flm_core/stdlib/features/numbering/mod.rs
1//! The `numbering` feature: counters, counter styles, and the number that
2//! every numbered reference point of a document carries; and the functions
3//! that write a counter value as content, which a caller may use without the
4//! feature.
5//!
6//! A **counter** ([`CounterDecl`]) is a dotted name under which things are
7//! counted in document order, declared by a feature together with the counter
8//! it is numbered within; its value at a reference point is a number with
9//! optional sub-numbers ([`CounterValue`]). A **counter style**
10//! ([`CounterStyleDecl`]) says how a counter value is shown: `(3)`, `Eq.~(3)`,
11//! `2.13`, `Eqs.~(1–3 and 7)`. A **reference point**
12//! ([`RefPoint`](crate::model::aspects::RefPoint)) is one place in a document
13//! that can be referred to, numbered, or given an anchor; a point that is to
14//! carry a number states its **number source**
15//! ([`NumberSource`](crate::model::aspects::NumberSource)): the counter it
16//! counts in and the counter style its number is shown in. The concepts
17//! overview presents these terms together ([counters and counter
18//! styles](crate::guide::concepts_overview#counters-and-counter-styles);
19//! [reference points, labels and
20//! anchors](crate::guide::concepts_overview#reference-points-labels-and-anchors)),
21//! and the [numbering guide](crate::guide::numbering) describes the mechanism
22//! for the author of a document and of an extension.
23//!
24//! # What the feature provides to an author of documents
25//!
26//! The numbering feature declares no command and no environment. It numbers
27//! the constructs that other features declare as numbered — headings, the
28//! lines of display mathematics, theorems, list items, floats, and the
29//! footnotes and other notes of the [`xnotes`](crate::stdlib::features::xnotes)
30//! feature — and the number such a construct shows, beside itself
31//! and in every reference to it, is written from the counter value this
32//! feature records.
33//!
34//! A document changes the numbering through its numbering options
35//! ([`NumberingOptions`]). For each counter, the options say which counter it
36//! is numbered within (the equations within the sections, so that an equation
37//! reads `(2.13)`), or that it is numbered within nothing, and the value the
38//! counter has before it is first advanced (the value `0` for the sections
39//! makes a subsection written before the first section read `0.1`). Whether a
40//! construct is numbered at all is decided by the feature that owns the
41//! construct (the headings feature's numbering depth, the mathematics
42//! feature's switch for numbered equations), never by this feature.
43//!
44//! # What the feature provides to the pipeline
45//!
46//! The `numbering` feature ([`Numbering`], an
47//! [`FlmFeature`](crate::core::registry::FlmFeature)) registers the following
48//! into the registry:
49//!
50//! - **Five service slots**, through which other features declare what is
51//! numbered and how. A service slot is the declaration, by the feature that
52//! owns an interaction, of a dotted name, the type of the values the slot
53//! takes and its arity ([`services`](crate::core::services)); each of these
54//! five takes any number of values, in contribution order:
55//! - the service slot `flm.numbering.counters` ([`COUNTERS_SLOT`]) takes the
56//! counters ([`CounterDecl`]);
57//! - `flm.numbering.styles` ([`STYLES_SLOT`]) takes the counter styles
58//! ([`CounterStyleDecl`]);
59//! - `flm.numbering.within-joiners` ([`WITHIN_JOINERS_SLOT`]) takes the
60//! within-joiners registered by name ([`WithinJoinerDecl`]);
61//! - `flm.numbering.number-writers` ([`NUMBER_WRITERS_SLOT`]) takes the
62//! number writers ([`NumberWriterDecl`]);
63//! - `flm.numbering.parent-sets` ([`PARENT_SETS_SLOT`]) takes the parent
64//! sets ([`ParentSetDecl`]).
65//!
66//! A feature contributes to these service slots with
67//! [`FeatureBuilder::peer_slot`](crate::core::registry::FeatureBuilder::peer_slot),
68//! a peer declaration ([`PeerName`](crate::core::registry::PeerName)) of
69//! the service slot: in a registry without the numbering feature, the
70//! value is dropped with one Note and the contributing feature still
71//! registers ([services and service
72//! slots](crate::guide::concepts_overview#services-and-service-slots)).
73//! - **The stage [`NUMBER`]** (`flm.numbering.number`), the only stage of the
74//! library that advances a counter. It runs once per document: it reads
75//! every reference point of the document in document order from the table
76//! `flm.refpoints`
77//! ([`REFPOINTS`](crate::stdlib::features::refpoints::REFPOINTS)), reads the
78//! numbering options, and writes the counter table. Its behavior is
79//! described below, under "What the stage does with a document".
80//! - **The counter table [`COUNTERS`]** (`flm.counters`, a [`Counters`]). For
81//! every reference point the stage read, the table holds a
82//! [`CounterRecord`] (the counter, its value, the counters it is numbered
83//! within with their values, the counter style) or nothing for a point that
84//! is not numbered. A record holds a value and never text: a lowering rule
85//! writes the number where it shows it, with [`Counters::format`],
86//! [`Counters::format_in_style`] or [`Counters::format_many`], and splices
87//! the resulting [`NumberSegment`]s with
88//! [`Lowerer::splice`](crate::core::lowering::Lowerer::splice). The table
89//! also carries every declared counter style, compiled ([`Counters::style`]).
90//! - **The option type [`NumberingOptions`]**, bound on the document; a render
91//! request may set it again, and its value then replaces the document's for
92//! that render ([`Bind::Either`](crate::model::options::Bind::Either)).
93//! - **The configuration [`NumberingConfig`]**, the counter styles a host
94//! replaces by name. It is the feature's configuration, fixed when the
95//! registry is built ([settings, options and
96//! configuration](crate::guide::concepts_overview#settings-options-and-configuration)),
97//! and it is how a host changes what a number looks like without writing a
98//! feature. The settings keys are the fields of [`NumberingConfig`]
99//! (`styles`) and of [`NumberingOptions`] (`counters`)
100//! ([`settings`](crate::core::settings)).
101//!
102//! The feature registers no element and no lowering rule, so it has no rule
103//! on any backend. The number of a construct is shown by the lowering rules of
104//! the feature that owns the construct, on every backend, through the counter
105//! table.
106//!
107//! ## Checks made when the registry is built
108//!
109//! The feature reads its five service slots once every feature has
110//! registered, and each of the following mistakes fails the registry build,
111//! with a message that gives the name concerned:
112//!
113//! - two declarations of one counter, counter style, parent set, within-joiner
114//! or number writer;
115//! - a counter or a parent set whose name begins with `_`
116//! ([`RESERVED_PREFIX`]);
117//! - a counter whose default counter style no feature declares;
118//! - a counter numbered within a counter no feature declares, within a parent
119//! set no feature registers, or within an empty list of counters;
120//! - a parent set that holds a counter no feature declares;
121//! - counters numbered within each other, through any of a counter's parents;
122//! - a counter numbered within another through a within-joiner that no
123//! feature registers, a nesting joiner that no feature registers, and a
124//! counter style written by a number writer that no feature registers;
125//! - a text of a counter style, of a within-joiner or of a nesting joiner that
126//! is not valid FLM or does not compile;
127//! - a within-joiner or a nesting joiner that writes a counter which, under
128//! one of the chains of counters the counter may be numbered within, is not
129//! in that chain;
130//! - a replacement in [`NumberingConfig`] for a counter style that no feature
131//! declares.
132//!
133//! The registry build compiles these texts once, through the feature's build
134//! hook ([`LateInit`](crate::core::registry::LateInit)), which runs once the
135//! language that documents are parsed with is built; nothing is parsed again
136//! while a number is written.
137//!
138//! ## What the stage does with a document
139//!
140//! - **The options are applied first.** Before it reads any reference point,
141//! the stage applies the document's numbering options to the declared
142//! hierarchy, and reports every option it cannot apply: a counter no
143//! feature declares ([`UnknownCounter`], a Warning), a parent set no feature
144//! registers ([`UnknownParentSet`]), a within-joiner that does not compile
145//! ([`BadWithinJoiner`]) or that no feature registers
146//! ([`UnknownWithinJoiner`]), counters numbered within each other
147//! ([`HierarchyCycle`]), and a within-joiner that writes a counter which,
148//! under the options, is not always one of the counters the counter is
149//! numbered within ([`NotAnAncestor`]).
150//! - **Every reference point that states a number source is numbered.** The
151//! stage reads the points in document order and advances the levels of the
152//! counter that each point's number source lists. A counter has no value
153//! until it is first advanced, or until the options give it an
154//! [`initial`](CounterOptions::initial) value; a point whose number needs an
155//! ancestor with no value is not numbered and is reported
156//! ([`ParentUninitialized`]), once per counter and run. Where a counter has
157//! several possible parents ([`Parents`]), the parent that applies at a
158//! point is the one advanced most recently in document order.
159//! - **A point that counts in a counter no feature declares is an error**
160//! ([`UndeclaredCounter`]), reported once per run and per counter name. A
161//! point that gives a counter asks to be numbered, so a registry that cannot
162//! number it is in error; a feature whose points may go unnumbered gives its
163//! configuration a switch under which those points give no counter. A point
164//! whose counter style no feature declares is an error at that point
165//! ([`UndeclaredStyle`]), because the counter is declared and the counter
166//! style asked for is a mistake. A point that would carry a sub-number its
167//! counter style has no format for is an error too ([`UndeclaredSubLevel`]).
168//! - **A point may count in a scoped instance of its counter.** A scoped
169//! instance is an independent sequence of the counter's values attached to
170//! an enclosing node, such as a list environment
171//! ([`NumberSource::instances`](crate::model::aspects::NumberSource::instances)).
172//! The stage keeps one count per instance; an instance nested in another is
173//! numbered within the enclosing instance's current value and written with
174//! the counter's nesting joiner ([`CounterDecl::nesting`]). Instances that
175//! do not enclose the point one within the next are an error
176//! ([`InstanceNotEnclosing`]).
177//! - **A point may carry a number template of its own**
178//! ([`NumberSource::number_format`](crate::model::aspects::NumberSource::number_format)).
179//! The stage compiles each distinct template text once per run and counter
180//! style, and records the point with a counter style derived from the
181//! declared one ([`CounterStyle::with_number_format`]). A template that does
182//! not compile is an error ([`BadNumberFormat`]), and the point is numbered
183//! in the declared counter style.
184//!
185//! Every diagnostic of the stage is an Error unless stated otherwise above.
186//!
187//! # Interactions with other features
188//!
189//! - The stage requires the table `flm.refpoints` of the
190//! [`refpoints`](crate::stdlib::features::refpoints) feature: a plan that
191//! schedules the stage in a registry without that feature fails. The stage
192//! reads nothing of the [`refs`](crate::stdlib::features::refs) feature, so
193//! a registry without references still numbers.
194//! - The [`headings`](crate::stdlib::features::headings),
195//! [`math`](crate::stdlib::features::math),
196//! [`lists`](crate::stdlib::features::lists),
197//! [`theorems`](crate::stdlib::features::theorems),
198//! [`floats`](crate::stdlib::features::floats) and
199//! [`xnotes`](crate::stdlib::features::xnotes) features declare their
200//! counters and counter styles into the service slots above, and their
201//! lowering rules read the counter table to show their numbers. The headings
202//! feature also contributes the parent set `flm.headings.levels`.
203//! - The [`refs`](crate::stdlib::features::refs) feature reads the counter
204//! table to write the number of a reference's target, and builds the anchor
205//! of a point whose anchor is derived from its number with
206//! [`identifier_text`].
207//! - Every text a counter style holds is FLM; number templates in the
208//! `Formats` form ([`NumberTemplate::Formats`]) and within templates are
209//! written in the template language that user definitions use ([the
210//! template language shared by
211//! features](crate::guide::concepts_overview#the-template-language-shared-by-features)).
212//!
213//! # Writing a counter value without the feature
214//!
215//! The functions that write a counter value hold no counter and count
216//! nothing, so a caller may use them on values of its own. A counter style
217//! declaration is compiled against the built language
218//! ([`CounterStyleDecl::compile`]) into a [`CounterStyle`]; [`format()`]
219//! writes one value with it and [`format_many`] writes several. Both return a
220//! list of [`Segment`]s, each a small tree of content with the position of the
221//! value it links to among the values the caller passed in, or none.
222//!
223//! ## What a counter style is made of
224//!
225//! - The **number template** ([`NumberTemplate`], the field `number_format`)
226//! says how the number itself is written: a text with a place for the
227//! number, which writes it in one of the eight number formats
228//! ([`NumberFormat`]). `#{arabic}.` writes `3.` for the number three, and
229//! the single-letter template `(a)` ([`NumberTemplate::Initial`]) writes
230//! `(c)`.
231//! - The **sub-levels** ([`SubLevelDecl`]) say how the sub-numbers of a value
232//! are written and what separates each from what comes before it. The value
233//! `(3, 2)` is written `3b` in a counter style whose first sub-level is
234//! written in letters with no separator.
235//! - The **prefix words** ([`PrefixWords`]) are the word before the number, in
236//! one form for a single number and one for several (`Eq.~`, `Eqs.~`), and
237//! optional named variants (`capital`: `Equation~`, `Equations~`).
238//! - The **delimiters** ([`Delimiters`]) are the texts around the number, such
239//! as `(` and `)`.
240//! - The **join texts** ([`JoinDecl`]) say how several numbers are written as
241//! one text, down to the word between the last two.
242//!
243//! Every one of these texts is FLM, and every one is parsed once, when the
244//! counter style is compiled.
245//!
246//! ## Numbering within another counter
247//!
248//! A counter may be numbered within another: an equation numbered within the
249//! sections is written `(2.13)`. The counter's [`Within`] declares both its
250//! parent (the counter whose advance restarts it) and its **within-joiner**,
251//! what is written of its ancestors before its own number, in one of four
252//! forms:
253//!
254//! - a **joining text**: `Within::parent("flm.headings.section")` writes the
255//! section's number and a full stop, and [`joined_by`](Within::joined_by)
256//! puts another text in place of the full stop;
257//! - a **within template** ([`template`](Within::template)): FLM text in
258//! which `#{flm.headings.section}` is the section's number in the section's
259//! own counter style, without word or delimiters. Markup may surround a
260//! substitution (`\textbf{#{flm.headings.section}}.`), and the keys in
261//! brackets of `#[Roman]{…}` and `#[bare]{…}` write the counter in a named
262//! [`NumberFormat`] and without its own ancestors;
263//! - **nothing** ([`displayed_bare`](Within::displayed_bare)): the counter
264//! still restarts under its parent, and its number is shown without its
265//! ancestors' numbers;
266//! - a **registered joiner** ([`joiner_named`](Within::joiner_named)): a
267//! [`WithinJoiner`] that a feature contributed to [`WITHIN_JOINERS_SLOT`],
268//! which writes what its code writes.
269//!
270//! The parent is one counter ([`Within::parent`]), any of several
271//! ([`Within::parents`]) or any counter of a named [`ParentSetDecl`]
272//! ([`Within::parent_set`]). Among several, the one advanced most recently in
273//! document order applies at a point, and a within template writes it as
274//! `#{_parent}`. [`no_restart`](Within::no_restart) writes the parent's number
275//! without letting the parent restart the count.
276//!
277//! An ancestor is written together with its own ancestors, so a within-joiner
278//! refers only to the counter immediately above: a theorem numbered within the
279//! subsections, which are numbered within the sections, is joined to
280//! `flm.headings.subsection` alone and is written `2.3.4`.
281//!
282//! A compiled within-joiner returns a list of [`Part`]s, written in order
283//! before the point's own number, which is never inside a part. Each part
284//! lists the ancestors it shows, so a caller writing several numbers at once
285//! can find which parts two numbers share. A joining text gives one part per
286//! ancestor; a within template gives one part per substitution, with the text
287//! after it; a registered joiner gives what its code gives.
288//!
289//! A caller passes the within-joiner and the ancestors together as a
290//! [`Parent`]; each ancestor is an [`Ancestor`] carrying its own value,
291//! counter style and within-joiner. The ancestors are the whole chain,
292//! outermost first, and the order tells which counters each ancestor may
293//! itself be written within. [`parts`] returns the parts alone, without a
294//! number around them.
295//!
296//! ## The number writer
297//!
298//! A counter style says what a number is made of; the **number writer** puts
299//! those texts and numbers together into the content a reader sees. The
300//! **default writer** writes every counter style that asks for no other
301//! writer:
302//!
303//! - for one value: the word, the opening delimiter, the parts, the number
304//! with its sub-numbers, and the closing delimiter;
305//! - for several values of one counter style: the values grouped by the
306//! counters they are numbered within, each group sorted, its consecutive
307//! values collapsed into ranges, and the runs joined by the counter style's
308//! join texts. The end of a range is written without the parts and without
309//! the leading components it shares with the start, unless the range holds
310//! exactly two consecutive values or the counter style repeats them, and a
311//! range never spans two groups.
312//!
313//! A feature may register another writer, as it registers a within-joiner:
314//! [`NumberWriter`] is the declaration and [`CompiledNumberWriter`] what it
315//! compiles to, with one entry point for one value and one for several values
316//! of one counter style. A [`NumberWriterDecl`] goes into
317//! [`NUMBER_WRITERS_SLOT`], and a counter style asks for the writer by name
318//! with [`with_number_writer`](CounterStyleDecl::with_number_writer). A writer
319//! receives each value as a [`NumberedValue`], with the caller's
320//! [`FormatOptions`], a [`WriteCx`] (the counter style's data, the library's
321//! operations, and [`parts`](WriteCx::parts), which runs a value's
322//! within-joiner when asked and keeps the result for the rest of the call), and
323//! a [`NumberOut`] to which it appends content or characters, each marked with
324//! the value it links to or with none. [`WriteCx::default_one`] and
325//! [`WriteCx::default_many`] write what the default writer would, so a writer
326//! can add to that text instead of repeating it.
327//!
328//! # Map of the items
329//!
330//! - The feature: [`Numbering`], [`feature()`], [`FEATURE`],
331//! [`NumberingConfig`]; the options [`NumberingOptions`], [`CounterOptions`],
332//! [`WithinOption`]; the stage name [`NUMBER`].
333//! - Declarations: [`CounterDecl`], [`Within`], [`Parents`],
334//! [`WithinJoinerSpec`], [`ParentSetDecl`]; the service slot names
335//! [`COUNTERS_SLOT`], [`STYLES_SLOT`], [`WITHIN_JOINERS_SLOT`],
336//! [`NUMBER_WRITERS_SLOT`], [`PARENT_SETS_SLOT`]; [`RESERVED_PREFIX`],
337//! [`PARENT_PLACEHOLDER`].
338//! - Counter styles: [`CounterStyleDecl`] with [`NumberTemplate`],
339//! [`NumberFormat`], [`SubLevelDecl`], [`PrefixWords`], [`PluralWords`],
340//! [`Delimiters`], [`JoinDecl`]; the compiled [`CounterStyle`];
341//! [`StyleError`].
342//! - Writing values: [`CounterValue`], [`format()`], [`format_many`],
343//! [`parts`], [`FormatOptions`], [`Segment`], [`Ancestor`], [`Parent`],
344//! [`FormatError`], [`identifier_text`].
345//! - Within-joiners: [`WithinJoiner`], [`WithinJoinerDecl`],
346//! [`CompiledWithinJoiner`], [`Part`], [`WithinCx`], [`JoinCx`].
347//! - Number writers: [`NumberWriter`], [`NumberWriterDecl`],
348//! [`CompiledNumberWriter`], [`NumberedValue`], [`NumberOut`], [`WriteCx`],
349//! [`WriterCx`], [`JoinText`].
350//! - The counter table: [`COUNTERS`], [`Counters`], [`CounterRecord`],
351//! [`NumberSegment`], [`ManyNumbers`].
352//! - The stage's diagnostic conditions: [`UnknownCounter`],
353//! [`UndeclaredCounter`], [`UndeclaredStyle`], [`UndeclaredSubLevel`],
354//! [`ParentUninitialized`], [`UnknownParentSet`], [`NotAnAncestor`],
355//! [`HierarchyCycle`], [`BadWithinJoiner`], [`UnknownWithinJoiner`],
356//! [`InstanceNotEnclosing`], [`BadNumberFormat`], [`StageFailed`].
357//!
358//! # Examples
359//!
360//! One equation number, with the word and the delimiters the counter style
361//! declares. The text a segment holds is read back here with the source
362//! recomposer ([`recompose_source`](crate::stdlib::backends::pres::read::recompose_source)),
363//! which writes content back as the FLM it was parsed from.
364//!
365//! ```
366//! use flm_core::lang::{build_language, LangInputs};
367//! use flm_core::stdlib::backends::pres::read::recompose_source;
368//! use flm_core::stdlib::features::numbering::{
369//! format, CounterStyleDecl, CounterValue, Delimiters, FormatOptions, NumberTemplate,
370//! PrefixWords, Segment,
371//! };
372//!
373//! /// The FLM source a list of segments writes, segment by segment.
374//! fn written(segments: &[Segment]) -> String {
375//! segments
376//! .iter()
377//! .map(|segment| {
378//! let nodes: Vec<_> = segment.content().root().children().iter().collect();
379//! recompose_source(&nodes)
380//! })
381//! .collect()
382//! }
383//!
384//! let lang = build_language(LangInputs::new());
385//!
386//! let mut decl = CounterStyleDecl::new("example.style.equation");
387//! decl.number_format = NumberTemplate::formats("#{arabic}");
388//! decl.delimiters = Delimiters::new("(", ")");
389//! decl.prefix_words = PrefixWords::new("Eq.~", "Eqs.~");
390//! let style = decl.compile(&lang).expect("the style compiles");
391//!
392//! let segments = format(&CounterValue::new(13), &style, None, &FormatOptions::new())?;
393//! assert_eq!(written(&segments), "Eq.~(13)");
394//!
395//! // Without the word, and without the delimiters.
396//! let bare = FormatOptions::new().without_word().without_delimiters();
397//! let segments = format(&CounterValue::new(13), &style, None, &bare)?;
398//! assert_eq!(written(&segments), "13");
399//! # Ok::<(), flm_core::stdlib::features::numbering::FormatError>(())
400//! ```
401//!
402//! Several numbers at once: they are sorted, consecutive ones are collapsed
403//! into a range, and the word takes its plural form.
404//!
405//! ```
406//! # use flm_core::lang::{build_language, LangInputs};
407//! # use flm_core::stdlib::backends::pres::read::recompose_source;
408//! # use flm_core::stdlib::features::numbering::{
409//! # format_many, CounterStyleDecl, CounterValue, Delimiters, FormatOptions,
410//! # JoinDecl, NumberedValue, PrefixWords, Segment,
411//! # };
412//! # fn written(segments: &[Segment]) -> String {
413//! # segments.iter().map(|segment| {
414//! # let nodes: Vec<_> = segment.content().root().children().iter().collect();
415//! # recompose_source(&nodes)
416//! # }).collect()
417//! # }
418//! # let lang = build_language(LangInputs::new());
419//! let mut decl = CounterStyleDecl::new("example.style.equation");
420//! decl.delimiters = Delimiters::new("(", ")");
421//! decl.prefix_words = PrefixWords::new("Eq.~", "Eqs.~");
422//! decl.join = JoinDecl::compact();
423//! let style = decl.compile(&lang).expect("the style compiles");
424//!
425//! let values = [
426//! CounterValue::new(2),
427//! CounterValue::new(9),
428//! CounterValue::new(1),
429//! CounterValue::new(3),
430//! ];
431//! let written_values: Vec<NumberedValue<'_>> = values.iter().map(NumberedValue::new).collect();
432//! let segments = format_many(&style, &written_values, &FormatOptions::new())?;
433//! assert_eq!(written(&segments), "Eqs.~(1–3,9)");
434//! # Ok::<(), flm_core::stdlib::features::numbering::FormatError>(())
435//! ```
436
437mod decl;
438mod feature;
439mod formats;
440mod joiner;
441mod many;
442mod options;
443mod stage;
444mod style;
445mod table;
446mod template;
447mod value;
448mod writer;
449
450pub use decl::{
451 CounterDecl, ParentSetDecl, Parents, Within, WithinJoinerSpec, COUNTERS_SLOT,
452 NUMBER_WRITERS_SLOT, PARENT_PLACEHOLDER, PARENT_SETS_SLOT, RESERVED_PREFIX, STYLES_SLOT,
453 WITHIN_JOINERS_SLOT,
454};
455pub use joiner::{
456 CompiledWithinJoiner, JoinCx, Part, WithinCx, WithinJoiner, WithinJoinerDecl,
457};
458pub use writer::{
459 CompiledNumberWriter, JoinText, NumberOut, NumberWriter, NumberWriterDecl, NumberedValue,
460 WriteCx, WriterCx,
461};
462pub use feature::{feature, Numbering, NumberingConfig, FEATURE};
463pub(crate) use feature::digest_style;
464pub use formats::{NumberFormat, NumberTemplate};
465pub use many::format_many;
466pub use options::{CounterOptions, NumberingOptions, WithinOption};
467pub use style::{
468 format, parts, Ancestor, CounterStyle, CounterStyleDecl, Delimiters, FormatError, FormatOptions,
469 JoinDecl, Parent, PluralWords, PrefixWords, Segment, StyleError, SubLevelDecl,
470};
471pub use stage::{
472 BadNumberFormat, BadWithinJoiner, HierarchyCycle, InstanceNotEnclosing, NotAnAncestor, ParentUninitialized,
473 StageFailed, UndeclaredCounter, UndeclaredStyle, UndeclaredSubLevel, UnknownCounter,
474 UnknownParentSet, UnknownWithinJoiner, NUMBER,
475};
476pub use table::{CounterRecord, Counters, ManyNumbers, NumberSegment, COUNTERS};
477pub(crate) use style::{list_shape, CompiledJoin, ListPiece};
478pub(crate) use template::{
479 compile_text, instantiate_fixed, instantiate_template, number_vocabulary, occurrences_of, parse_keys,
480 AncestorKeys, Binding, Bindings,
481};
482pub use value::{identifier_text, CounterValue};