From dc8282f707b2cb3d88a98bddb3a6e27d2445c1f7 Mon Sep 17 00:00:00 2001 From: GloamXun Date: Tue, 20 Oct 2026 19:15:16 +0800 Subject: [PATCH] Add common fence delimiter symbols --- crates/texrra-tex-core/src/math.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/crates/texrra-tex-core/src/math.rs b/crates/texrra-tex-core/src/math.rs index f67a016..724297e 100755 --- a/crates/texrra-tex-core/src/math.rs +++ b/crates/texrra-tex-core/src/math.rs @@ -581,6 +581,16 @@ fn parse_atom(chars: &[char], index: usize) -> (MathAtom, usize) { return match command.as_str() { "quad" => (MathAtom::Space(655_360), next), "qquad" => (MathAtom::Space(1_310_720), next), + "lvert" | "rvert" | "vert" => (MathAtom::Symbol('|'), next), + "lVert" | "rVert" | "Vert" => (MathAtom::Symbol('\u{2016}'), next), + "lbrace" => (MathAtom::Symbol('{'), next), + "rbrace" => (MathAtom::Symbol('}'), next), + "langle" => (MathAtom::Symbol('\u{27E8}'), next), + "rangle" => (MathAtom::Symbol('\u{27E9}'), next), + "lfloor" => (MathAtom::Symbol('\u{230A}'), next), + "rfloor" => (MathAtom::Symbol('\u{230B}'), next), + "lceil" => (MathAtom::Symbol('\u{2308}'), next), + "rceil" => (MathAtom::Symbol('\u{2309}'), next), "displaystyle" | "textstyle" | "scriptstyle" | "scriptscriptstyle" | "nonumber" | "notag" | "limits" | "nolimits" | "displaylimits" => { let mut after = next; @@ -1278,6 +1288,14 @@ mod tests { assert_eq!(plain.height, numbered.height); } + #[test] + fn fence_delimiters_have_widths() { + let font = Cmr10Metrics::default(); + for source in [r"\lvert x \rvert", r"\lfloor x \rfloor", r"\lceil x \rceil"] { + let boxed = layout_math(&parse_math(source), &font); + assert!(boxed.width > layout_math(&parse_math(r"x"), &font).width); + } + } #[test] fn pmod_wraps_the_argument_and_bmod_stays_inline() { let font = Cmr10Metrics::default();