diff options
| author | Ian Wrzesinski <133046678+wrzian@users.noreply.github.com> | 2025-01-23 07:27:38 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-01-23 12:27:38 +0000 |
| commit | f7bd03dd76533cda2d2626d6470d3bb55e03b012 (patch) | |
| tree | 9b6ed1b911ea6a5916a4b7b7d42248593afd7f5e | |
| parent | b3fb6c2326ac6d585cc17d1f643bc06e076be042 (diff) | |
Fix delimiter unparen syntax (#5739)
| -rw-r--r-- | crates/typst-syntax/src/parser.rs | 4 | ||||
| -rw-r--r-- | tests/ref/math-lr-unparen.png | bin | 0 -> 493 bytes | |||
| -rw-r--r-- | tests/suite/math/delimited.typ | 8 |
3 files changed, 10 insertions, 2 deletions
diff --git a/crates/typst-syntax/src/parser.rs b/crates/typst-syntax/src/parser.rs index a65e5ff6..f9fb8b61 100644 --- a/crates/typst-syntax/src/parser.rs +++ b/crates/typst-syntax/src/parser.rs @@ -442,10 +442,10 @@ fn math_unparen(p: &mut Parser, m: Marker) { if first.text() == "(" && last.text() == ")" { first.convert_to_kind(SyntaxKind::LeftParen); last.convert_to_kind(SyntaxKind::RightParen); + // Only convert if we did have regular parens. + node.convert_to_kind(SyntaxKind::Math); } } - - node.convert_to_kind(SyntaxKind::Math); } /// The unicode math class of a string. Only returns `Some` if `text` has diff --git a/tests/ref/math-lr-unparen.png b/tests/ref/math-lr-unparen.png Binary files differnew file mode 100644 index 00000000..d418b14e --- /dev/null +++ b/tests/ref/math-lr-unparen.png diff --git a/tests/suite/math/delimited.typ b/tests/suite/math/delimited.typ index 22674050..ca82427d 100644 --- a/tests/suite/math/delimited.typ +++ b/tests/suite/math/delimited.typ @@ -125,3 +125,11 @@ $ lr(size: #3em, |)_a^b lr(size: #3em, zws|)_a^b --- issue-4188-lr-corner-brackets --- // Test positioning of U+231C to U+231F $⌜a⌟⌞b⌝$ = $⌜$$a$$⌟$$⌞$$b$$⌝$ + +--- math-lr-unparen --- +// Test that unparen with brackets stays as an LrElem. +#let item = $limits(sum)_i$ +$ + 1 / ([item]) quad + 1 / [item] +$ |
