From e0e797c27d4eff3fbca2a182aee2700f20ed6c21 Mon Sep 17 00:00:00 2001 From: Liam Murphy Date: Tue, 18 Jul 2023 00:08:19 +1000 Subject: Classify `dots.c`, `dots.down`, `dots.up` and `dots.v` as normal (#1726) Fixes #713. They were previously classified by Unicode as relations, which caused a '+' sign after one of them to be treated as a unary operator rather than a binary operator. This PR overrides the Unicode classification and classifies them as normal instead, which causes a '+' sign after one of them to be properly treated as a binary operator. --- crates/typst-library/src/math/fragment.rs | 1 + tests/ref/math/spacing.png | Bin 18271 -> 17881 bytes tests/typ/math/spacing.typ | 3 ++- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/typst-library/src/math/fragment.rs b/crates/typst-library/src/math/fragment.rs index 1a90eaad..85fdf6a6 100644 --- a/crates/typst-library/src/math/fragment.rs +++ b/crates/typst-library/src/math/fragment.rs @@ -216,6 +216,7 @@ impl GlyphFragment { pub fn with_id(ctx: &MathContext, c: char, id: GlyphId, span: Span) -> Self { let class = match c { ':' => Some(MathClass::Relation), + '⋯' | '⋱' | '⋰' | '⋮' => Some(MathClass::Normal), _ => unicode_math_class::class(c), }; let mut fragment = Self { diff --git a/tests/ref/math/spacing.png b/tests/ref/math/spacing.png index abcfae80..5e717eff 100644 Binary files a/tests/ref/math/spacing.png and b/tests/ref/math/spacing.png differ diff --git a/tests/typ/math/spacing.typ b/tests/typ/math/spacing.typ index b763fb2d..132477f7 100644 --- a/tests/typ/math/spacing.typ +++ b/tests/typ/math/spacing.typ @@ -11,7 +11,8 @@ $a not b$ \ $a+b, a*b$ \ $sum x, sum(x)$ \ $sum product x$ \ -$f(x), zeta(x), "frac"(x)$ +$f(x), zeta(x), "frac"(x)$ \ +$a+dots.c+b$ --- // Test ignored vs non-ignored spaces. -- cgit v1.2.3