fix: exclude content block syntax when parsing math arguments (#1124)

This commit is contained in:
Myriad-Dreamin 2025-01-07 14:18:11 +08:00 committed by GitHub
parent bc2e07bb0c
commit a6a6d88143
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 44 additions and 7 deletions

View file

@ -1,3 +1,4 @@
*.tmLanguage.json
dist
tests/official-testing
tests/official-testing
tests/packages

View file

@ -1456,7 +1456,7 @@ const mathCallArgs: textmate.Pattern = {
],
};
const mathCallStart = new RegExp(MATH_IDENTIFIER.source + /(?=\(|\[)/.source);
const mathCallStart = new RegExp(MATH_IDENTIFIER.source + /(?=\()/.source);
const mathFuncCallOrPropAccess = (): textmate.Pattern => {
return {
@ -1464,11 +1464,11 @@ const mathFuncCallOrPropAccess = (): textmate.Pattern => {
begin: lookAhead(
new RegExp(
`(?:${oneOf(MATH_DOT_ACCESS, MATH_IDENTIFIER).source})` +
/(?=\(|\[)/.source
/(?=\()/.source
)
),
end: replaceGroup(
/(?:(?<=[\)\]])(?![\[\(\.]|[CallStart]))|(?=[\$\s;,\}\]\)]|$)/u,
/(?:(?<=[\)])(?![\(\.]|[CallStart]))|(?=[\$\s;,\}\]\)]|$)/u,
"[CallStart]",
mathCallStart
),
@ -1505,9 +1505,6 @@ const mathFuncCallOrPropAccess = (): textmate.Pattern => {
{
include: "#mathCallArgs",
},
{
include: "#contentBlock",
},
],
};
};

View file

@ -0,0 +1,5 @@
#text(
[string is [gissssssss...
],
)

View file

@ -0,0 +1,19 @@
>
>#text(
#^ source.typst entity.name.function.hash.typst
# ^^^^ source.typst meta.expr.call.typst entity.name.function.typst
# ^ source.typst meta.expr.call.typst meta.brace.round.typst
> [string is [gissssssss...
#^^ source.typst meta.expr.call.typst
# ^ source.typst meta.expr.call.typst meta.brace.square.typst
# ^^^^^^^^^^ source.typst meta.expr.call.typst
# ^ source.typst meta.expr.call.typst meta.brace.square.typst
# ^^^^^^^^^^ source.typst meta.expr.call.typst
# ^^^ source.typst meta.expr.call.typst punctuation.definition.ellipsis.typst
> ],
#^^ source.typst meta.expr.call.typst
# ^ source.typst meta.expr.call.typst meta.brace.square.typst
# ^^ source.typst meta.expr.call.typst
>)
#^ source.typst meta.expr.call.typst markup.content.brace.typst
>

View file

@ -0,0 +1 @@
Where it takes a minimum on $[0;+oo[$ for $x = alpha$

View file

@ -0,0 +1,14 @@
>Where it takes a minimum on $[0;+oo[$ for $x = alpha$
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.typst
# ^ source.typst markup.math.typst punctuation.definition.string.begin.math.typst
# ^ source.typst markup.math.typst markup.content.brace.typst
# ^^^ source.typst markup.math.typst
# ^^ source.typst markup.math.typst variable.other.readwrite.typst
# ^ source.typst markup.math.typst markup.content.brace.typst
# ^ source.typst markup.math.typst punctuation.definition.string.end.math.typst
# ^^^^^ source.typst
# ^ source.typst markup.math.typst punctuation.definition.string.begin.math.typst
# ^^^^ source.typst markup.math.typst
# ^^^^^ source.typst markup.math.typst variable.other.readwrite.typst
# ^ source.typst markup.math.typst punctuation.definition.string.end.math.typst
>