Fix matrix delimiters

Fixes #200.
This commit is contained in:
Laurenz 2023-03-27 13:14:21 +02:00
parent 2c7f2c005a
commit 51d972ec24
3 changed files with 33 additions and 2 deletions

View File

@ -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() {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.2 KiB

After

Width:  |  Height:  |  Size: 9.7 KiB

View File

@ -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: "[") $,