Accept the starred operatorname form

This commit is contained in:
gloamxun committed 2026-10-20 19:09:03 +08:00
1 parent f3bbe4098b
commit c72f612431
1 file changed
+11
+11
View File
@@ -918,6 +918,9 @@ fn parse_atom(chars: &[char], index: usize) -> (MathAtom, usize) {
} }
"operatorname" => { "operatorname" => {
let mut after = next; let mut after = next;
if chars.get(after) == Some(&'*') {
after += 1;
}
if chars.get(after) == Some(&'{') { if chars.get(after) == Some(&'{') {
after += 1; after += 1;
} }
@@ -1265,6 +1268,14 @@ mod tests {
assert_eq!(under.height, plain.height); assert_eq!(under.height, plain.height);
} }
#[test]
fn operatorname_star_does_not_emit_a_symbol() {
let font = Cmr10Metrics::default();
let plain = layout_math(&parse_math(r"\operatorname{argmax}"), &font);
let starred = layout_math(&parse_math(r"\operatorname*{argmax}"), &font);
assert_eq!(plain.width, starred.width);
assert_eq!(plain.height, starred.height);
}
#[test] #[test]
fn operatorname_becomes_upright_text() { fn operatorname_becomes_upright_text() {
let font = Cmr10Metrics::default(); let font = Cmr10Metrics::default();