Skip to main content

NodeKind

Enum NodeKind 

Source
pub enum NodeKind {
Show 30 variants List(Vec<Node>), Symbol { ch: char, class: AtomClass, }, BigOp { ch: char, limits: Limits, integral: bool, }, OpName { name: String, limits: bool, }, Scripts { base: Option<Box<Node>>, sub: Option<Box<Node>>, sup: Option<Box<Node>>, primes: Vec<Span>, }, Frac { num: Box<Node>, den: Box<Node>, spec: FracSpec, }, Radical { index: Option<Box<Node>>, radicand: Box<Node>, }, Accent { accent: AccentKind, base: Box<Node>, }, LeftRight { left: Delim, right: Delim, body: Vec<Node>, }, SizedDelim { size: DelimSize, class: AtomClass, delim: Delim, }, Text { body: Vec<Node>, }, TextRun { text: String, char_spans: Vec<Span>, }, TextStyled { style: TextStyle, body: Vec<Node>, }, MathIsland { body: Vec<Node>, display: bool, }, StyleChange(Style), AlignChange(LineAlign), SizeChange(f64), ColorChange(String), LineSpacing(f64), MathFont { font: MathFont, body: Box<Node>, }, Phantom { kind: PhantomKind, body: Box<Node>, }, Stack { kind: StackKind, annotation: Box<Node>, base: Box<Node>, }, XArrow { mapsto: bool, above: Box<Node>, below: Option<Box<Node>>, }, Space(SpaceKind), Tie, Linebreak, AlignTab, AlignBlock { align: LineAlign, lines: Vec<Node>, }, Environment { name: String, spec: Option<String>, rows: Vec<Vec<Node>>, }, Fragment(FragmentKind),
}
Expand description

What a node is. See the module docs; every variant is produced by crate::parse / crate::parse_text with full span provenance.

Variants§

§

List(Vec<Node>)

A horizontal list: a group’s content, a cell, an argument, or the whole formula.

§

Symbol

A single character atom, already mapped to its math codepoint (- ⇒ −, * ⇒ ∗, \pi ⇒ π). class is the intrinsic atom class before contextual Bin→Ord degradation.

Fields

§ch: char

The (mapped) character.

§class: AtomClass

Intrinsic atom class.

§

BigOp

A big operator (\sum, \int, …): an Op atom with a limits mode.

Fields

§ch: char

The operator character (∑, ∫, …).

§limits: Limits

\limits/\nolimits state.

§integral: bool

True for the \int class, whose default is side scripts even in display style.

§

OpName

A roman operator name (\sin, \lim, \operatorname{…}): an Op atom set in upright text.

Fields

§name: String

The rendered name (“sin”, “lim”, …).

§limits: bool

True for the \lim class, which takes under/over scripts in display style.

§

Scripts

Sub/superscripts and primes attached to a base atom. base is None when the script opens the list (TeX’s empty-nucleus atom).

Fields

§base: Option<Box<Node>>

The atom the scripts attach to.

§sub: Option<Box<Node>>

Subscript.

§sup: Option<Box<Node>>

Superscript (primes precede it visually).

§primes: Vec<Span>

The ' primes, one source span each.

§

Frac

A generalized fraction: \frac-family, \binom/\choose, or an infix \over that split its enclosing list.

Fields

§num: Box<Node>

Numerator.

§den: Box<Node>

Denominator.

§spec: FracSpec

Bar/delimiter/style flavor.

§

Radical

\sqrt, with an optional index (\sqrt[3]{x}).

Fields

§index: Option<Box<Node>>

The index, if any.

§radicand: Box<Node>

The radicand.

§

Accent

An accented atom.

Fields

§accent: AccentKind

Which accent.

§base: Box<Node>

The base.

§

LeftRight

\left … \right: an Inner atom.

Fields

§left: Delim

Opening delimiter.

§right: Delim

Closing delimiter.

§body: Vec<Node>

The enclosed list.

§

SizedDelim

A fixed-size delimiter (\big(, \Big\{, …).

Fields

§size: DelimSize

Which size.

§class: AtomClass

The atom class the variant imposes: \bigl ⇒ Open, \bigr ⇒ Close, \bigm ⇒ Rel, plain \big ⇒ Ord.

§delim: Delim

The delimiter.

§

Text

\text{…} inside mathematics: the body is text-mode content.

Fields

§body: Vec<Node>

Text-mode body.

§

TextRun

A literal run of text-mode characters, with one source span per character (decoded characters and source bytes are not linear: escapes decode two bytes to one character, whitespace collapses) — the provenance Text[3:7]-style slicing consumes.

Fields

§text: String

The decoded text.

§char_spans: Vec<Span>

One span per char of text, in order.

§

TextStyled

A \textbf/\emph/\underline styling island (text mode, or the LaTeX text-in-math form).

Fields

§style: TextStyle

Which style.

§body: Vec<Node>

The body, in text mode.

§

MathIsland

$…$ (or $$…$$) inside text mode: the body is math-mode content.

Fields

§body: Vec<Node>

Math-mode body.

§display: bool

True for $$…$$ display mathematics (lays out in display style); false for inline $…$ (text style).

§

StyleChange(Style)

A style-switch marker (\displaystyle …) applying to the remainder of the enclosing list.

§

AlignChange(LineAlign)

A line-alignment declaration (\centering): applies to the remainder of the enclosing list, exiting at group end, exactly like LaTeX’s paragraph declarations. Produces no glyphs of its own.

§

SizeChange(f64)

A size declaration (\small, \Large, …): sets the current size factor for the remainder of the enclosing list, exiting at group end, and composing multiplicatively with the script styles (the LaTeX 10 pt ladder of size10.clo).

§

ColorChange(String)

A \color{…} marker applying to the remainder of the enclosing group. The argument is kept verbatim.

§

LineSpacing(f64)

A line-spacing declaration (\doublespacing): multiplies the \baselineskip of subsequent \\-stacked lines in the enclosing multi-line list (setspace’s \baselinestretch, 10 pt ladder value). Produces no glyphs; inert inside grids, whose row rule is the environment’s own.

§

MathFont

A math-alphabet command applied to one argument.

Fields

§font: MathFont

Which alphabet.

§body: Box<Node>

The argument.

§

Phantom

A phantom box.

Fields

§kind: PhantomKind

Which dimensions it occupies.

§body: Box<Node>

The hidden body.

§

Stack

\stackrel/\overset/\underset.

Fields

§kind: StackKind

Which flavor.

§annotation: Box<Node>

The small stacked element (top for stackrel/overset, bottom for underset).

§base: Box<Node>

The base.

§

XArrow

\xrightarrow[below]{above} / \xmapsto[below]{above}: a drawn arrow stretched to its script-style labels, spaced as a relation.

Fields

§mapsto: bool

True for \xmapsto (the origin-bar band).

§above: Box<Node>

The mandatory above-label (a List node).

§below: Option<Box<Node>>

The optional below-label (a List node).

§

Space(SpaceKind)

An explicit spacing command.

§

Tie

~ — a tie (non-breaking interword space).

§

Linebreak

\\ — a line break (or, at an environment’s own level, the row separator, in which case it is consumed by the environment).

§

AlignTab

& — an alignment tab (or, at an environment’s own level, the cell separator, in which case it is consumed by the environment). Kept as a node at the top level because the Tex surface wraps whole strings in an align*-class environment.

§

AlignBlock

A line-alignment environment (flushleft, center, flushright): a text-mode block whose \\-split lines are aligned within the widest line’s width. Lines are NodeKind::List nodes.

Fields

§align: LineAlign

The line alignment.

§lines: Vec<Node>

The lines, in order.

§

Environment

A \begin{name} … \end{name} environment. Cells are NodeKind::List nodes.

Fields

§name: String

Environment name (array, cases, …).

§spec: Option<String>

The column-spec argument (array only), kept verbatim.

§rows: Vec<Vec<Node>>

Rows of cells.

§

Fragment(FragmentKind)

A structural fragment: the Tex surface’s multi-argument idiom makes each literal argument its own corpus string, so a piece may be a substring of a balanced whole ("{a", "b}", "\right)"). The grammar accepts these at the top level and marks them explicitly — never silently.

Trait Implementations§

Source§

impl Clone for NodeKind

Source§

fn clone(&self) -> NodeKind

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 NodeKind

Source§

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

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

impl PartialEq for NodeKind

Source§

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

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

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for NodeKind

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