pub enum NumberTemplate {
Formats(String),
Initial(String),
}Expand description
A number template: how a counter style writes the number itself, as a text
with a place for the number, written in one of the eight NumberFormats;
a counter style holds one in its field number_format.
The text is FLM with a place for the number, in one of two languages, and
it is compiled once, when the counter style is compiled. Around the place
for the number the text is ordinary FLM: \textbf and ~ mean in a
number template what they mean in a document.
Formatsis written in the template language that user definitions use (the template language shared by features):#{name}is the number written in the formatname. The whole text is parsed as one, so markup may surround the number:\textbf{#{arabic}}writes the number in bold.Initialis the language of an author’s own item labels: the first of the charactersa,A,i,Iand1is the number, written in the format that character shows by example, and the rest is FLM:(a)writes(c)for the number three.
A counter style’s number format
(CounterStyleDecl::number_format),
each of its sub-levels (SubLevelDecl) and a
reference point’s own number template
(NumberSource::number_format,
always in the Formats language) are number templates.
§Examples
The number in decimal digits followed by a full stop, and the number as a lowercase letter between parentheses:
use flm_core::stdlib::features::numbering::NumberTemplate;
let section = NumberTemplate::formats("#{arabic}.");
let item = NumberTemplate::initial("(a)");Markup around the number. The language that the counter style is compiled against here holds FLM’s structural elements and no feature’s commands, so the example surrounds the number with a group instead of a command; a command’s braces are a group, and a command behaves the same way.
use flm_core::lang::{build_language, LangInputs};
use flm_core::stdlib::features::numbering::{CounterStyleDecl, NumberTemplate};
let lang = build_language(LangInputs::new());
let mut around = CounterStyleDecl::new("example.style.equation");
around.number_format = NumberTemplate::formats("{#{arabic}}");
assert!(around.compile(&lang).is_ok());
// A name that is not one of the eight formats is refused.
let mut wrong = CounterStyleDecl::new("example.style.equation");
wrong.number_format = NumberTemplate::formats("#{nosuchformat}");
assert!(wrong.compile(&lang).is_err());Variants§
Formats(String)
A number template in the template language: every #{name} is the
number written in the format name, and the rest is written as given:
#{arabic}. writes 3. for the number three, and
\textbf{#{arabic}} writes it in bold. A #{…} whose name is not a
number format is refused when the counter style is compiled, and so is
a key in brackets, #[…]{…}, which only a within template accepts.
Initial(String)
A number template in the single-letter language: the first character
among a, A, i, I and 1 is the number, written in the format
that character shows by example (letters, capital letters, roman
numerals, capital roman numerals, decimal digits), and the rest is
FLM written as given: (a) writes (c) for the number three. A text
that holds none of those five characters writes itself for every
number, and the parts of the counters it is numbered within are not
written before it: it is a fixed mark, such as a bullet.
This is the language of an author’s own item labels, where the
number’s format is shown by an example instead of being named. The
first of the five characters is replaced wherever it is, so Part a.
writes Pcrt a. for the number three; a text that must hold one of
these characters as a letter of its own is written in the Formats
language.
Implementations§
Source§impl NumberTemplate
impl NumberTemplate
Trait Implementations§
Source§impl Clone for NumberTemplate
impl Clone for NumberTemplate
Source§impl Debug for NumberTemplate
impl Debug for NumberTemplate
Source§impl<'de> Deserialize<'de> for NumberTemplate
impl<'de> Deserialize<'de> for NumberTemplate
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 NumberTemplate
Source§impl JsonSchema for NumberTemplate
impl JsonSchema for NumberTemplate
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 NumberTemplate
impl PartialEq for NumberTemplate
Source§impl Serialize for NumberTemplate
impl Serialize for NumberTemplate
impl StructuralPartialEq for NumberTemplate
Auto Trait Implementations§
impl Forget for NumberTemplate
impl Freeze for NumberTemplate
impl Move for NumberTemplate
impl RefUnwindSafe for NumberTemplate
impl Send for NumberTemplate
impl Sync for NumberTemplate
impl Unpin for NumberTemplate
impl UnsafeUnpin for NumberTemplate
impl UnwindSafe for NumberTemplate
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