diff --git a/src/syntax/parser.rs b/src/syntax/parser.rs index 0431768e6..0e211e692 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 index d97d6ec13..59e3a7b09 100644 Binary files a/tests/ref/math/matrix.png and b/tests/ref/math/matrix.png differ diff --git a/tests/typ/math/matrix.typ b/tests/typ/math/matrix.typ index e10b77d7e..a828e4b41 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: "[") $,