diff options
| author | bluebear94 <uruwi@protonmail.com> | 2023-10-12 04:19:07 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-10-12 10:19:07 +0200 |
| commit | d3b62bd02ef92b747b724f344e9b8c7d5668ffbe (patch) | |
| tree | fae56c4bb8018e3d6c06a4669ee8216e13ea9892 | |
| parent | d1a702f3fda49f7180ccde4f336fa725861be17f (diff) | |
MathAttach::primes: account for possible hash before base (#2363)
Fixes #2358.
| -rw-r--r-- | crates/typst-syntax/src/ast.rs | 6 | ||||
| -rw-r--r-- | tests/ref/math/prime.png | bin | 0 -> 1248 bytes | |||
| -rw-r--r-- | tests/typ/math/prime.typ | 9 |
3 files changed, 14 insertions, 1 deletions
diff --git a/crates/typst-syntax/src/ast.rs b/crates/typst-syntax/src/ast.rs index 83e4ff9c..f411326f 100644 --- a/crates/typst-syntax/src/ast.rs +++ b/crates/typst-syntax/src/ast.rs @@ -863,7 +863,11 @@ impl<'a> MathAttach<'a> { /// Extract attached primes if present. pub fn primes(self) -> Option<MathPrimes<'a>> { - self.0.children().nth(1).and_then(|n| n.cast()) + self.0 + .children() + .skip_while(|node| node.cast::<Expr<'_>>().is_none()) + .nth(1) + .and_then(|n| n.cast()) } } diff --git a/tests/ref/math/prime.png b/tests/ref/math/prime.png Binary files differnew file mode 100644 index 00000000..81a47643 --- /dev/null +++ b/tests/ref/math/prime.png diff --git a/tests/typ/math/prime.typ b/tests/typ/math/prime.typ new file mode 100644 index 00000000..61e0c0b2 --- /dev/null +++ b/tests/typ/math/prime.typ @@ -0,0 +1,9 @@ +// Test prime symbols after code mode. +#let g = $f$ +#let gg = $f$ + +$ + #(g)' #g' #g ' \ + #g''''''''''''''''' \ + gg' +$ |
