diff --git a/crates/typst-syntax/src/parser.rs b/crates/typst-syntax/src/parser.rs index b452c2c09..474edbce1 100644 --- a/crates/typst-syntax/src/parser.rs +++ b/crates/typst-syntax/src/parser.rs @@ -384,10 +384,10 @@ fn math_expr_prec(p: &mut Parser, min_prec: usize, stop: SyntaxKind) { fn math_op(kind: SyntaxKind) -> Option<(SyntaxKind, SyntaxKind, ast::Assoc, usize)> { match kind { SyntaxKind::Underscore => { - Some((SyntaxKind::MathAttach, SyntaxKind::Hat, ast::Assoc::Right, 2)) + Some((SyntaxKind::MathAttach, SyntaxKind::Hat, ast::Assoc::Right, 3)) } SyntaxKind::Hat => { - Some((SyntaxKind::MathAttach, SyntaxKind::Underscore, ast::Assoc::Right, 2)) + Some((SyntaxKind::MathAttach, SyntaxKind::Underscore, ast::Assoc::Right, 3)) } SyntaxKind::Slash => { Some((SyntaxKind::MathFrac, SyntaxKind::End, ast::Assoc::Left, 1)) diff --git a/tests/ref/math-attach-followed-by-func-call-complex.png b/tests/ref/math-attach-followed-by-func-call-complex.png new file mode 100644 index 000000000..36de777de Binary files /dev/null and b/tests/ref/math-attach-followed-by-func-call-complex.png differ diff --git a/tests/ref/math-attach-followed-by-func-call.png b/tests/ref/math-attach-followed-by-func-call.png index 71d78c16e..096fb5d00 100644 Binary files a/tests/ref/math-attach-followed-by-func-call.png and b/tests/ref/math-attach-followed-by-func-call.png differ diff --git a/tests/ref/raw-highlight-typm.png b/tests/ref/raw-highlight-typm.png index 016a3e7a2..b0688f6b3 100644 Binary files a/tests/ref/raw-highlight-typm.png and b/tests/ref/raw-highlight-typm.png differ diff --git a/tests/suite/math/accent.typ b/tests/suite/math/accent.typ index 0aef41e20..8ebfe7731 100644 --- a/tests/suite/math/accent.typ +++ b/tests/suite/math/accent.typ @@ -34,7 +34,7 @@ $tilde(sum), tilde(sum, size: #50%), accent(H, hat, size: #200%)$ --- math-accent-sized-script --- // Test accent size in script size. -$tilde(U, size: #1.1em), x^tilde(U, size: #1.1em), sscript(tilde(U, size: #1.1em))$ +$tilde(U, size: #1.1em), x^(tilde(U, size: #1.1em)), sscript(tilde(U, size: #1.1em))$ --- math-accent-dotless --- // Test dotless glyph variants. diff --git a/tests/suite/math/attach.typ b/tests/suite/math/attach.typ index 979018478..bac0417c5 100644 --- a/tests/suite/math/attach.typ +++ b/tests/suite/math/attach.typ @@ -42,9 +42,23 @@ attach(a, tl: u, t: t, tr: v, bl: x, b: b, br: y) $ --- math-attach-followed-by-func-call --- -// Test function call after subscript. -$pi_1(Y), a_f(x), a^zeta (x), a^abs(b)_sqrt(c) \ - a^subset.eq (x), a_(zeta(x)), pi_(1(Y)), a^(abs(b))_(sqrt(c))$ +// Test function call after subscripts and superscripts. +#set page(width: auto) +$a_1(x), a^10(x), a_f(x), a^zeta(x), a_"text"(x), + a_∂(x), a^cos(x), a_abs(x), a^root(2, x), a_subset.eq(x) \ + a_(1(x)), a^(10(x)), a_(f(x)), a^(zeta(x)), a_("text"(x)), + a_(∂(x)), a^(cos(x)), a_(abs(x)), a^(root(2, x)), a_(subset.eq(x))$ + +--- math-attach-followed-by-func-call-complex --- +// Test function call with named arguments after scripts. +#let cross = $c$ +$a_cancel(x, cross: #true)$ + +--- math-attach-followed-by-func-call-error --- +// Error: 14-19 unknown variable: cross +// Hint: 14-19 if you meant to display multiple letters as is, try adding spaces between each letter: `c r o s s` +// Hint: 14-19 or if you meant to display this as text, try placing it in quotes: `"cross"` +$a_cancel(x, cross: #true)$ --- math-attach-nested --- // Test associativity and scaling. diff --git a/tests/suite/text/raw.typ b/tests/suite/text/raw.typ index a7f58a8d0..849313566 100644 --- a/tests/suite/text/raw.typ +++ b/tests/suite/text/raw.typ @@ -215,7 +215,7 @@ box[] hello.world hello.world() hello.my.world() -f_zeta(x), f_zeta(x)/1 +f_(zeta(x)), f_(zeta(x))/1 emph(hello.my.world()) emph(hello.my().world) emph(hello.my().world())