Accept middle math delimiters
This commit is contained in:
1 parent
6769a6e80b
commit
ebab0eca05
2 files changed
+12
No files matched your search
@@ -382,6 +382,10 @@ fn parse_atom(chars: &[char], index: usize) -> (MathAtom, usize) {
|
|||||||
after,
|
after,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
"middle" => {
|
||||||
|
let delimiter = chars.get(next).copied().unwrap_or('|');
|
||||||
|
(MathAtom::Symbol(delimiter), next + 1)
|
||||||
|
}
|
||||||
"left" => {
|
"left" => {
|
||||||
let left = chars.get(next).copied().unwrap_or('(');
|
let left = chars.get(next).copied().unwrap_or('(');
|
||||||
let (body, after) = parse_sequence(chars, next + 1, false, true);
|
let (body, after) = parse_sequence(chars, next + 1, false, true);
|
||||||
@@ -473,6 +477,13 @@ mod tests {
|
|||||||
assert!(indexed.height > plain.height);
|
assert!(indexed.height > plain.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn middle_delimiter_adds_a_symbol() {
|
||||||
|
let font = Cmr10Metrics::default();
|
||||||
|
let without = layout_math(&parse_math("\\left(ab\\right)"), &font);
|
||||||
|
let with = layout_math(&parse_math("\\left(a\\middle|b\\right)"), &font);
|
||||||
|
assert!(with.width > without.width);
|
||||||
|
}
|
||||||
#[test]
|
#[test]
|
||||||
fn empty_left_delimiter_has_no_width() {
|
fn empty_left_delimiter_has_no_width() {
|
||||||
let font = Cmr10Metrics::default();
|
let font = Cmr10Metrics::default();
|
||||||
|
|||||||
@@ -104,6 +104,7 @@ overfull ratio 4.11, badness 6942. TeX rejects the underfull candidate under
|
|||||||
its tolerance but still emits the moderately overfull 5-word line. Reproducing
|
its tolerance but still emits the moderately overfull 5-word line. Reproducing
|
||||||
this needs a two-pass tolerance algorithm with an emergency overfull pass, not
|
this needs a two-pass tolerance algorithm with an emergency overfull pass, not
|
||||||
a single cost function.
|
a single cost function.
|
||||||
|
- `\middle|` inside `\left...\right` is accepted as a delimiter symbol (not yet stretched).
|
||||||
- `\sqrt[n]{x}` carries an optional degree atom; `\left.` is an empty
|
- `\sqrt[n]{x}` carries an optional degree atom; `\left.` is an empty
|
||||||
delimiter with zero width.
|
delimiter with zero width.
|
||||||
- `MathAtom::Accent { accent, base }` parses `\hat`, `\widehat`,
|
- `MathAtom::Accent { accent, base }` parses `\hat`, `\widehat`,
|
||||||
|
|||||||
Reference in new issue
Block a user