Skip to main content

parse

Function parse 

Source
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

§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"))"#);