diff --git a/crates/typst-syntax/src/ast.rs b/crates/typst-syntax/src/ast.rs index 83e4ff9cf..f411326f6 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> { - self.0.children().nth(1).and_then(|n| n.cast()) + self.0 + .children() + .skip_while(|node| node.cast::>().is_none()) + .nth(1) + .and_then(|n| n.cast()) } } diff --git a/tests/ref/math/prime.png b/tests/ref/math/prime.png new file mode 100644 index 000000000..81a476436 Binary files /dev/null and b/tests/ref/math/prime.png differ diff --git a/tests/typ/math/prime.typ b/tests/typ/math/prime.typ new file mode 100644 index 000000000..61e0c0b20 --- /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' +$