Treat math style declarations as transparent

This commit is contained in:
gloamxun committed 2026-10-20 19:00:01 +08:00
1 parent 495b615220
commit 6876935e60
1 file changed
+16
+16
View File
@@ -550,6 +550,13 @@ fn parse_atom(chars: &[char], index: usize) -> (MathAtom, usize) {
}
}
return match command.as_str() {
"displaystyle" | "textstyle" | "scriptstyle" | "scriptscriptstyle" => {
let mut after = next;
while chars.get(after).is_some_and(|ch| ch.is_whitespace()) {
after += 1;
}
parse_atom(chars, after)
}
"frac" => {
let (numerator, after) = parse_atom(chars, next);
let (denominator, after) = parse_atom(chars, after);
@@ -1205,6 +1212,15 @@ mod tests {
assert!(under.depth > plain.depth);
assert_eq!(under.height, plain.height);
}
#[test]
fn math_style_commands_are_transparent() {
let font = Cmr10Metrics::default();
let plain = layout_math(&parse_math("x"), &font);
let styled = layout_math(&parse_math(r"\displaystyle{x}"), &font);
assert_eq!(plain.width, styled.width);
assert_eq!(plain.height, styled.height);
}
#[test]
fn binom_stacks_two_arguments() {
let font = Cmr10Metrics::default();