Parse phantom bodies as braced groups
This commit is contained in:
1 parent
9ad404acee
commit
028137a9ad
1 file changed
+18
-5
@@ -2163,14 +2163,27 @@ fn parse_atom(chars: &[char], index: usize) -> (MathAtom, usize) {
|
|||||||
}
|
}
|
||||||
"mathstrut" => (MathAtom::Strut, next),
|
"mathstrut" => (MathAtom::Strut, next),
|
||||||
"phantom" | "hphantom" | "vphantom" => {
|
"phantom" | "hphantom" | "vphantom" => {
|
||||||
let (body, after) = parse_atom(chars, next);
|
let mut after = next;
|
||||||
|
while chars.get(after) == Some(&'\u{0}')
|
||||||
|
|| chars.get(after).is_some_and(|c| c.is_whitespace())
|
||||||
|
{
|
||||||
|
after += 1;
|
||||||
|
}
|
||||||
|
let Some((inner, end)) = read_braced_text(chars, after) else {
|
||||||
|
return (MathAtom::Symbol('?'), (after + 1).min(chars.len()));
|
||||||
|
};
|
||||||
|
let (horizontal, vertical) = match command.as_str() {
|
||||||
|
"phantom" => (true, true),
|
||||||
|
"hphantom" => (true, false),
|
||||||
|
_ => (false, true),
|
||||||
|
};
|
||||||
(
|
(
|
||||||
MathAtom::Phantom {
|
MathAtom::Phantom {
|
||||||
body: Box::new(body),
|
body: Box::new(parse_math(&inner)),
|
||||||
horizontal: command != "vphantom",
|
horizontal,
|
||||||
vertical: command != "hphantom",
|
vertical,
|
||||||
},
|
},
|
||||||
after,
|
end,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
"operatorname" => {
|
"operatorname" => {
|
||||||
|
|||||||
Reference in new issue
Block a user