pub struct MacroSet { /* private fields */ }Expand description
A named table of \newcommand-tier substitution macros. See the module
docs for the expansion, provenance, and budget rules.
Implementations§
Source§impl MacroSet
impl MacroSet
Sourcepub fn pack(id: &str) -> Option<Self>
pub fn pack(id: &str) -> Option<Self>
The builtin preamble packs, by stable content id (the ids the
fmn-config registry records): fmd-math/pack/default (the everyday
bundle), fmd-math/pack/basic (minimal), fmd-math/pack/empty
(bare primitives). Plain names (default, basic, empty) are
accepted too.
Sourcepub fn define(
&mut self,
name: &str,
params: u8,
body: &str,
) -> Result<(), MathError>
pub fn define( &mut self, name: &str, params: u8, body: &str, ) -> Result<(), MathError>
Define a macro: params parameters (#1…#9), a TeX-source body.
Replaces any existing definition of the name (packs are assembled
with this; source-level shadowing rules are \newcommand’s).
§Errors
MathError::Malformed (at byte 0 of the definition body) for an
invalid name, too many parameters, an unbalanced body, or a #k
outside 1..=params.
Sourcepub fn canonical_bytes(&self) -> Vec<u8> ⓘ
pub fn canonical_bytes(&self) -> Vec<u8> ⓘ
A deterministic serialization of the whole table — the cache-key
ingredient (hash these bytes; equal bytes ⇔ equal macro semantics).
Format: a version tag, then name US params US body RS per macro in
sorted order (US/RS are the ASCII unit/record separators, which
cannot appear in names and are vanishingly unlikely in bodies; the
version tag changes if this framing ever does).