Fix comma handling

pull/9/head
trivernis 4 years ago
parent f3bd761d3d
commit 7ecfd23495

@ -2,7 +2,7 @@
name = "asciimath-rs"
description = "AsciiMath parser"
repository = "https://github.com/trivernis/asciimath-rs"
version = "0.5.2"
version = "0.5.3"
authors = ["trivernis <trivernis@protonmail.com>"]
edition = "2018"
readme = "README.md"

@ -373,7 +373,7 @@ impl ToMathML for Group {
fn to_mathml(&self) -> String {
match self {
Group::Vector(v) => v.to_mathml(),
Group::MSep => ",".to_string(),
Group::MSep => "<mo>,</mo>".to_string(),
Group::Parentheses(p) => p.to_mathml(),
Group::Brackets(b) => b.to_mathml(),
Group::Braces(b) => b.to_mathml(),

@ -40,7 +40,7 @@ pub fn parse(content: String) -> Expression {
#[cfg(test)]
mod tests {
use crate::elements::group::{Brackets, Group, Matrix, Vector};
use crate::elements::group::{Brackets, Group, Matrix, Parentheses, Vector};
use crate::elements::literal::{Literal, Number};
use crate::elements::special::{Expression, Special, Sum};
use crate::elements::Element;
@ -311,7 +311,7 @@ mod tests {
#[test]
fn it_parses_vectors() {
assert_eq!(
parse("((1), (2)) - f".to_string()),
parse("((1), (2))(1,2) - f".to_string()),
Expression {
children: vec![
Element::Group(Group::Vector(Vector {
@ -328,6 +328,20 @@ mod tests {
}]
]
})),
Element::Group(Group::Parentheses(Parentheses {
inner: Expression {
children: vec![
Element::Literal(Literal::Number(Number {
number: "1".to_string()
})),
Element::Group(Group::MSep),
Element::Literal(Literal::Number(Number {
number: "2".to_string()
}))
]
}
.boxed()
})),
Element::Literal(Literal::Operation(Operation::Minus)),
Element::Literal(Literal::Function(Function::F))
]

Loading…
Cancel
Save