Add common fence delimiter symbols

This commit is contained in:
gloamxun committed 2026-10-20 19:15:16 +08:00
1 parent df511602cf
commit dc8282f707
1 file changed
+18
+18
View File
@@ -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();