MathAttach::primes: account for possible hash before base (#2363)

Fixes #2358.
This commit is contained in:
bluebear94 2023-10-12 04:19:07 -04:00 committed by GitHub
parent d1a702f3fd
commit d3b62bd02e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 1 deletions

View File

@ -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())
}
}

BIN
tests/ref/math/prime.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

9
tests/typ/math/prime.typ Normal file
View File

@ -0,0 +1,9 @@
// Test prime symbols after code mode.
#let g = $f$
#let gg = $f$
$
#(g)' #g' #g ' \
#g''''''''''''''''' \
gg'
$