pub struct CounterStyle { /* private fields */ }Expand description
A counter style compiled against the built language: what a number is written with.
It is built from a CounterStyleDecl by
compile or
compile_with, holds the parsed form of
every text of the declaration and the compiled number writer, and is
passed to format() and format_many. The counter
table holds the compiled counter styles of a registry
(Counters::style).
Implementations§
Source§impl CounterStyle
impl CounterStyle
Sourcepub fn warnings(&self) -> &[FlmDiagnostic]
pub fn warnings(&self) -> &[FlmDiagnostic]
Returns the diagnostics that the counter style’s texts raised when they were parsed. None of them is an error, since a text that parses with an error is refused instead. The numbering feature adds them to the registry’s build diagnostics.
Sourcepub fn with_number_format(
&self,
template: &NumberTemplate,
lang: &BuiltLang,
language: &TemplateLanguage,
) -> Result<CounterStyle, StyleError>
pub fn with_number_format( &self, template: &NumberTemplate, lang: &BuiltLang, language: &TemplateLanguage, ) -> Result<CounterStyle, StyleError>
Returns a derived counter style: this counter style with its number
format replaced by template, with the same name, sub-levels, words,
delimiters, join texts, choices and number writer.
Only template is compiled; every other part is shared with this
counter style. The numbering stage uses it for a point that carries a
number template of its own
(NumberSource::number_format):
the point’s record holds the derived counter style, so that the point’s
number and every reference to it are written in it. The lists feature
also writes an item’s label through a derived counter style
(Counters::format_in_style). The
warnings of the derived counter style are
this counter style’s, followed by those template raised.
§Errors
The StyleError of a template that does not compile, as
CounterStyleDecl::compile_with reports it for a declaration’s
number template.
Sourcepub fn declares_variant(&self, name: &str) -> bool
pub fn declares_variant(&self, name: &str) -> bool
Returns whether the counter style declares the variant name of the
prefix words (PrefixWords::variants).
A number asked for in a variant the counter style does not declare is written with the default words; a caller that reports such a request, as the refs feature does, checks it with this method.
Sourcepub fn sub_level_count(&self) -> usize
pub fn sub_level_count(&self) -> usize
Returns how many sub-levels the counter style declares: the depth of the deepest sub-number it can write, counting the first sub-level as 1.
A value that carries a non-zero sub-number deeper than that cannot be written in this counter style; the numbering stage checks this when it makes a record, not when the number is shown.
Sourcepub fn literal(&self, text: &str) -> Result<Arc<NodeTree<Flm>>, FormatError>
pub fn literal(&self, text: &str) -> Result<Arc<NodeTree<Flm>>, FormatError>
Returns text as a small tree of content, built as the characters of
a number are: one text node attributed to the counter style’s source.
A caller that writes several numbers itself builds the text between two of them with this method: everything a reader sees is content, not characters, and this module provides the only way to build content from computed characters. The call runs on a worker thread.
§Errors
FormatError::NestingTooDeep or FormatError::Failed when the
content could not be built.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for CounterStyle
impl !UnwindSafe for CounterStyle
impl Forget for CounterStyle
impl Freeze for CounterStyle
impl Move for CounterStyle
impl Send for CounterStyle
impl Sync for CounterStyle
impl Unpin for CounterStyle
impl UnsafeUnpin for CounterStyle
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> 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