pub struct ListsConfig {
pub environments: BTreeMap<Name, ListKind>,
}Expand description
The configuration of the Lists feature: the list
environments, each environment’s name mapped to its list kind
(ListKind).
The default (ListsConfig::new) declares three list kinds:
| environment | numbered | labels by depth | reference templates by depth |
|---|---|---|---|
itemize | no | •, -, ▸ | ignored: a reference shows the label |
enumerate | yes | #{arabic}., (#{roman}), #{alph}- | #{arabic}, (#{roman}), #{alph} |
description | no | none: every item carries its term as a tag | ignored: a reference shows the tag |
An enumerate therefore shows 1., 2. beside its items, a list
nested in one of its items (i), (ii), and a list nested one level
deeper a-, b-, while references to those items show Item~2,
Item~(ii), Item~b. A program that embeds the library declares other
list kinds, or changes these, through the same type:
use flm_core::stdlib::features::lists::{ListKind, ListsConfig};
let config = ListsConfig::new()
.environment("steps", ListKind::numbered(["Step #{arabic}:"]))
.environment("itemize", ListKind::unnumbered(["--"]));
assert!(config.kind("steps").is_some_and(|kind| kind.numbered));
assert_eq!(config.kind("itemize").and_then(|kind| kind.label_at(1)), Some("--"));
assert_eq!(config.environments.len(), 4);Lists::new takes the value, and the standard
package carries it as
StdlibConfig::lists. It is the
feature’s configuration (see
configuration):
fixed when the registry is built, before any document is parsed, because
the environments are part of the parsing language the registry builds
(BuiltLang) and the counters and counter
styles the feature declares depend on it. The feature therefore feeds
digest_bytes into the registry digest, the
fingerprint that decides whether a cached result may be reused, as every
feature whose declarations depend on its configuration must.
The registry build checks the configuration and fails on:
- an environment name that is empty or holds whitespace, a brace, a
backslash or a
%(ListsConfig::validate); - an environment name that is one of the kind tokens a presentation list
reserves (
LIST_RESERVED_KINDS;validate); - a numbered list kind with no label template or no reference template
(
validate); - once the parsing language is built, a label template, or a numbered list kind’s reference template, that is not valid in the template language, and a label template of an unnumbered list kind that writes a number format.
Fields§
§environments: BTreeMap<Name, ListKind>The list kinds, by environment name.
Implementations§
Source§impl ListsConfig
impl ListsConfig
Sourcepub fn new() -> ListsConfig
pub fn new() -> ListsConfig
The shipped configuration: the list kinds itemize, enumerate and
description (see the type’s documentation).
Sourcepub fn empty() -> ListsConfig
pub fn empty() -> ListsConfig
A configuration declaring no list environment at all.
Sourcepub fn environment(self, name: impl Into<Name>, kind: ListKind) -> ListsConfig
pub fn environment(self, name: impl Into<Name>, kind: ListKind) -> ListsConfig
Builder: declares the list environment name with the list kind
kind, replacing the list kind already declared under that name, if
any.
Sourcepub fn kind(&self, name: &str) -> Option<&ListKind>
pub fn kind(&self, name: &str) -> Option<&ListKind>
The list kind of the list environment name, if one is declared.
Sourcepub fn validate(&self) -> Result<(), String>
pub fn validate(&self) -> Result<(), String>
Checks the parts of the configuration that can be checked before the
registry’s parsing language (BuiltLang) is
built. The feature calls it when it registers, and a
failure fails the registry build.
§Errors
A sentence describing the first problem found: an environment name
that is empty or holds whitespace, a brace, a backslash or a %; an
environment name that is one of the kind tokens a presentation list
reserves (LIST_RESERVED_KINDS); a numbered list kind with no label
template or no reference template.
Sourcepub fn digest_bytes(&self) -> Vec<u8> ⓘ
pub fn digest_bytes(&self) -> Vec<u8> ⓘ
The bytes that represent the configuration in the registry digest;
the type’s Hash implementation hashes the same bytes.
Every list kind is written in the order of its name: its name, whether
it is numbered, its label templates, its reference templates and its
nesting joiner, each text preceded by its length. Two configurations
therefore give the same bytes exactly when they are equal. Two
configurations that differ only in an unnumbered list kind’s reference
templates, which have no effect, still give different bytes: a digest
that differs without need only prevents the reuse of a cached result,
and never gives a wrong one. The bytes are written field by field
rather than taken from the type’s Debug output, which would change
with a field rename and silently change every registry digest.
Trait Implementations§
Source§impl Clone for ListsConfig
impl Clone for ListsConfig
Source§impl Debug for ListsConfig
impl Debug for ListsConfig
Source§impl Default for ListsConfig
impl Default for ListsConfig
Source§fn default() -> ListsConfig
fn default() -> ListsConfig
Source§impl<'de> Deserialize<'de> for ListsConfigwhere
ListsConfig: Default,
impl<'de> Deserialize<'de> for ListsConfigwhere
ListsConfig: Default,
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for ListsConfig
Source§impl Hash for ListsConfig
impl Hash for ListsConfig
Source§impl JsonSchema for ListsConfig
impl JsonSchema for ListsConfig
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read moreSource§impl PartialEq for ListsConfig
impl PartialEq for ListsConfig
impl StructuralPartialEq for ListsConfig
Auto Trait Implementations§
impl Forget for ListsConfig
impl Freeze for ListsConfig
impl Move for ListsConfig
impl RefUnwindSafe for ListsConfig
impl Send for ListsConfig
impl Sync for ListsConfig
impl Unpin for ListsConfig
impl UnsafeUnpin for ListsConfigwhere
*const LeafNode<Name, ListKind> is !null: UnsafeUnpin,
PhantomData<(Owned, LeafOrInternal)>: UnsafeUnpin,
PhantomData<Box<(Name, ListKind)>>: UnsafeUnpin,
impl UnwindSafe for ListsConfig
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,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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