pub struct LatexDefinitionPayload {
pub kind: LatexDefinitionKind,
pub name: String,
pub source_name: String,
pub args: usize,
pub packed: bool,
pub robust: bool,
pub body_argument: bool,
pub feature: Option<String>,
}Expand description
The payload of flm.pres.latex.definition: a macro or environment
definition, or a feature’s declaration
(LatexDefinitionKind::Declaration), that the style file must hold for
the recomposed LaTeX to compile.
The content slots hold the definition’s LaTeX as lowered content: body
(BODY_SLOT) for a macro and
a declaration, or BEGIN_SLOT and END_SLOT for an environment. The
definition takes args arguments, all of them mandatory, and
the body refers to them as #1 to #<args>; every call writes exactly that
many groups, in that order, and nothing else, so LaTeX reads no argument
syntax of its own at a call. An environment may take one more argument, its
own body (body_argument); a call writes no group
for that one, since what a call writes between \begin and \end is
already the body.
The lowering rule that recomposes a kept user definition
(kept) stages a definition
node at every use site of the definition, since rules keep no state. The
emitter writes nothing in the node’s place: it records the definition for
the style file once per name, so that the style file holds it exactly
once.
Fields§
§kind: LatexDefinitionKindWhat the node defines: a macro, an environment or a feature’s
declaration (LatexDefinitionKind).
name: StringThe name defined, without a backslash (flmUDhello, flmUEnote);
for a declaration, the name of the control sequence it is guarded on
(lemma, c@theorem).
source_name: StringThe name the document declared, without a backslash (hello,
note), where it differs from name — a recomposed
user definition is renamed under a prefix of its own
(recomposed_name). The style
file writes it in the comment line above the definition, so that an
author reading the file recognizes their own definition. Equal to
name unless
with_source_name said otherwise, which is
how a definition written under the document’s own name is told from one
written under a prefix (is_bare).
args: usizeHow many arguments the definition takes. Any number: past
PLAIN_ARGUMENT_LIMIT the call hands them over in one group
(packed) rather than one group each.
packed: boolWhether the call hands the arguments over in one group instead of
one group each: \<name>{{first}{second}…}, one pair of braces around
each argument, in argument order.
This is how a definition of more than PLAIN_ARGUMENT_LIMIT
arguments is written, since a LaTeX macro body can refer to only nine
parameters. The definition then takes one LaTeX parameter regardless of
args, and its body reads argument n out of
it with the style file’s accessor
(ARG_COMMAND, \flmArg{<n>}{#1}).
A definition of nine effective arguments or fewer keeps the plain
form, where the body refers to #1 to #<args> directly.
robust: boolWhether the definition is written as a robust command rather than
as a plain expandable macro: the render option
robust_names
lists the name the document declared.
A robust command is one LaTeX writes into a file of its own — the
table of contents, the auxiliary file — as the call itself rather than
as what the call stands for, and runs when that file is read back. The
macro is then written with the document command interface,
\ProvideDocumentCommand\<name>{+m …} with one +m per argument
(\DeclareDocumentCommand where the definition is written under the
document’s own name, is_bare), where an expandable
one is \providecommand\<name>[<n>]. The + makes each argument
long, so it may hold a paragraph break, as \providecommand does of
itself.
Only a macro carries this. An environment is robust however it is
written — \begin opens a group, runs the begin code, sets the body
and runs the end code, none of which expansion alone could produce — so
the option changes nothing for one, and the projection refuses a payload
that claims it (from_projection).
body_argument: boolWhether the definition takes what is written between \begin and \end
as an argument of its own rather than letting LaTeX set it between
the begin and the end code: the environment’s argument specification
ends with +b, after one +m per argument, and the body is the last
parameter — #<args + 1>, or #2 where the arguments are
packed into one group.
An environment written this way carries its whole definition in the
BEGIN_SLOT, with the body’s parameter written where the definition
wants the body, and its END_SLOT is empty. This is how a definition
is written that wants the body somewhere a begin code and an end code
cannot put it — inside a command’s argument, or in two places.
Only an environment can take one: a macro’s body slot is its whole
definition already, so LatexDefinitionKind::Macro leaves this
false.
feature: Option<String>The feature that writes this definition from its own configuration,
where the definition is not one the document declared: defterm for
the environment of a defined term, whose begin code is the configured
lead-in. None for a recomposed user definition.
Such a definition is written under the name it is given and always
guarded — \providecommand, \ProvideDocumentEnvironment, the
test \ifcsname around a declaration — like
a definition piece, so that a definition of that name the user made
before the style file is loaded wins; the style file writes it before
the document’s own definitions, under a comment line that gives the
feature’s name (RecomposedDefinition::feature).
A feature stages one where the definition’s text must be lowered — a
template of its configuration, written through the ordinary rules —
which a definition piece, fixed text, cannot hold.
Implementations§
Source§impl LatexDefinitionPayload
impl LatexDefinitionPayload
Sourcepub fn new(
kind: LatexDefinitionKind,
name: impl Into<String>,
args: usize,
) -> Self
pub fn new( kind: LatexDefinitionKind, name: impl Into<String>, args: usize, ) -> Self
A definition of kind named name taking args arguments, declared
in the document under that same name and calling them one group each.
Sourcepub fn of_feature(self, feature: impl Into<String>) -> Self
pub fn of_feature(self, feature: impl Into<String>) -> Self
The same definition written by the feature feature from its own
configuration (feature): guarded, under the
name it is given.
Sourcepub fn with_source_name(self, source_name: impl Into<String>) -> Self
pub fn with_source_name(self, source_name: impl Into<String>) -> Self
The same definition declared in the document under source_name, the
author’s own spelling, which the style file writes in the comment line
above the definition (source_name).
Sourcepub fn packed(self) -> Self
pub fn packed(self) -> Self
The same definition with its arguments handed over in one group
(packed).
Sourcepub fn robust(self) -> Self
pub fn robust(self) -> Self
The same definition written as a robust command
(robust). A macro only: an environment is robust
however it is written, and the projection refuses one that claims it.
Sourcepub fn body_argument(self) -> Self
pub fn body_argument(self) -> Self
The same definition taking its body as its last argument
(body_argument). An environment only: a macro
has no body of its own to take, and the projection refuses one that
claims it (from_projection).
Sourcepub fn is_bare(&self) -> bool
pub fn is_bare(&self) -> bool
Whether the definition is written under the name the document spelled
rather than under a prefix of its own. The render option
bare_names
asked for it, so the definition is meant to replace any definition that
LaTeX or a package makes under that name, and the emitter writes it
unconditionally rather than guarded. A feature’s definition
(feature) is never bare.
Sourcepub fn from_projection(
value: &SerialValue,
) -> Result<LatexDefinitionPayload, DeserializeError>
pub fn from_projection( value: &SerialValue, ) -> Result<LatexDefinitionPayload, DeserializeError>
The payload rebuilt from its projection, the value
project produced.
§Errors
Returns a DeserializeError that identifies
flm.pres.latex.definition when the projection is not a map, when
kind is missing or is not the name of a kind
(LatexDefinitionKind::parse), when name is missing or is not a
string, when source or feature is present and is not a string, when
a declaration gives no feature, takes arguments or is packed, when
args is present and is not a whole number of arguments, when packed,
robust or body is present and is not a boolean, when body is set
on anything but an environment (a macro’s body slot is already its
whole definition), or when robust is set on anything but a macro (an
environment is robust however it is written). Any number of arguments
is accepted: past PLAIN_ARGUMENT_LIMIT the call hands them over in
one group.
Trait Implementations§
Source§impl Clone for LatexDefinitionPayload
impl Clone for LatexDefinitionPayload
Source§impl Debug for LatexDefinitionPayload
impl Debug for LatexDefinitionPayload
impl Eq for LatexDefinitionPayload
Source§impl PartialEq for LatexDefinitionPayload
impl PartialEq for LatexDefinitionPayload
Source§impl PresPayload for LatexDefinitionPayload
impl PresPayload for LatexDefinitionPayload
Source§fn project(&self) -> SerialValue
fn project(&self) -> SerialValue
impl StructuralPartialEq for LatexDefinitionPayload
Auto Trait Implementations§
impl Forget for LatexDefinitionPayload
impl Freeze for LatexDefinitionPayload
impl Move for LatexDefinitionPayload
impl RefUnwindSafe for LatexDefinitionPayload
impl Send for LatexDefinitionPayloadwhere
RawVecInner: Send,
impl Sync for LatexDefinitionPayloadwhere
RawVecInner: Sync,
impl Unpin for LatexDefinitionPayload
impl UnsafeUnpin for LatexDefinitionPayload
impl UnwindSafe for LatexDefinitionPayloadwhere
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,
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