Skip to main content

MathNode

Enum MathNode 

Source
pub enum MathNode {
Show 34 variants Atom(char, AtomKind), Fraction(Box<MathNode>, Box<MathNode>), Radical(Option<Box<MathNode>>, Box<MathNode>), Superscript(Box<MathNode>, Box<MathNode>), Subscript(Box<MathNode>, Box<MathNode>), SubSup(Box<MathNode>, Box<MathNode>, Box<MathNode>), Delimited(Delimiter, Box<MathNode>, Delimiter), SizedDelim(Delimiter, DelimSize, AtomKind), Row(Vec<MathNode>), Matrix(MatrixStyle, Vec<ColSpec>, Vec<EnvRow>), Substack(Vec<MathNode>), Ref(String), Tag { star: bool, body: Box<MathNode>, }, Label(String), NoNumber, Hline, Intertext(Box<MathNode>), Sum(Option<Box<MathNode>>, Option<Box<MathNode>>), Integral(IntegralKind, Option<Box<MathNode>>, Option<Box<MathNode>>), Product(Option<Box<MathNode>>, Option<Box<MathNode>>), Limit(Option<Box<MathNode>>), OverUnder(Box<MathNode>, Option<Box<MathNode>>, Option<Box<MathNode>>), Accent(Box<MathNode>, AccentKind), CancelTo(Box<MathNode>, Box<MathNode>), Text(String, TextStyle), Space(SpaceKind), Operator(String, bool), Symbol(String), Color(Color, Box<MathNode>), TextColor(Color, Box<MathNode>), ColorBox(Color, Box<MathNode>), FColorBox(Color, Color, Box<MathNode>), Strut(Dim, Dim), Phantom(PhantomKind, Box<MathNode>),
}
Expand description

Typed math-mode syntax tree.

Produced by crate::parse(). MathNode::gold is the gold-stable debug form.

§Examples

use latex_rust::parse;

let n = parse("x^2").unwrap();
assert!(n.gold().contains("sup"));

Variants§

§

Atom(char, AtomKind)

Single character with a TeX atom class.

§

Fraction(Box<MathNode>, Box<MathNode>)

\frac / \dfrac / \tfrac / \cfrac / {a \over b}.

§

Radical(Option<Box<MathNode>>, Box<MathNode>)

\sqrt / \sqrt[n]. Index None is a square root.

§

Superscript(Box<MathNode>, Box<MathNode>)

x^{}

§

Subscript(Box<MathNode>, Box<MathNode>)

x_{}

§

SubSup(Box<MathNode>, Box<MathNode>, Box<MathNode>)

x_{}^{}

§

Delimited(Delimiter, Box<MathNode>, Delimiter)

\left ... \right

§

SizedDelim(Delimiter, DelimSize, AtomKind)

\big / \Big / \bigg / \Bigg (and l/r/m forms).

§

Row(Vec<MathNode>)

Horizontal list of nodes.

§

Matrix(MatrixStyle, Vec<ColSpec>, Vec<EnvRow>)

Matrix or multiline environment. colspec is the {array} preamble (empty otherwise).

§

Substack(Vec<MathNode>)

\substack{...} — stacked script-style lines.

§

Ref(String)

\ref{key}

§

Tag

\tag{...} / \tag*{...} (peeled into EnvRow when inside an environment).

Fields

§star: bool

\tag*

§body: Box<MathNode>

Tag body.

§

Label(String)

\label{key}

§

NoNumber

\nonumber / \notag

§

Hline

\hline (peeled into EnvRow::Hline in environments).

§

Intertext(Box<MathNode>)

\intertext{...}

§

Sum(Option<Box<MathNode>>, Option<Box<MathNode>>)

\sum with optional lower / upper limits.

§

Integral(IntegralKind, Option<Box<MathNode>>, Option<Box<MathNode>>)

\int family with optional limits.

§

Product(Option<Box<MathNode>>, Option<Box<MathNode>>)

\prod with optional limits.

§

Limit(Option<Box<MathNode>>)

\lim with optional subscript.

§

OverUnder(Box<MathNode>, Option<Box<MathNode>>, Option<Box<MathNode>>)

\overset / \underset / \stackrel (base, over, under).

§

Accent(Box<MathNode>, AccentKind)

Accent or decoration on a nucleus.

§

CancelTo(Box<MathNode>, Box<MathNode>)

\cancelto{value}{expr}

§

Text(String, TextStyle)

Styled character run (\mathrm, \text, …).

§

Space(SpaceKind)

Explicit math skip.

§

Operator(String, bool)

Named operator (\sin). The flag is \limits vs \nolimits.

§

Symbol(String)

Named glyph (\alpha, \times). The string is the control-sequence name.

§

Color(Color, Box<MathNode>)

\color applied to a following math list.

§

TextColor(Color, Box<MathNode>)

\textcolor{...}{...}

§

ColorBox(Color, Box<MathNode>)

\colorbox{...}{...}

§

FColorBox(Color, Color, Box<MathNode>)

\fcolorbox{border}{fill}{body}

§

Strut(Dim, Dim)

Vertical strut (height, depth) in em.

§

Phantom(PhantomKind, Box<MathNode>)

\phantom family.

Implementations§

Source§

impl MathNode

Source

pub fn gold(&self) -> String

Gold-stable S-expression. One space between items; no trailing space.

Trait Implementations§

Source§

impl Clone for MathNode

Source§

fn clone(&self) -> MathNode

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 MathNode

Source§

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

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

impl Eq for MathNode

Source§

impl PartialEq for MathNode

Source§

fn eq(&self, other: &MathNode) -> 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 MathNode

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<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> 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> 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<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> SerializableAny for T
where T: 'static + Any + Clone + for<'a> Send + Sync,

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.