Skip to main content

parse_equation

Function parse_equation 

Source
pub fn parse_equation(input: &str) -> EqNode
Expand description

Parse a LaTeX math string into an EqNode tree.

Accepts standard LaTeX math-mode markup as well as bareword shortcuts (pi, sqrt(x), int_0^1, etc.). Never returns an error — malformed input produces a best-effort tree.

§Examples

use rust_latex_parser::{parse_equation, EqNode};

// Standard LaTeX
let tree = parse_equation("\\frac{a}{b}");
assert!(matches!(tree, EqNode::Frac(_, _)));

// Bareword shortcuts
let tree = parse_equation("pi r^2");

// Complex expressions
let tree = parse_equation("\\int_0^\\infty e^{-x^2} dx = \\sqrt{\\pi}");