Crates.io | asciimath-rs |
lib.rs | asciimath-rs |
version | 0.6.2 |
source | src |
created_at | 2020-08-04 15:28:25.081968 |
updated_at | 2021-12-06 19:49:39.169334 |
description | AsciiMath parser |
homepage | |
repository | https://github.com/trivernis/asciimath-rs |
max_upload_size | |
id | 272920 |
size | 110,349 |
This project aims to implement a fully functional AsciiMath parser for rust. It's part of the snekdown parser project.
See the spec.
use asciimath_rs::format::mathml::ToMathML;
fn main() {
let expression = asciimath_rs::parse("sin(2x) + 3".to_string());
let mathml_string = expression.to_mathml();
}
use asciimath_rs::parsing::tokenizer::Tokenizer;
use asciimath_rs::parsing::tree_parser::TreeParser;
use asciimath_rs::format::mathml::ToMathML;
fn main() {
let mut tokenizer = Tokenizer::new("cos(2) - alpha".to_string());
let tokens = tokenizer.parse();
let mut tree_parser = TreeParser::new(tokens);
let expression = tree_parser.parse();
let mathml_string = expression.to_mathml();
}
As seen in the less simple example the parsing works in two steps. In the first step the raw input string is analyzed and converted into Tokens that represent the syntactic meaning of a sequence of characters. The second step takes the flat vector of tokens and converts it into a tree in a depth first way.
The resulting expression can then be converted into MathML with the default ToMathML
trait implementation.
This project is Apache 2.0 licensed.