Keep relation spacing for pmod and negated atoms
This commit is contained in:
1 parent
fd3f0ffae5
commit
33125d1f16
2 files changed
+18
-11
No files matched your search
@@ -158,6 +158,7 @@ fn atom_class(atom: &MathAtom) -> MathClass {
|
||||
MathAtom::Symbol(character) => math_class(*character),
|
||||
MathAtom::Classed { class, .. } => *class,
|
||||
MathAtom::Row(atoms) => atoms.last().map(atom_class).unwrap_or(MathClass::Ordinary),
|
||||
MathAtom::Negated { base } => atom_class(base),
|
||||
_ => MathClass::Ordinary,
|
||||
}
|
||||
}
|
||||
@@ -761,11 +762,14 @@ fn parse_atom(chars: &[char], index: usize) -> (MathAtom, usize) {
|
||||
"pmod" => {
|
||||
let (inner, after) = parse_atom(chars, next);
|
||||
(
|
||||
MathAtom::Row(vec![
|
||||
MathAtom::Text("(mod ".to_owned()),
|
||||
inner,
|
||||
MathAtom::Text(")".to_owned()),
|
||||
]),
|
||||
MathAtom::Classed {
|
||||
class: MathClass::Relation,
|
||||
body: Box::new(MathAtom::Row(vec![
|
||||
MathAtom::Text("(mod ".to_owned()),
|
||||
inner,
|
||||
MathAtom::Text(")".to_owned()),
|
||||
])),
|
||||
},
|
||||
after,
|
||||
)
|
||||
}
|
||||
@@ -1003,12 +1007,13 @@ mod tests {
|
||||
let MathAtom::Row(atoms) = parsed else {
|
||||
panic!("expected row")
|
||||
};
|
||||
let MathAtom::Row(inner) = &atoms[0] else {
|
||||
panic!("expected inner row")
|
||||
};
|
||||
assert_eq!(inner.len(), 3);
|
||||
assert!(matches!(&inner[0], MathAtom::Text(text) if text == "(mod "));
|
||||
assert!(matches!(&inner[2], MathAtom::Text(text) if text == ")"));
|
||||
assert!(matches!(
|
||||
&atoms[0],
|
||||
MathAtom::Classed {
|
||||
class: MathClass::Relation,
|
||||
..
|
||||
}
|
||||
));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in new issue
Block a user