pub struct DeftermConfig {
pub lead_in: Option<String>,
}Expand description
The configuration of the Defterm feature: the
lead-in, the text that a term definition (a defterm environment)
shows before the words of its first paragraph, usually the term being
defined.
The lead-in is a template in the template
language
(described for authors under the template
language), with one
placeholder: #{term} is the term as the term definition writes it,
markup included. The rest of the template is ordinary FLM markup, and
markup may enclose the placeholder. #{term}: is the default, and
\textbf{Definition} (\emph{#{term}}): a richer lead-in. A template
without #{term} is allowed: every term definition then opens with the
same words. A template may use #{term} once at most, because the term is
shown only once, where the term definition is written.
None sets no lead-in: a term definition is then its body alone. A blank
template is not a way to say so: it fails the registry build.
The value is what Defterm::new takes, and a host
passes it through
StdlibConfig::defterm. It is
the feature’s configuration, fixed when the registry is built (see
settings, options and
configuration):
the template is compiled once then, and a template that does not compile
fails the registry build with a message that quotes it. It enters the
registry digest (digest_bytes).
§Examples
use flm_core::stdlib::features::defterm::{DeftermConfig, DEFAULT_LEAD_IN};
assert_eq!(DeftermConfig::new().lead_in.as_deref(), Some(DEFAULT_LEAD_IN));
let richer = DeftermConfig::new()
.lead_in(Some(r"\textbf{Definition} (\emph{#{term}}): ".to_string()));
assert!(richer.lead_in.is_some());
// No lead-in: a definition is its body alone.
assert!(DeftermConfig::new().lead_in(None).lead_in.is_none());Fields§
§lead_in: Option<String>The lead-in template, or None for no lead-in. DEFAULT_LEAD_IN
by default.
Implementations§
Source§impl DeftermConfig
impl DeftermConfig
Sourcepub fn new() -> DeftermConfig
pub fn new() -> DeftermConfig
The default configuration: the lead-in DEFAULT_LEAD_IN.
Sourcepub fn lead_in(self, lead_in: Option<String>) -> DeftermConfig
pub fn lead_in(self, lead_in: Option<String>) -> DeftermConfig
Builder: sets the lead-in template, or None for no lead-in.
Sourcepub fn digest_bytes(&self) -> Vec<u8> ⓘ
pub fn digest_bytes(&self) -> Vec<u8> ⓘ
The configuration written out as bytes: what the feature feeds into
the registry digest, and what the Hash implementation hashes. -
for no lead-in, else +, the template’s length and the template.
Trait Implementations§
Source§impl Clone for DeftermConfig
impl Clone for DeftermConfig
Source§impl Debug for DeftermConfig
impl Debug for DeftermConfig
Source§impl Default for DeftermConfig
impl Default for DeftermConfig
Source§fn default() -> DeftermConfig
fn default() -> DeftermConfig
Source§impl<'de> Deserialize<'de> for DeftermConfigwhere
DeftermConfig: Default,
impl<'de> Deserialize<'de> for DeftermConfigwhere
DeftermConfig: 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 DeftermConfig
Source§impl Hash for DeftermConfig
impl Hash for DeftermConfig
Source§impl JsonSchema for DeftermConfig
impl JsonSchema for DeftermConfig
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 DeftermConfig
impl PartialEq for DeftermConfig
impl StructuralPartialEq for DeftermConfig
Auto Trait Implementations§
impl Forget for DeftermConfig
impl Freeze for DeftermConfig
impl Move for DeftermConfig
impl RefUnwindSafe for DeftermConfig
impl Send for DeftermConfigwhere
RawVecInner: Send,
impl Sync for DeftermConfigwhere
RawVecInner: Sync,
impl Unpin for DeftermConfig
impl UnsafeUnpin for DeftermConfig
impl UnwindSafe for DeftermConfigwhere
RawVecInner: UnwindSafe,
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