diff options
| author | Laurenz <laurmaedje@gmail.com> | 2023-03-27 13:14:21 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2023-03-27 13:14:21 +0200 |
| commit | 51d972ec247e9e79eba1302d25b581446a7c961a (patch) | |
| tree | 03ac2fb31a63d7e5b7eea2e0a728d0614d6cde2c | |
| parent | 2c7f2c005a214e8b0c1afbe9f4dab29dead8dfb0 (diff) | |
Fix matrix delimiters
Fixes #200.
| -rw-r--r-- | src/syntax/parser.rs | 9 | ||||
| -rw-r--r-- | tests/ref/math/matrix.png | bin | 7376 -> 9945 bytes | |||
| -rw-r--r-- | tests/typ/math/matrix.typ | 26 |
3 files changed, 33 insertions, 2 deletions
diff --git a/src/syntax/parser.rs b/src/syntax/parser.rs index 0431768e..0e211e69 100644 --- a/src/syntax/parser.rs +++ b/src/syntax/parser.rs @@ -428,6 +428,7 @@ fn math_args(p: &mut Parser) { p.convert(SyntaxKind::Colon); named = Some(arg); arg = p.marker(); + array = p.marker(); } match p.current_text() { @@ -448,7 +449,10 @@ fn math_args(p: &mut Parser) { p.convert(SyntaxKind::Comma); arg = p.marker(); namable = true; - named = None; + if named.is_some() { + array = p.marker(); + named = None; + } continue; } _ => {} @@ -465,6 +469,9 @@ fn math_args(p: &mut Parser) { if arg != p.marker() { maybe_wrap_in_math(p, arg, named); + if named.is_some() { + array = p.marker(); + } } if has_arrays && array != p.marker() { diff --git a/tests/ref/math/matrix.png b/tests/ref/math/matrix.png Binary files differindex d97d6ec1..59e3a7b0 100644 --- a/tests/ref/math/matrix.png +++ b/tests/ref/math/matrix.png diff --git a/tests/typ/math/matrix.typ b/tests/typ/math/matrix.typ index e10b77d7..a828e4b4 100644 --- a/tests/typ/math/matrix.typ +++ b/tests/typ/math/matrix.typ @@ -29,6 +29,30 @@ $ mat( ) $ --- -// Test alternative delimiter. +// Test alternative delimiter with set rule. #set math.mat(delim: "[") $ mat(1, 2; 3, 4) $ + +--- +// Test alternative math delimiter directly in call. +#set align(center) +#grid( + columns: 3, + gutter: 10pt, + + $ mat(1, 2, delim: "[") $, + $ mat(1, 2; delim: "[") $, + $ mat(delim: "[", 1, 2) $, + + $ mat(1; 2; delim: "[") $, + $ mat(1; delim: "[", 2) $, + $ mat(delim: "[", 1; 2) $, + + $ mat(1, 2; delim: "[", 3, 4) $, + $ mat(delim: "[", 1, 2; 3, 4) $, + $ mat(1, 2; 3, 4; delim: "[") $, +) + +--- +// Error: 13-14 expected array, found content +$ mat(1, 2; 3, 4, delim: "[") $, |
