pub struct QuoteConfig {
pub environments: BTreeMap<String, QuoteEnvironment>,
}Expand description
The configuration of the Quote feature: the quote
environments, each environment’s name mapped to its QuoteEnvironment.
The default (QuoteConfig::new) declares three environments:
| environment | quotation-section commands | bare content read as |
|---|---|---|
quote | \text, \lines, \attributed, \block | an error |
blockquote | none | one block section |
address | none | one lines section |
A host declares others, or changes these, through the same type:
use flm_core::stdlib::features::quote::{QuoteConfig, QuoteEnvironment, QuoteSection};
let config = QuoteConfig::new()
.environment("epigraph", QuoteEnvironment::new([QuoteSection::Text, QuoteSection::Attributed]))
.environment("aside", QuoteEnvironment::new([]).bare(QuoteSection::Block));
assert_eq!(config.environments.len(), 5);
assert!(config.validate().is_ok());The value is what Quote::new takes; a host using
the standard features passes it with
StdlibConfig::quote. The
configuration is fixed when the registry is built, before any document is
parsed
(configuration),
because the environments and their quotation-section commands are part of
the language. The feature therefore feeds
digest_bytes into the registry
digest, the number that changes whenever something
about the registry that can change what processing produces changes
(FeatureBuilder::digest_input).
The feature checks the configuration when the registry is built
(validate), and the registry build fails, with
a message that identifies the environment, on any of these: a name that
is empty or holds whitespace, a brace, a backslash or %; a name equal to
one of the kind tokens a presentation list reserves (LIST_RESERVED_KINDS), since an
environment’s name becomes the kind token of the block it is staged as;
and an environment that accepts no quotation-section command and reads no
bare content. A name that another feature also declares, such as itemize
or theorem, makes the registry build fail as any two declarations of one
name do.
The configuration refers to no backend, HTML tag or stylesheet: the lowering rules and stylesheets of each backend decide how a quotation is presented.
Fields§
§environments: BTreeMap<String, QuoteEnvironment>The quote environments, by name.
Implementations§
Source§impl QuoteConfig
impl QuoteConfig
Sourcepub fn new() -> QuoteConfig
pub fn new() -> QuoteConfig
Returns the default configuration: the environments quote,
blockquote and address (see the table above).
Sourcepub fn empty() -> QuoteConfig
pub fn empty() -> QuoteConfig
Returns a configuration that declares no quote environment. The feature then registers no quote environment, no quotation-section command and no lowering rule.
Sourcepub fn environment(
self,
name: impl Into<String>,
environment: QuoteEnvironment,
) -> QuoteConfig
pub fn environment( self, name: impl Into<String>, environment: QuoteEnvironment, ) -> QuoteConfig
Builder: declares the environment name as environment, replacing
any environment of that name, and returns the configuration.
Sourcepub fn without_environment(self, name: &str) -> QuoteConfig
pub fn without_environment(self, name: &str) -> QuoteConfig
Builder: removes the environment name, if there is one, and returns
the configuration.
Sourcepub fn get(&self, name: &str) -> Option<&QuoteEnvironment>
pub fn get(&self, name: &str) -> Option<&QuoteEnvironment>
Returns the environment name, or None when none is declared.
Sourcepub fn validate(&self) -> Result<(), String>
pub fn validate(&self) -> Result<(), String>
Checks the configuration, as the feature does when it registers.
§Errors
Returns a sentence that states the first problem found: an environment
name that is empty or holds whitespace, a brace, a backslash or the
comment character %; a name equal to one of the kind tokens a
presentation list reserves (LIST_RESERVED_KINDS); an environment
that accepts no quotation-section command and reads no bare content.
Sourcepub fn digest_bytes(&self) -> Vec<u8> ⓘ
pub fn digest_bytes(&self) -> Vec<u8> ⓘ
Returns the canonical byte form of the configuration: what the feature
feeds into the registry digest, and what Hash hashes.
The bytes are: the number of environments, then each environment in
the order of the names: its name preceded by its length, the number of
its quotation-section commands and the commands in the order of
QuoteSection, and its bare-content kind (0 for none, otherwise one
more than the kind’s position in that order, counted from zero). Two
configurations therefore have the same byte form exactly when they are equal.
Trait Implementations§
Source§impl Clone for QuoteConfig
impl Clone for QuoteConfig
Source§impl Debug for QuoteConfig
impl Debug for QuoteConfig
Source§impl Default for QuoteConfig
impl Default for QuoteConfig
Source§fn default() -> QuoteConfig
fn default() -> QuoteConfig
Source§impl<'de> Deserialize<'de> for QuoteConfigwhere
QuoteConfig: Default,
impl<'de> Deserialize<'de> for QuoteConfigwhere
QuoteConfig: 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 QuoteConfig
Source§impl Hash for QuoteConfig
impl Hash for QuoteConfig
Source§impl JsonSchema for QuoteConfig
impl JsonSchema for QuoteConfig
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 QuoteConfig
impl PartialEq for QuoteConfig
impl StructuralPartialEq for QuoteConfig
Auto Trait Implementations§
impl Forget for QuoteConfig
impl Freeze for QuoteConfigwhere
*const LeafNode<String, QuoteEnvironment> is !null: Freeze,
PhantomData<(Owned, LeafOrInternal)>: Freeze,
PhantomData<Box<(String, QuoteEnvironment)>>: Freeze,
impl Move for QuoteConfig
impl RefUnwindSafe for QuoteConfig
impl Send for QuoteConfigwhere
NodeRef<Owned, String, QuoteEnvironment, LeafOrInternal>: Send,
BoxRaw<(String, QuoteEnvironment)>: Send,
impl Sync for QuoteConfigwhere
NodeRef<Owned, String, QuoteEnvironment, LeafOrInternal>: Sync,
BoxRaw<(String, QuoteEnvironment)>: Sync,
impl Unpin for QuoteConfigwhere
*const LeafNode<String, QuoteEnvironment> is !null: Unpin,
Box<(String, QuoteEnvironment)>: Unpin,
impl UnsafeUnpin for QuoteConfigwhere
*const LeafNode<String, QuoteEnvironment> is !null: UnsafeUnpin,
PhantomData<(Owned, LeafOrInternal)>: UnsafeUnpin,
PhantomData<Box<(String, QuoteEnvironment)>>: UnsafeUnpin,
impl UnwindSafe for QuoteConfig
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