summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crates/typst-syntax/src/ast.rs6
-rw-r--r--tests/ref/math/prime.pngbin0 -> 1248 bytes
-rw-r--r--tests/typ/math/prime.typ9
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
new file mode 100644
index 00000000..81a47643
--- /dev/null
+++ b/tests/ref/math/prime.png
Binary files differ
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'
+$