Skip to main content

ParseNode

Enum ParseNode 

Source
pub enum ParseNode {
Show 58 variants Atom { mode: Mode, family: AtomFamily, text: String, loc: Option<SourceLocation>, }, MathOrd { mode: Mode, text: String, loc: Option<SourceLocation>, }, TextOrd { mode: Mode, text: String, loc: Option<SourceLocation>, }, OpToken { mode: Mode, text: String, loc: Option<SourceLocation>, }, AccentToken { mode: Mode, text: String, loc: Option<SourceLocation>, }, SpacingNode { mode: Mode, text: String, loc: Option<SourceLocation>, }, OrdGroup { mode: Mode, body: Vec<ParseNode>, semisimple: Option<bool>, loc: Option<SourceLocation>, }, SupSub { mode: Mode, base: Option<Box<ParseNode>>, sup: Option<Box<ParseNode>>, sub: Option<Box<ParseNode>>, loc: Option<SourceLocation>, }, GenFrac { mode: Mode, continued: bool, numer: Box<ParseNode>, denom: Box<ParseNode>, has_bar_line: bool, left_delim: Option<String>, right_delim: Option<String>, bar_size: Option<Measurement>, loc: Option<SourceLocation>, }, Sqrt { mode: Mode, body: Box<ParseNode>, index: Option<Box<ParseNode>>, loc: Option<SourceLocation>, }, Accent { mode: Mode, label: String, is_stretchy: Option<bool>, is_shifty: Option<bool>, base: Box<ParseNode>, loc: Option<SourceLocation>, }, AccentUnder { mode: Mode, label: String, is_stretchy: Option<bool>, is_shifty: Option<bool>, base: Box<ParseNode>, loc: Option<SourceLocation>, }, Op { mode: Mode, limits: bool, always_handle_sup_sub: Option<bool>, suppress_base_shift: Option<bool>, parent_is_sup_sub: bool, symbol: bool, name: Option<String>, body: Option<Vec<ParseNode>>, loc: Option<SourceLocation>, }, OperatorName { mode: Mode, body: Vec<ParseNode>, always_handle_sup_sub: bool, limits: bool, parent_is_sup_sub: bool, loc: Option<SourceLocation>, }, Font { mode: Mode, font: String, body: Box<ParseNode>, loc: Option<SourceLocation>, }, Text { mode: Mode, body: Vec<ParseNode>, font: Option<String>, loc: Option<SourceLocation>, }, Color { mode: Mode, color: String, body: Vec<ParseNode>, loc: Option<SourceLocation>, }, ColorToken { mode: Mode, color: String, loc: Option<SourceLocation>, }, Size { mode: Mode, value: Measurement, is_blank: bool, loc: Option<SourceLocation>, }, Styling { mode: Mode, style: StyleStr, body: Vec<ParseNode>, loc: Option<SourceLocation>, }, Sizing { mode: Mode, size: u8, body: Vec<ParseNode>, loc: Option<SourceLocation>, }, DelimSizing { mode: Mode, size: u8, mclass: String, delim: String, loc: Option<SourceLocation>, }, LeftRight { mode: Mode, body: Vec<ParseNode>, left: String, right: String, right_color: Option<String>, loc: Option<SourceLocation>, }, LeftRightRight { mode: Mode, delim: String, color: Option<String>, loc: Option<SourceLocation>, }, Middle { mode: Mode, delim: String, loc: Option<SourceLocation>, }, Overline { mode: Mode, body: Box<ParseNode>, loc: Option<SourceLocation>, }, Underline { mode: Mode, body: Box<ParseNode>, loc: Option<SourceLocation>, }, Rule { mode: Mode, shift: Option<Measurement>, width: Measurement, height: Measurement, loc: Option<SourceLocation>, }, Kern { mode: Mode, dimension: Measurement, loc: Option<SourceLocation>, }, Phantom { mode: Mode, body: Vec<ParseNode>, loc: Option<SourceLocation>, }, VPhantom { mode: Mode, body: Box<ParseNode>, loc: Option<SourceLocation>, }, Smash { mode: Mode, body: Box<ParseNode>, smash_height: bool, smash_depth: bool, loc: Option<SourceLocation>, }, MClass { mode: Mode, mclass: String, body: Vec<ParseNode>, is_character_box: bool, loc: Option<SourceLocation>, }, Array {
Show 13 fields mode: Mode, body: Vec<Vec<ParseNode>>, row_gaps: Vec<Option<Measurement>>, hlines_before_row: Vec<Vec<bool>>, cols: Option<Vec<AlignSpec>>, col_separation_type: Option<String>, hskip_before_and_after: Option<bool>, add_jot: Option<bool>, arraystretch: f64, tags: Option<Vec<ArrayTag>>, leqno: Option<bool>, is_cd: Option<bool>, loc: Option<SourceLocation>,
}, Environment { mode: Mode, name: String, name_group: Box<ParseNode>, loc: Option<SourceLocation>, }, Cr { mode: Mode, new_line: bool, size: Option<Measurement>, loc: Option<SourceLocation>, }, Infix { mode: Mode, replace_with: String, size: Option<Measurement>, loc: Option<SourceLocation>, }, Internal { mode: Mode, loc: Option<SourceLocation>, }, Verb { mode: Mode, body: String, star: bool, loc: Option<SourceLocation>, }, Href { mode: Mode, href: String, body: Vec<ParseNode>, loc: Option<SourceLocation>, }, Url { mode: Mode, url: String, loc: Option<SourceLocation>, }, Raw { mode: Mode, string: String, loc: Option<SourceLocation>, }, HBox { mode: Mode, body: Vec<ParseNode>, loc: Option<SourceLocation>, }, HorizBrace { mode: Mode, label: String, is_over: bool, base: Box<ParseNode>, loc: Option<SourceLocation>, }, Enclose { mode: Mode, label: String, background_color: Option<String>, border_color: Option<String>, body: Box<ParseNode>, loc: Option<SourceLocation>, }, Lap { mode: Mode, alignment: String, body: Box<ParseNode>, loc: Option<SourceLocation>, }, MathChoice { mode: Mode, display: Vec<ParseNode>, text: Vec<ParseNode>, script: Vec<ParseNode>, scriptscript: Vec<ParseNode>, loc: Option<SourceLocation>, }, RaiseBox { mode: Mode, dy: Measurement, body: Box<ParseNode>, loc: Option<SourceLocation>, }, VCenter { mode: Mode, body: Box<ParseNode>, loc: Option<SourceLocation>, }, XArrow { mode: Mode, label: String, body: Box<ParseNode>, below: Option<Box<ParseNode>>, loc: Option<SourceLocation>, }, Pmb { mode: Mode, mclass: String, body: Vec<ParseNode>, loc: Option<SourceLocation>, }, Tag { mode: Mode, body: Vec<ParseNode>, tag: Vec<ParseNode>, loc: Option<SourceLocation>, }, Html { mode: Mode, attributes: HashMap<String, String>, body: Vec<ParseNode>, loc: Option<SourceLocation>, }, HtmlMathMl { mode: Mode, html: Vec<ParseNode>, mathml: Vec<ParseNode>, loc: Option<SourceLocation>, }, IncludeGraphics { mode: Mode, alt: String, width: Measurement, height: Measurement, totalheight: Measurement, src: String, loc: Option<SourceLocation>, }, CdLabel { mode: Mode, side: String, label: Box<ParseNode>, loc: Option<SourceLocation>, }, CdLabelParent { mode: Mode, fragment: Box<ParseNode>, loc: Option<SourceLocation>, }, CdArrow { mode: Mode, direction: String, label_above: Option<Box<ParseNode>>, label_below: Option<Box<ParseNode>>, loc: Option<SourceLocation>, },
}
Expand description

The main AST node type. Each variant corresponds to a KaTeX ParseNode type.

Serializes to JSON with "type": "variant_name" to match KaTeX’s format, enabling direct structural comparison.

Variants§

§

Atom

Fields

§mode: Mode
§family: AtomFamily
§text: String
§

MathOrd

Fields

§mode: Mode
§text: String
§

TextOrd

Fields

§mode: Mode
§text: String
§

OpToken

Fields

§mode: Mode
§text: String
§

AccentToken

Fields

§mode: Mode
§text: String
§

SpacingNode

Fields

§mode: Mode
§text: String
§

OrdGroup

Fields

§mode: Mode
§semisimple: Option<bool>
§

SupSub

§

GenFrac

Fields

§mode: Mode
§continued: bool
§has_bar_line: bool
§left_delim: Option<String>
§right_delim: Option<String>
§

Sqrt

§

Accent

Fields

§mode: Mode
§label: String
§is_stretchy: Option<bool>
§is_shifty: Option<bool>
§

AccentUnder

Fields

§mode: Mode
§label: String
§is_stretchy: Option<bool>
§is_shifty: Option<bool>
§

Op

Fields

§mode: Mode
§limits: bool
§always_handle_sup_sub: Option<bool>
§suppress_base_shift: Option<bool>
§parent_is_sup_sub: bool
§symbol: bool
§

OperatorName

Fields

§mode: Mode
§always_handle_sup_sub: bool
§limits: bool
§parent_is_sup_sub: bool
§

Font

§

Text

§

Color

Fields

§mode: Mode
§color: String
§

ColorToken

Fields

§mode: Mode
§color: String
§

Size

Fields

§mode: Mode
§is_blank: bool
§

Styling

§

Sizing

Fields

§mode: Mode
§size: u8
§

DelimSizing

Fields

§mode: Mode
§size: u8
§mclass: String
§delim: String
§

LeftRight

Fields

§mode: Mode
§left: String
§right: String
§right_color: Option<String>
§

LeftRightRight

Fields

§mode: Mode
§delim: String
§

Middle

Fields

§mode: Mode
§delim: String
§

Overline

§

Underline

§

Rule

§

Kern

Fields

§mode: Mode
§dimension: Measurement
§

Phantom

§

VPhantom

§

Smash

Fields

§mode: Mode
§smash_height: bool
§smash_depth: bool
§

MClass

Fields

§mode: Mode
§mclass: String
§is_character_box: bool
§

Array

Fields

§mode: Mode
§hlines_before_row: Vec<Vec<bool>>
§col_separation_type: Option<String>
§hskip_before_and_after: Option<bool>
§add_jot: Option<bool>
§arraystretch: f64
§leqno: Option<bool>
§is_cd: Option<bool>
§

Environment

Fields

§mode: Mode
§name: String
§name_group: Box<ParseNode>
§

Cr

Fields

§mode: Mode
§new_line: bool
§

Infix

Fields

§mode: Mode
§replace_with: String
§

Internal

Fields

§mode: Mode
§

Verb

Fields

§mode: Mode
§body: String
§star: bool
§

Href

§

Url

Fields

§mode: Mode
§

Raw

Fields

§mode: Mode
§string: String
§

HBox

§

HorizBrace

Fields

§mode: Mode
§label: String
§is_over: bool
§

Enclose

Fields

§mode: Mode
§label: String
§background_color: Option<String>
§border_color: Option<String>
§

Lap

Fields

§mode: Mode
§alignment: String
§

MathChoice

Fields

§mode: Mode
§display: Vec<ParseNode>
§script: Vec<ParseNode>
§scriptscript: Vec<ParseNode>
§

RaiseBox

§

VCenter

§

XArrow

§

Pmb

Fields

§mode: Mode
§mclass: String
§

Tag

§

Html

Fields

§mode: Mode
§attributes: HashMap<String, String>
§

HtmlMathMl

§

IncludeGraphics

Fields

§mode: Mode
§totalheight: Measurement
§

CdLabel

Fields

§mode: Mode
§side: String
§

CdLabelParent

Fields

§mode: Mode
§fragment: Box<ParseNode>
§

CdArrow

Fields

§mode: Mode
§direction: String

“right”, “left”, “up”, “down”, “horiz_eq”, “vert_eq”, “none”

§label_above: Option<Box<ParseNode>>

For right/left arrows: label above the shaft. For up/down arrows: label to the left of the shaft.

§label_below: Option<Box<ParseNode>>

For right/left arrows: label below the shaft. For up/down arrows: label to the right of the shaft.

Implementations§

Source§

impl ParseNode

Source

pub fn mode(&self) -> Mode

Source

pub fn type_name(&self) -> &'static str

Source

pub fn is_symbol_node(&self) -> bool

Check if this node is a symbol node (atom or non-atom symbol).

Source

pub fn symbol_text(&self) -> Option<&str>

Get the text of a symbol node.

Source

pub fn normalize_argument(arg: ParseNode) -> ParseNode

Normalize an argument: if it’s an ordgroup with a single element, unwrap it.

Source

pub fn ord_argument(arg: ParseNode) -> Vec<ParseNode>

Convert an argument to a list: if ordgroup, return body; otherwise wrap in vec.

Trait Implementations§

Source§

impl Clone for ParseNode

Source§

fn clone(&self) -> ParseNode

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ParseNode

Source§

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

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

impl<'de> Deserialize<'de> for ParseNode

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for ParseNode

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

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 = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,