pub fn parse(input: &str) -> Result<MathNode, ParseError>Expand description
Parse a LaTeX math string into a MathNode using a fresh color table.
Accepts raw math, $...$, $$...$$, \(...\), or \[...\]. Binding of
_ / ^ / primes is Pratt-style (tight postfix on the nucleus).
§Arguments
input— math source, with or without delimiter fences.
§Returns
The typed AST, or a ParseError naming the problem.
§Errors
ParseError::Unknown— command is not in the catalog.ParseError::Unsupported— known construct this crate will not invent.ParseError::Malformed— syntactically invalid input.ParseError::UnmatchedDelimiter—\leftwithout\right(or vice versa).ParseError::TrailingBackslash— input ended with a stray\.
§Examples
use latex_rust::parse;
let ast = parse(r"\frac{1}{2}").unwrap();
assert_eq!(ast.gold(), r#"(frac (atom Ord "1") (atom Ord "2"))"#);