Lay out ensuremath bodies as math

This commit is contained in:
gloamxun committed 2026-10-26 04:14:38 +08:00
1 parent 0340878909
commit 0c8228eced
4 files changed
+87 -3

No files matched your search

+14
View File
@@ -2186,6 +2186,10 @@ fn parse_atom(chars: &[char], index: usize) -> (MathAtom, usize) {
end,
)
}
"ensuremath" => match read_braced_text(chars, next) {
Some((inner, after)) => (parse_math(&inner), after),
None => (MathAtom::Symbol('?'), next),
},
"operatorname" => {
let mut after = next;
while chars.get(after) == Some(&'\u{0}')
@@ -3217,6 +3221,16 @@ mod tests {
let limited = layout_math(&parse_math(r"\mathop{argmax}_{x}"), &font);
assert!(limited.depth > plain.depth);
}
#[test]
fn ensuremath_inside_math_is_transparent() {
let font = Cmr10Metrics::Roman;
let with = layout_math(&parse_math("\\ensuremath{a+b}"), &font);
let plain = layout_math(&parse_math("a+b"), &font);
assert_eq!(with.width, plain.width);
assert_eq!(with.height, plain.height);
assert_eq!(with.depth, plain.depth);
}
#[test]
fn operator_names_are_upright_and_stack_when_starred() {
let font = Cmr10Metrics::default();