diff --git a/crates/typst-syntax/src/ast.rs b/crates/typst-syntax/src/ast.rs index 2ea318a7f..65a91629f 100644 --- a/crates/typst-syntax/src/ast.rs +++ b/crates/typst-syntax/src/ast.rs @@ -848,9 +848,9 @@ impl MathAttach { .find_map(SyntaxNode::cast) } - /// Extract primes if present. + /// Extract attached primes if present. pub fn primes(&self) -> Option { - self.0.cast_first_match() + self.0.children().nth(1).and_then(|n| n.cast()) } } diff --git a/tests/ref/math/opticalsize.png b/tests/ref/math/opticalsize.png index 905d3389f..bd67542bc 100644 Binary files a/tests/ref/math/opticalsize.png and b/tests/ref/math/opticalsize.png differ diff --git a/tests/typ/math/opticalsize.typ b/tests/typ/math/opticalsize.typ index 6edd24193..07027cbba 100644 --- a/tests/typ/math/opticalsize.typ +++ b/tests/typ/math/opticalsize.typ @@ -43,3 +43,7 @@ $a'_b^c$, $a_b'^c$, $a_b^c'$, $a_b'^c'^d'$ $(a'_b')^(c'_d')$, $a'/b'$, $a_b'/c_d'$ $∫'$, $∑'$, $ ∑'_S' $ + +--- +// Test attaching primes only +$a' = a^', a_', a_'''^''^'$ \ No newline at end of file