Skip to main content

XnoteKind

Struct XnoteKind 

Source
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 counter flm.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 and Footnotes~ 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, fn in \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 \label and 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, None for 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.
  • title and title_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: Name

The 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: PrefixWords

The words a reference writes before one number and before several, with their variants: Footnote~, Footnotes~.

§label_type: String

The only label type that an xnote of the kind accepts, and the prefix of its anchors in the output: fn. ASCII letters only.

§numbered: bool

Whether the kind’s xnotes are numbered.

§number_format: NumberTemplate

How 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: NumberTemplate

The 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: XnotePlacement

Where the kind’s xnotes are shown.

§layout: ArgLayout

How 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: u8

The level of the heading above the list, counted from zero like every heading level; 2 by default.

§backlink: String

The text of the link from a listed xnote back to its mark: ↩.

§latex_command: String

The 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

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn number_format(self, number_format: NumberTemplate) -> XnoteKind

Builder: how a reference writes a numbered xnote’s number.

Source

pub fn within(self, within: Within) -> XnoteKind

Builder: the counter within which a numbered kind is numbered.

Source

pub fn mark(self, mark: NumberTemplate) -> XnoteKind

Builder: the text of the mark (mark).

Source

pub fn placement(self, placement: XnotePlacement) -> XnoteKind

Builder: where the kind’s xnotes are shown.

Source

pub fn layout(self, layout: ArgLayout) -> XnoteKind

Builder: how the content argument is laid out.

Source

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).

Source

pub fn without_title(self) -> XnoteKind

Builder: no heading above the kind’s list.

Source

pub fn title_level(self, level: u8) -> XnoteKind

Builder: the level of the heading above the list, counted from zero.

Builder: the text of the link back from a listed xnote to its mark.

Source

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.

Source

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 Clone for XnoteKind

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for XnoteKind

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for XnoteKind

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for XnoteKind

Source§

impl JsonSchema for XnoteKind

Source§

fn schema_name() -> Cow<'static, str>

The name of the generated JSON Schema. Read more
Source§

fn schema_id() -> Cow<'static, str>

Returns a string that uniquely identifies the schema produced by this type. Read more
Source§

fn json_schema(generator: &mut SchemaGenerator) -> Schema

Generates a JSON Schema for this type. Read more
Source§

fn inline_schema() -> bool

Whether JSON Schemas generated for this type should be included directly in parent schemas, rather than being re-used where possible using the $ref keyword. Read more
Source§

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.

Source§

fn read_entry(name: &str, data: Value) -> Result<XnoteKind, String>

Reads the entry named name from data, the rest of the entry as written under that name. Read more
Source§

impl PartialEq for XnoteKind

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for XnoteKind

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for XnoteKind

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Az for T

Source§

fn az<Dst>(self) -> Dst
where T: Cast<Dst>,

Casts the value.
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<Src, Dst> CastFrom<Src> for Dst
where Src: Cast<Dst>,

Source§

fn cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CheckedAs for T

Source§

fn checked_as<Dst>(self) -> Option<Dst>
where T: CheckedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> CheckedCastFrom<Src> for Dst
where Src: CheckedCast<Dst>,

Source§

fn checked_cast_from(src: Src) -> Option<Dst>

Casts the value.
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<Src, Dst> LosslessTryInto<Dst> for Src
where Dst: LosslessTryFrom<Src>,

Source§

fn lossless_try_into(self) -> Option<Dst>

Performs the conversion.
Source§

impl<Src, Dst> LossyInto<Dst> for Src
where Dst: LossyFrom<Src>,

Source§

fn lossy_into(self) -> Dst

Performs the conversion.
Source§

impl<T> OverflowingAs for T

Source§

fn overflowing_as<Dst>(self) -> (Dst, bool)
where T: OverflowingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> OverflowingCastFrom<Src> for Dst
where Src: OverflowingCast<Dst>,

Source§

fn overflowing_cast_from(src: Src) -> (Dst, bool)

Casts the value.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> SaturatingAs for T

Source§

fn saturating_as<Dst>(self) -> Dst
where T: SaturatingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> SaturatingCastFrom<Src> for Dst
where Src: SaturatingCast<Dst>,

Source§

fn saturating_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> SettingsData for T

Source§

impl<T> StrictAs for T

Source§

fn strict_as<Dst>(self) -> Dst
where T: StrictCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> StrictCastFrom<Src> for Dst
where Src: StrictCast<Dst>,

Source§

fn strict_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> UnwrappedAs for T

Source§

fn unwrapped_as<Dst>(self) -> Dst
where T: UnwrappedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> UnwrappedCastFrom<Src> for Dst
where Src: UnwrappedCast<Dst>,

Source§

fn unwrapped_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> WrappingAs for T

Source§

fn wrapping_as<Dst>(self) -> Dst
where T: WrappingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> WrappingCastFrom<Src> for Dst
where Src: WrappingCast<Dst>,

Source§

fn wrapping_cast_from(src: Src) -> Dst

Casts the value.