summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax <me@mkor.je>2025-02-23 11:28:24 +0000
committerGitHub <noreply@github.com>2025-02-23 11:28:24 +0000
commit55bc5f4c940c86377f1ffe25b42fdb01a6827358 (patch)
tree2c90aa5371ea1b1c892ff3e1a7cf68e0852ca82d
parent240f238eee4d6dfce7e3c4cabb9315ad052ca230 (diff)
Make math shorthands noncontinuable (#5925)
-rw-r--r--crates/typst-syntax/src/parser.rs9
-rw-r--r--tests/ref/math-shorthands-noncontinuable.pngbin0 -> 475 bytes
-rw-r--r--tests/suite/math/syntax.typ5
3 files changed, 10 insertions, 4 deletions
diff --git a/crates/typst-syntax/src/parser.rs b/crates/typst-syntax/src/parser.rs
index e187212d..c5d13c8b 100644
--- a/crates/typst-syntax/src/parser.rs
+++ b/crates/typst-syntax/src/parser.rs
@@ -271,10 +271,11 @@ fn math_expr_prec(p: &mut Parser, min_prec: usize, stop: SyntaxKind) {
}
SyntaxKind::Text | SyntaxKind::MathText | SyntaxKind::MathShorthand => {
- continuable = matches!(
- math_class(p.current_text()),
- None | Some(MathClass::Alphabetic)
- );
+ continuable = !p.at(SyntaxKind::MathShorthand)
+ && matches!(
+ math_class(p.current_text()),
+ None | Some(MathClass::Alphabetic)
+ );
if !maybe_delimited(p) {
p.eat();
}
diff --git a/tests/ref/math-shorthands-noncontinuable.png b/tests/ref/math-shorthands-noncontinuable.png
new file mode 100644
index 00000000..2f1ad1d1
--- /dev/null
+++ b/tests/ref/math-shorthands-noncontinuable.png
Binary files differ
diff --git a/tests/suite/math/syntax.typ b/tests/suite/math/syntax.typ
index cd1124c3..7091d908 100644
--- a/tests/suite/math/syntax.typ
+++ b/tests/suite/math/syntax.typ
@@ -13,6 +13,11 @@ $ underline(f' : NN -> RR) \
1 - 0 thick &...,
) $
+--- math-shorthands-noncontinuable ---
+// Test that shorthands are not continuable.
+$ x >=(y) / z \
+ x >= (y) / z $
+
--- math-common-symbols ---
// Test common symbols.
$ dot \ dots \ ast \ tilde \ star $