pub struct XnoteKind {Show 14 fields
pub name: Name,
pub commands: Vec<String>,
pub words: PrefixWords,
pub label_type: String,
pub numbered: bool,
pub number_format: NumberTemplate,
pub within: Option<Within>,
pub mark: NumberTemplate,
pub placement: XnotePlacement,
pub layout: ArgLayout,
pub title: Option<String>,
pub title_level: u8,
pub backlink: String,
pub latex_command: String,
}Expand description
One xnote kind: one way of being an xnote, a piece of text set apart from
the running text (the footnotes written \footnote{…}, the side notes a
configuration adds, the notes another feature’s elements carry; see the
module documentation of the feature).
An xnote kind states, field by field:
name: what the kind is called,footnote. It is made of ASCII letters only, because other names are derived from it: the counterflm.xnotes.<name>, the list element, the LaTeX command\flmXN<name>.commands: the commands with which an author writes an xnote of the kind, without the backslash:footnote. Empty for a kind that no author writes, which another feature contributes through the service slot of xnote kinds (contribute_kind).words: the words a reference writes before an xnote’s number,Footnote~before one number andFootnotes~before several.\ref{fn:x}prints them (Footnote~1); the default title of the list is made from them; and the accessible name of the link from a mark to its xnote begins with them.label_type: the only label type that an xnote of the kind accepts,fnin\label{fn:x}; also the prefix of its anchors in the output (fn-1,fnref--1kzmq). It is made of ASCII letters only, like the name, so that it can be written as the label type of a\labeland begin an anchor.numbered: whether the kind’s xnotes are counted, in document order, in a counter of the kind’s own. A reference to a numbered xnote shows its number; a reference to an unnumbered xnote shows its content where that content is inline, and otherwise its label.number_format: how a reference writes the number of a numbered kind’s xnote,#{arabic}.within: the counter within which a numbered kind is numbered,Nonefor numbering through the whole document.mark: what is shown in the running text where an xnote was written. For a numbered kind it is a number template,#{arabic}by default, and the mark is the xnote’s number written through it; for an unnumbered kind it is a fixed mark, a template with no number placeholder (*,\dag), or empty for no mark. In both cases the template is FLM text, compiled when the registry is built.placement: listed after the content, or shown in place (XnotePlacement).layout: how the content argument is laid out: inferred from what the author wrote by default, or fixed.titleandtitle_level: the heading placed above the kind’s list, and its level.backlink: the text of the link from the entry of a listed xnote back to its mark,↩.latex_command: the LaTeX command to which the style file’s default definition of\flmXN<name>passes the xnote (footnote), a command of the author’s LaTeX that the author’s own preamble may redefine.
§Numbered and unnumbered xnote kinds
Whether a kind is numbered is stated by its flag
numbered and is never inferred from its
templates. The mark template is read the same way for
both: as FLM text in the language of a counter style’s number template,
compiled when the registry is built, a mistake in it failing the build
(see the template
language).
For a numbered kind it is a number template; for an unnumbered kind it is
a fixed mark, and an unnumbered kind whose mark holds a number placeholder
such as #{arabic} is refused when the registry is built, since it has no
number to write (XnoteKind::validate). The
number_format and within
of an unnumbered kind are ignored, neither compiled nor checked, so that
switching a kind between numbered and unnumbered needs no other change.
An xnote kind does not depend on any particular output: the mark is one
text, shown as a superscript, which each output writes in its own way. For
a numbered kind, a host that wants the mark written differently on one
output replaces the kind’s mark style, flm.xnotes.style.<name>.mark
(mark_style_name), through the numbering
feature’s configuration in that output’s registry, as it replaces any
declared counter style. An unnumbered kind’s fixed mark is compiled by the
xnotes feature from mark and is not a declared
counter style: a different fixed mark on one output needs a configuration
with a different mark in that output’s registry.
§Examples
use flm_core::lang::mint::ArgLayout;
use flm_core::stdlib::features::numbering::{NumberTemplate, PrefixWords};
use flm_core::stdlib::features::xnotes::{XnoteKind, XnotePlacement};
// The default kind.
let footnote = XnoteKind::footnote();
assert_eq!(footnote.commands, ["footnote"]);
assert_eq!(footnote.title.as_deref(), Some("Footnotes"));
// A second numbered kind, listed after the footnotes.
let endnote = XnoteKind::numbered("endnote", PrefixWords::new("Endnote~", "Endnotes~"))
.commands(["endnote"])
.label_type("en");
assert_eq!(endnote.title.as_deref(), Some("Endnotes"));
// An unnumbered kind shown where it is written, with no mark.
let sidenote = XnoteKind::unnumbered("sidenote", PrefixWords::new("Side note~", "Side notes~"))
.commands(["sidenote"])
.label_type("sn")
.placement(XnotePlacement::InPlace);
assert!(!sidenote.numbered);
assert_eq!(sidenote.mark, NumberTemplate::formats(""));
// A kind whose content is always paragraphs.
let long = XnoteKind::footnote().layout(ArgLayout::Blocks);
assert_eq!(long.layout, ArgLayout::Blocks);Fields§
§name: NameThe kind’s name, ASCII letters only: footnote.
In settings, it is written as the entry’s key, not as a field.
commands: Vec<String>The commands with which an xnote of the kind is written, without the backslash; empty for a kind that only another feature creates.
words: PrefixWordsThe words a reference writes before one number and before several,
with their variants: Footnote~, Footnotes~.
label_type: StringThe only label type that an xnote of the kind accepts, and the prefix
of its anchors in the output: fn. ASCII letters only.
numbered: boolWhether the kind’s xnotes are numbered.
number_format: NumberTemplateHow a reference writes a numbered xnote’s number; ignored for an
unnumbered kind. #{arabic} by default.
within: Option<Within>The counter within which a numbered kind is numbered, or None for
numbering through the whole document; ignored for an unnumbered kind.
mark: NumberTemplateThe text of the mark, as FLM text: a number template for a numbered
kind (#{arabic}), a fixed mark with no number placeholder for an
unnumbered one (empty for no mark).
placement: XnotePlacementWhere the kind’s xnotes are shown.
layout: ArgLayoutHow the content argument is laid out:
InlineOrBlocks by default, which makes
a note written on one run inline content and one holding a blank line
or a block paragraphs. Inline refuses a blank
line in the note, as every inline argument does.
Blocks makes every note paragraphs, even an
empty one: with it, an in-place xnote is always a block of its own,
\footnote{} included.
title: Option<String>The heading placed above the kind’s list, as FLM text; None for no
heading. The constructors set the plural word, capitalized and without
the non-breaking space (Footnotes).
The title is compiled when the registry is built, and a title that is
not valid FLM fails the build. It is read in the language of a counter
style’s number template, with no placeholder available: # starts a
placeholder there, so a literal # is written \# or ##, and a
placeholder such as #{n} fails the build.
title_level: u8The level of the heading above the list, counted from zero like every heading level; 2 by default.
backlink: StringThe text of the link from a listed xnote back to its mark: ↩.
latex_command: StringThe LaTeX command to which the style file’s default definition of
\flmXN<name> passes the xnote, without the backslash (footnote): a
command of the author’s LaTeX, which the author’s own preamble may
redefine. ASCII letters only.
Implementations§
Source§impl XnoteKind
impl XnoteKind
Sourcepub fn numbered(name: impl Into<Name>, words: PrefixWords) -> XnoteKind
pub fn numbered(name: impl Into<Name>, words: PrefixWords) -> XnoteKind
A numbered xnote kind named name with the reference words words:
no command, the label type name, numbered through the document, the
number written #{arabic} in a reference and in the mark, listed, the
layout inferred from the content, the title made of the plural word
capitalized, at level 2, the back-link ↩, the LaTeX command
footnote. The builder methods change each of these.
The title is computed from words here, once: a kind whose words are
changed afterwards keeps its title until title
sets another.
Sourcepub fn unnumbered(name: impl Into<Name>, words: PrefixWords) -> XnoteKind
pub fn unnumbered(name: impl Into<Name>, words: PrefixWords) -> XnoteKind
An unnumbered xnote kind named name with the reference words
words: as XnoteKind::numbered, but its xnotes are counted in no
counter and its mark is empty, so that no mark is written.
Sourcepub fn footnote() -> XnoteKind
pub fn footnote() -> XnoteKind
The default xnote kind, footnote: written \footnote, the words
Footnote~ and Footnotes~ (the capital variant the same), the label
type fn, numbered through the document, #{arabic} in a reference and
in the mark, listed, its layout inferred, the title Footnotes at
level 2, the back-link ↩, the LaTeX command footnote.
Sourcepub fn commands(
self,
commands: impl IntoIterator<Item = impl Into<String>>,
) -> XnoteKind
pub fn commands( self, commands: impl IntoIterator<Item = impl Into<String>>, ) -> XnoteKind
Builder: the commands with which an xnote of the kind is written, without the backslash.
Sourcepub fn label_type(self, label_type: impl Into<String>) -> XnoteKind
pub fn label_type(self, label_type: impl Into<String>) -> XnoteKind
Builder: the label type the kind’s xnotes accept, made of ASCII letters only.
Sourcepub fn number_format(self, number_format: NumberTemplate) -> XnoteKind
pub fn number_format(self, number_format: NumberTemplate) -> XnoteKind
Builder: how a reference writes a numbered xnote’s number.
Sourcepub fn within(self, within: Within) -> XnoteKind
pub fn within(self, within: Within) -> XnoteKind
Builder: the counter within which a numbered kind is numbered.
Sourcepub fn mark(self, mark: NumberTemplate) -> XnoteKind
pub fn mark(self, mark: NumberTemplate) -> XnoteKind
Builder: the text of the mark (mark).
Sourcepub fn placement(self, placement: XnotePlacement) -> XnoteKind
pub fn placement(self, placement: XnotePlacement) -> XnoteKind
Builder: where the kind’s xnotes are shown.
Sourcepub fn layout(self, layout: ArgLayout) -> XnoteKind
pub fn layout(self, layout: ArgLayout) -> XnoteKind
Builder: how the content argument is laid out.
Sourcepub fn title(self, title: impl Into<String>) -> XnoteKind
pub fn title(self, title: impl Into<String>) -> XnoteKind
Builder: the heading placed above the kind’s list, as FLM text,
compiled when the registry is built (a literal # is written \# or
##; see title).
Sourcepub fn without_title(self) -> XnoteKind
pub fn without_title(self) -> XnoteKind
Builder: no heading above the kind’s list.
Sourcepub fn title_level(self, level: u8) -> XnoteKind
pub fn title_level(self, level: u8) -> XnoteKind
Builder: the level of the heading above the list, counted from zero.
Sourcepub fn backlink(self, backlink: impl Into<String>) -> XnoteKind
pub fn backlink(self, backlink: impl Into<String>) -> XnoteKind
Builder: the text of the link back from a listed xnote to its mark.
Sourcepub fn latex_command(self, command: impl Into<String>) -> XnoteKind
pub fn latex_command(self, command: impl Into<String>) -> XnoteKind
Builder: the LaTeX command to which the style file’s default
definition of \flmXN<name> passes the xnote, without the backslash
and made of ASCII letters: a command of the author’s LaTeX, which the
author’s own preamble may redefine.
Sourcepub fn validate(&self) -> Result<(), String>
pub fn validate(&self) -> Result<(), String>
Checks what can be checked of one xnote kind on its own;
contribute_kind calls it before it declares
anything.
§Errors
A sentence describing the first problem found: a name, a label type or a LaTeX command that is empty or holds anything but ASCII letters; an unnumbered kind whose mark holds a number placeholder. The number and mark templates of a numbered kind are checked by the numbering feature, when the registry compiles the kind’s counter styles; the title and an unnumbered kind’s fixed mark are compiled, and checked, when the registry is built.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for XnoteKind
impl<'de> Deserialize<'de> for XnoteKind
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 XnoteKind
Source§impl JsonSchema for XnoteKind
impl JsonSchema for XnoteKind
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 NamedEntry for XnoteKind
An xnote kind is written in settings under its name, in the map of
XnotesConfig::kinds, and read over the kind that
XnoteKind::numbered makes for that name and the words written; the
words must be written.
impl NamedEntry for XnoteKind
An xnote kind is written in settings under its name, in the map of
XnotesConfig::kinds, and read over the kind that
XnoteKind::numbered makes for that name and the words written; the
words must be written.
impl StructuralPartialEq for XnoteKind
Auto Trait Implementations§
impl Forget for XnoteKind
impl Freeze for XnoteKindwhere
*const ArcInner<str> is !null: Freeze,
PhantomData<ArcInner<str>>: Freeze,
*const u8 is !null: Freeze,
PhantomData<String>: Freeze,
PhantomData<u8>: Freeze,
*const LeafNode<String, PluralWords> is !null: Freeze,
PhantomData<(Owned, LeafOrInternal)>: Freeze,
PhantomData<Box<(String, PluralWords)>>: Freeze,
PhantomData<Name>: Freeze,
impl Move for XnoteKind
impl RefUnwindSafe for XnoteKind
impl Send for XnoteKindwhere
Arc<str>: Send,
RawVecInner: Send,
NodeRef<Owned, String, PluralWords, LeafOrInternal>: Send,
BoxRaw<(String, PluralWords)>: Send,
impl Sync for XnoteKindwhere
Arc<str>: Sync,
RawVecInner: Sync,
NodeRef<Owned, String, PluralWords, LeafOrInternal>: Sync,
BoxRaw<(String, PluralWords)>: Sync,
impl Unpin for XnoteKind
impl UnsafeUnpin for XnoteKindwhere
*const ArcInner<str> is !null: UnsafeUnpin,
PhantomData<ArcInner<str>>: UnsafeUnpin,
*const u8 is !null: UnsafeUnpin,
PhantomData<String>: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
*const LeafNode<String, PluralWords> is !null: UnsafeUnpin,
PhantomData<(Owned, LeafOrInternal)>: UnsafeUnpin,
PhantomData<Box<(String, PluralWords)>>: UnsafeUnpin,
PhantomData<Name>: UnsafeUnpin,
impl UnwindSafe for XnoteKind
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