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::Symbol(character) => math_class(*character),
|
||||||
MathAtom::Classed { class, .. } => *class,
|
MathAtom::Classed { class, .. } => *class,
|
||||||
MathAtom::Row(atoms) => atoms.last().map(atom_class).unwrap_or(MathClass::Ordinary),
|
MathAtom::Row(atoms) => atoms.last().map(atom_class).unwrap_or(MathClass::Ordinary),
|
||||||
|
MathAtom::Negated { base } => atom_class(base),
|
||||||
_ => MathClass::Ordinary,
|
_ => MathClass::Ordinary,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -761,11 +762,14 @@ fn parse_atom(chars: &[char], index: usize) -> (MathAtom, usize) {
|
|||||||
"pmod" => {
|
"pmod" => {
|
||||||
let (inner, after) = parse_atom(chars, next);
|
let (inner, after) = parse_atom(chars, next);
|
||||||
(
|
(
|
||||||
MathAtom::Row(vec![
|
MathAtom::Classed {
|
||||||
MathAtom::Text("(mod ".to_owned()),
|
class: MathClass::Relation,
|
||||||
inner,
|
body: Box::new(MathAtom::Row(vec![
|
||||||
MathAtom::Text(")".to_owned()),
|
MathAtom::Text("(mod ".to_owned()),
|
||||||
]),
|
inner,
|
||||||
|
MathAtom::Text(")".to_owned()),
|
||||||
|
])),
|
||||||
|
},
|
||||||
after,
|
after,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -1003,12 +1007,13 @@ mod tests {
|
|||||||
let MathAtom::Row(atoms) = parsed else {
|
let MathAtom::Row(atoms) = parsed else {
|
||||||
panic!("expected row")
|
panic!("expected row")
|
||||||
};
|
};
|
||||||
let MathAtom::Row(inner) = &atoms[0] else {
|
assert!(matches!(
|
||||||
panic!("expected inner row")
|
&atoms[0],
|
||||||
};
|
MathAtom::Classed {
|
||||||
assert_eq!(inner.len(), 3);
|
class: MathClass::Relation,
|
||||||
assert!(matches!(&inner[0], MathAtom::Text(text) if text == "(mod "));
|
..
|
||||||
assert!(matches!(&inner[2], MathAtom::Text(text) if text == ")"));
|
}
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|||||||
@@ -202,3 +202,5 @@ for a later overlaid slash.
|
|||||||
`\noalign{...}` material in a halign source is skipped while rows are scanned.
|
`\noalign{...}` material in a halign source is skipped while rows are scanned.
|
||||||
|
|
||||||
`\bmod`/`\pmod{n}` parse to upright `mod` rows, with `\pmod` wrapping its argument in `(mod ...)`.
|
`\bmod`/`\pmod{n}` parse to upright `mod` rows, with `\pmod` wrapping its argument in `(mod ...)`.
|
||||||
|
|
||||||
|
`\pmod{n}` is a `Classed` relation, and `\not` inherits the base atom's math class for spacing.
|
||||||
Reference in new issue
Block a user