pub struct HeadingDecl {Show 13 fields
pub name: Name,
pub level: u8,
pub counter: Option<Name>,
pub style: Option<Name>,
pub within: Option<Within>,
pub number_format: NumberTemplate,
pub title_number_format: String,
pub skip_toc: bool,
pub run_in: bool,
pub ref_kind: RefKind,
pub label_types: Vec<String>,
pub anchor_prefix: String,
pub docs: String,
}Expand description
The declaration of a heading kind.
A heading kind is a type of heading, such as a section, a subsection or an
appendix. A heading kind has a name and a level. Its declaration also
contains the settings for the numbering of its headings, for their listing in
a table of contents, for run-in headings, and for the labels that its
headings accept. The heading kinds of a registry are listed in
HeadingsConfig::headings.
HeadingDecl::new creates a heading kind from a name and a level, with
default values for all other fields. Each of these fields has a builder
method of the same name that changes it.
The declaration of a heading kind does not list the commands with which its
headings are written. These commands are declared separately, as
HeadingCommand values in HeadingsConfig::commands, because headings of
the same kind can be written with several commands.
§Examples
use flm_core::stdlib::features::headings::HeadingDecl;
use flm_core::stdlib::features::numbering::{NumberTemplate, Within};
// An appendix at the level of the sections, numbered A, B, C.
let appendix =
HeadingDecl::new("appendix", 1).number_format(NumberTemplate::formats("#{Alph}"));
assert_eq!(
appendix.counter.as_ref().map(|name| name.as_str()),
Some("flm.headings.appendix")
);
assert_eq!(
appendix.style.as_ref().map(|name| name.as_str()),
Some("flm.headings.style.appendix")
);
// A heading kind that is never numbered and never listed in a table of
// contents.
let aside = HeadingDecl::new("aside", 3).no_counter().skip_toc(true);
assert!(aside.counter.is_none());
// A heading kind numbered within the sections, as in `2.1`. The `Within`
// value refers to the counter of the sections by its full name.
let sub = HeadingDecl::new("subsection", 2).within(Within::parent("flm.headings.section"));Fields§
§name: NameThe name of the heading kind, such as section. The name identifies the
heading kind in the attribute data-flm-heading of the HTML output and
in the render option HeadingsLatexOptions.
In settings data, the name is the key of the entry and not a field.
level: u8The level of the heading kind. Levels count from 0, and an outer heading has a smaller level than the headings inside it. The standard heading kinds have the levels 1 to 5, so a heading kind above the sections, such as a chapter, can have the level 0.
The Sectioning aspect returns the level. The HTML element of a
heading corresponds to its level, unless another element is set with a
render option. The format of a heading in plain text also depends on its
level. Whether the heading kind is numbered depends on its level and on
the setting HeadingNumbering.
counter: Option<Name>The counter in which the headings of this kind are counted, given by its
full name. The default is flm.headings.<name> (COUNTER_PREFIX).
None means that the heading kind is never numbered; no counter is then
declared for it in the numbering feature.
style: Option<Name>The counter style with which the numbers of this heading kind are
formatted. The default is flm.headings.style.<name> (STYLE_PREFIX).
A heading kind with a counter must have a counter style.
HeadingDecl::no_counter removes both the counter and the counter
style.
within: Option<Within>The counter within which the counter of this heading kind is numbered,
and how the number of that counter is written before the number of this
heading kind. The default, None, means that the counter is not
numbered within another counter. Counters are given by their full names,
as in Within::parent("flm.headings.section").
number_format: NumberTemplateThe format of the number of this heading kind, without the numbers of
its parent counters, in the number-template language of
NumberTemplate. The default is #{arabic}.
title_number_format: StringThe heading title template of this heading kind: the text written
before the title of a numbered heading. The text is written in the
template language (see the template language shared by
features),
and the placeholder #{number} stands for the number of the heading. The
default is DEFAULT_TITLE_NUMBER_FORMAT (#{number}. ), so a numbered
section reads 1. Introduction.
The template can contain words and markup around the number, as in
Chapter~#{number}: . With #[bare]{number}, the number is written
without the numbers of the parent counters. With #[Roman]{number}, the
number of this heading kind is written in Roman numerals. The number
itself has the role NUMBER_ROLE, with which it
can be formatted in a stylesheet or a lowering rule. A template without a
placeholder is allowed: the headings are then counted, but their numbers
are not written. The template is not used for a heading that is not
numbered.
The registry build fails if the template cannot be parsed, if it contains
a placeholder other than number, or if number is written with a key
that it does not accept. title describes the template in full.
skip_toc: boolWhether the headings of this kind are never listed in a table of
contents. If true, the option toc of these headings has no effect.
The default is false.
run_in: boolWhether the headings of this kind are run-in headings, set at the start
of the paragraph that they introduce (see run-in
headings). The default is false.
ref_kind: RefKindThe reference kind of the reference point of a heading of this kind. The
default is KIND (section).
label_types: Vec<String>The label types that a heading of this kind accepts. The default is
LABEL_TYPES (sec and topic).
anchor_prefix: StringThe text at the start of the anchor of a heading of this kind that has
no label. The default is ANCHOR_PREFIX (sec).
docs: StringA description of the heading kind in one sentence, used in the
description of its element value in the registry. The default is empty,
and an empty description is replaced with A heading of level <level>..
Implementations§
Source§impl HeadingDecl
impl HeadingDecl
Sourcepub fn new(name: impl Into<Name>, level: u8) -> HeadingDecl
pub fn new(name: impl Into<Name>, level: u8) -> HeadingDecl
Returns the heading kind name at the level level, with the following
default values of the other fields:
- the counter
flm.headings.<name>(COUNTER_PREFIX) and the counter styleflm.headings.style.<name>(STYLE_PREFIX); - no counter within which the counter is numbered;
- the number format
#{arabic}and the heading title templateDEFAULT_TITLE_NUMBER_FORMAT; - headings listed in a table of contents and set as blocks;
- the reference kind
KIND, the label typesLABEL_TYPESand the anchor prefixANCHOR_PREFIX; - an empty description.
Sourcepub fn counter(self, counter: impl Into<Name>) -> HeadingDecl
pub fn counter(self, counter: impl Into<Name>) -> HeadingDecl
Sets the counter of this heading kind to counter, given by its full
name.
Sourcepub fn no_counter(self) -> HeadingDecl
pub fn no_counter(self) -> HeadingDecl
Removes the counter and the counter style of this heading kind. A heading
kind without a counter is never numbered, and no counter is declared for
it in the numbering feature.
Sourcepub fn style(self, style: impl Into<Name>) -> HeadingDecl
pub fn style(self, style: impl Into<Name>) -> HeadingDecl
Sets the counter style of this heading kind to style.
Sourcepub fn within(self, within: Within) -> HeadingDecl
pub fn within(self, within: Within) -> HeadingDecl
Sets the counter within which the counter of this heading kind is
numbered (see the field within).
Sourcepub fn number_format(self, number_format: NumberTemplate) -> HeadingDecl
pub fn number_format(self, number_format: NumberTemplate) -> HeadingDecl
Sets the format of the number of this heading kind.
Sourcepub fn title_number_format(self, text: impl Into<String>) -> HeadingDecl
pub fn title_number_format(self, text: impl Into<String>) -> HeadingDecl
Sets the heading title template of this heading kind: the text written
before the title of a numbered heading, in which #{number} stands for
the number (see the field
title_number_format).
Sourcepub fn skip_toc(self, skip_toc: bool) -> HeadingDecl
pub fn skip_toc(self, skip_toc: bool) -> HeadingDecl
Sets whether the headings of this kind are never listed in a table of contents.
Sourcepub fn run_in(self, run_in: bool) -> HeadingDecl
pub fn run_in(self, run_in: bool) -> HeadingDecl
Sets whether the headings of this kind are run-in headings.
Sourcepub fn ref_kind(self, ref_kind: impl Into<RefKind>) -> HeadingDecl
pub fn ref_kind(self, ref_kind: impl Into<RefKind>) -> HeadingDecl
Sets the reference kind of the reference point of a heading of this kind.
Sourcepub fn label_types(
self,
types: impl IntoIterator<Item = impl Into<String>>,
) -> HeadingDecl
pub fn label_types( self, types: impl IntoIterator<Item = impl Into<String>>, ) -> HeadingDecl
Sets the label types that a heading of this kind accepts.
Sourcepub fn anchor_prefix(self, prefix: impl Into<String>) -> HeadingDecl
pub fn anchor_prefix(self, prefix: impl Into<String>) -> HeadingDecl
Sets the text at the start of the anchor of a heading of this kind that has no label.
Trait Implementations§
Source§impl Clone for HeadingDecl
impl Clone for HeadingDecl
Source§impl Debug for HeadingDecl
impl Debug for HeadingDecl
Source§impl<'de> Deserialize<'de> for HeadingDecl
impl<'de> Deserialize<'de> for HeadingDecl
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 HeadingDecl
Source§impl JsonSchema for HeadingDecl
impl JsonSchema for HeadingDecl
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 HeadingDecl
In settings data, a heading kind is an entry of the map
HeadingsConfig::headings, with the name of the heading kind as its key.
The entry must contain the field level. The other fields are optional; a
field that is left out has the value set by HeadingDecl::new.
impl NamedEntry for HeadingDecl
In settings data, a heading kind is an entry of the map
HeadingsConfig::headings, with the name of the heading kind as its key.
The entry must contain the field level. The other fields are optional; a
field that is left out has the value set by HeadingDecl::new.
Source§fn read_entry(name: &str, data: Value) -> Result<HeadingDecl, String>
fn read_entry(name: &str, data: Value) -> Result<HeadingDecl, String>
Source§impl PartialEq for HeadingDecl
impl PartialEq for HeadingDecl
Source§impl Serialize for HeadingDecl
impl Serialize for HeadingDecl
impl StructuralPartialEq for HeadingDecl
Auto Trait Implementations§
impl Forget for HeadingDecl
impl Freeze for HeadingDeclwhere
*const ArcInner<str> is !null: Freeze,
PhantomData<ArcInner<str>>: Freeze,
*const u8 is !null: Freeze,
PhantomData<Name>: Freeze,
PhantomData<u8>: Freeze,
PhantomData<String>: Freeze,
impl Move for HeadingDecl
impl RefUnwindSafe for HeadingDecl
impl Send for HeadingDecl
impl Sync for HeadingDecl
impl Unpin for HeadingDecl
impl UnsafeUnpin for HeadingDeclwhere
*const ArcInner<str> is !null: UnsafeUnpin,
PhantomData<ArcInner<str>>: UnsafeUnpin,
*const u8 is !null: UnsafeUnpin,
PhantomData<Name>: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
PhantomData<String>: UnsafeUnpin,
impl UnwindSafe for HeadingDecl
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