mirror of
https://github.com/typst/typst
synced 2025-08-15 15:38:33 +08:00
Make only alphabetic text continuable
This commit is contained in:
parent
dbdc8ea069
commit
438fe42bf7
@ -271,12 +271,9 @@ fn math_expr_prec(p: &mut Parser, min_prec: usize, stop: SyntaxKind) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
SyntaxKind::Text | SyntaxKind::MathText | SyntaxKind::MathShorthand => {
|
SyntaxKind::Text | SyntaxKind::MathText | SyntaxKind::MathShorthand => {
|
||||||
continuable = !p.at(SyntaxKind::MathShorthand)
|
// `a(b)/c` parses as `(a(b))/c` if `a` is continuable.
|
||||||
&& !p.current_text().chars().all(char::is_numeric)
|
continuable = math_class(p.current_text()) == Some(MathClass::Alphabetic)
|
||||||
&& matches!(
|
|| p.current_text().chars().all(char::is_alphabetic);
|
||||||
math_class(p.current_text()),
|
|
||||||
None | Some(MathClass::Alphabetic)
|
|
||||||
);
|
|
||||||
if !maybe_delimited(p) {
|
if !maybe_delimited(p) {
|
||||||
p.eat();
|
p.eat();
|
||||||
}
|
}
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 5.4 KiB After Width: | Height: | Size: 3.5 KiB |
@ -37,8 +37,8 @@ $ 1/2/3 = (1/2)/3 = 1/(2/3) $
|
|||||||
// Test precedence.
|
// Test precedence.
|
||||||
$ a_1/b_2, 1/f(x), zeta(x)/2, "foo"[|x|]/2 \
|
$ a_1/b_2, 1/f(x), zeta(x)/2, "foo"[|x|]/2 \
|
||||||
1.2/3.7, 2.3^3.4 \
|
1.2/3.7, 2.3^3.4 \
|
||||||
🏳️🌈[x]/2, f [x]/2, phi [x]/2, 🏳️🌈 [x]/2 \
|
f [x]/2, phi [x]/2 \
|
||||||
+[x]/2, 1(x)/2, 2[x]/2 \
|
+[x]/2, 1(x)/2, 2[x]/2, 🏳️🌈[x]/2 \
|
||||||
(a)b/2, b(a)[b]/2 \
|
(a)b/2, b(a)[b]/2 \
|
||||||
n!/2, 5!/2, n !/2, 1/n!, 1/5! $
|
n!/2, 5!/2, n !/2, 1/n!, 1/5! $
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user