From 30464dd2144f9d0a1fcebda5776b32d413f505e6 Mon Sep 17 00:00:00 2001 From: GloamXun Date: Tue, 20 Oct 2026 13:32:48 +0800 Subject: [PATCH] Add the double-arrow math accent --- crates/texrra-tex-core/src/math.rs | 23 ++++++++++++++++++----- docs/TEX_CORE.md | 2 ++ 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/crates/texrra-tex-core/src/math.rs b/crates/texrra-tex-core/src/math.rs index 171df34..a2a0d4a 100755 --- a/crates/texrra-tex-core/src/math.rs +++ b/crates/texrra-tex-core/src/math.rs @@ -753,12 +753,12 @@ fn parse_atom(chars: &[char], index: usize) -> (MathAtom, usize) { after, ) } - "overrightarrow" | "overleftarrow" => { + "overrightarrow" | "overleftarrow" | "overleftrightarrow" => { let (base, after) = parse_atom(chars, next); - let accent = if command == "overrightarrow" { - '\u{20D7}' - } else { - '\u{20D6}' + let accent = match command.as_str() { + "overrightarrow" => '\u{20D7}', + "overleftarrow" => '\u{20D6}', + _ => '\u{20E1}', }; ( MathAtom::Accent { @@ -1068,6 +1068,19 @@ mod tests { assert!(tall.width > plain.width); } + #[test] + fn overleftrightarrow_uses_the_double_arrow_accent() { + let MathAtom::Row(atoms) = parse_math(r"\overleftrightarrow{AB}") else { + panic!("expected row") + }; + assert!(matches!( + &atoms[0], + MathAtom::Accent { + accent: '\u{20E1}', + .. + } + )); + } #[test] fn mathring_uses_the_ring_accent() { let MathAtom::Row(atoms) = parse_math(r"\mathring{x}") else { diff --git a/docs/TEX_CORE.md b/docs/TEX_CORE.md index b9d442c..209beac 100755 --- a/docs/TEX_CORE.md +++ b/docs/TEX_CORE.md @@ -237,3 +237,5 @@ v1 remains the production renderer; the route-D core is additive and tested inde `\substack{a\\b}` parses each row and stacks them as `MathAtom::StackLines`. `\mathring{x}` is the U+030A ring accent. + +`\overleftrightarrow` uses U+20E1.