Attach math scripts across ignored spaces
TeX ignores spaces in math mode, but parse_sequence looked for _ or ^ at the
raw next index. Source such as \alpha _{i} therefore rendered the underscore
as a literal symbol at full size. Skip math spaces after the base before
checking for scripts.
The arXiv equation now has real subscripts and superscripts instead of literal
underscores. Test count is 1078.
This commit is contained in:
1 parent
742986e4dd
commit
d5de8b9fe6
6 files changed
+17
-9
No files matched your search
@@ -1615,6 +1615,9 @@ fn parse_sequence(
|
||||
return (MathAtom::Row(vec![atom]), end);
|
||||
}
|
||||
let (mut atom, mut next) = parse_atom(chars, index);
|
||||
// TeX ignores spaces in math; `\alpha _{i}` must still attach the
|
||||
// script to the preceding atom.
|
||||
next = skip_math_space(chars, next);
|
||||
let mut sub = None;
|
||||
let mut sup = None;
|
||||
loop {
|
||||
@@ -3909,4 +3912,9 @@ mod tagged_equation_tests {
|
||||
assert_eq!(tagged.height, plain.height.max(7 * 65_536));
|
||||
assert_eq!(tagged.depth, plain.depth.max(2 * 65_536));
|
||||
}
|
||||
#[test]
|
||||
fn whitespace_before_a_script_still_attaches() {
|
||||
let atom = parse_math(r"\alpha _{i}");
|
||||
assert!(format!("{atom:?}").contains("Script"), "{atom:?}");
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user