diff --git a/crates/texrra-tex-core/src/math.rs b/crates/texrra-tex-core/src/math.rs index a52ce24..f3ebaaa 100755 --- a/crates/texrra-tex-core/src/math.rs +++ b/crates/texrra-tex-core/src/math.rs @@ -382,6 +382,10 @@ fn parse_atom(chars: &[char], index: usize) -> (MathAtom, usize) { after, ) } + "middle" => { + let delimiter = chars.get(next).copied().unwrap_or('|'); + (MathAtom::Symbol(delimiter), next + 1) + } "left" => { let left = chars.get(next).copied().unwrap_or('('); let (body, after) = parse_sequence(chars, next + 1, false, true); @@ -473,6 +477,13 @@ mod tests { 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] fn empty_left_delimiter_has_no_width() { let font = Cmr10Metrics::default(); diff --git a/docs/TEX_CORE.md b/docs/TEX_CORE.md index 89f2446..1dc2e99 100755 --- a/docs/TEX_CORE.md +++ b/docs/TEX_CORE.md @@ -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 this needs a two-pass tolerance algorithm with an emergency overfull pass, not 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 delimiter with zero width. - `MathAtom::Accent { accent, base }` parses `\hat`, `\widehat`,