Place starred operatorname limits below the operator
This commit is contained in:
1 parent
b8a135d2b6
commit
ae8f81b1a2
1 file changed
+17
-2
@@ -993,7 +993,8 @@ fn parse_atom(chars: &[char], index: usize) -> (MathAtom, usize) {
|
|||||||
}
|
}
|
||||||
"operatorname" => {
|
"operatorname" => {
|
||||||
let mut after = next;
|
let mut after = next;
|
||||||
if chars.get(after) == Some(&'*') {
|
let starred = chars.get(after) == Some(&'*');
|
||||||
|
if starred {
|
||||||
after += 1;
|
after += 1;
|
||||||
}
|
}
|
||||||
if chars.get(after) == Some(&'{') {
|
if chars.get(after) == Some(&'{') {
|
||||||
@@ -1010,7 +1011,12 @@ fn parse_atom(chars: &[char], index: usize) -> (MathAtom, usize) {
|
|||||||
if after < chars.len() {
|
if after < chars.len() {
|
||||||
after += 1;
|
after += 1;
|
||||||
}
|
}
|
||||||
(MathAtom::Text(text), after)
|
let atom = MathAtom::Text(text);
|
||||||
|
if starred {
|
||||||
|
parse_limits(chars, after, atom)
|
||||||
|
} else {
|
||||||
|
(atom, after)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
"text" | "mathrm" => {
|
"text" | "mathrm" => {
|
||||||
let mut after = next;
|
let mut after = next;
|
||||||
@@ -1389,6 +1395,15 @@ mod tests {
|
|||||||
MathAtom::Row(atoms) if matches!(&atoms[0], MathAtom::Text(text) if text == "mod")
|
MathAtom::Row(atoms) if matches!(&atoms[0], MathAtom::Text(text) if text == "mod")
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn starred_operatorname_takes_limits_below() {
|
||||||
|
let font = Cmr10Metrics::default();
|
||||||
|
let plain = layout_math(&parse_math(r"\operatorname*{argmax}"), &font);
|
||||||
|
let limited = layout_math(&parse_math(r"\operatorname*{argmax}_{x}"), &font);
|
||||||
|
assert!(limited.depth > plain.depth);
|
||||||
|
assert!(limited.width >= plain.width);
|
||||||
|
}
|
||||||
#[test]
|
#[test]
|
||||||
fn operatorname_star_does_not_emit_a_symbol() {
|
fn operatorname_star_does_not_emit_a_symbol() {
|
||||||
let font = Cmr10Metrics::default();
|
let font = Cmr10Metrics::default();
|
||||||
|
|||||||
Reference in new issue
Block a user