mirror of
https://github.com/typst/typst
synced 2025-05-13 20:46:23 +08:00
Fix arbitrarily nested equations in the base of math.attach
(#5613)
This commit is contained in:
parent
6c2d54bbe3
commit
c3334a55fe
@ -161,7 +161,7 @@ fn stretch_size(
|
||||
) -> Option<Smart<Rel<Length>>> {
|
||||
// Extract from an EquationElem.
|
||||
let mut base = elem.base();
|
||||
if let Some(equation) = base.to_packed::<EquationElem>() {
|
||||
while let Some(equation) = base.to_packed::<EquationElem>() {
|
||||
base = equation.body();
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,7 @@ impl Packed<AttachElem> {
|
||||
pub fn merge_base(&self) -> Option<Self> {
|
||||
// Extract from an EquationElem.
|
||||
let mut base = self.base();
|
||||
if let Some(equation) = base.to_packed::<EquationElem>() {
|
||||
while let Some(equation) = base.to_packed::<EquationElem>() {
|
||||
base = equation.body();
|
||||
}
|
||||
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 1.3 KiB |
BIN
tests/ref/math-attach-nested-deep-base.png
Normal file
BIN
tests/ref/math-attach-nested-deep-base.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 185 B |
Binary file not shown.
Before Width: | Height: | Size: 180 B After Width: | Height: | Size: 415 B |
@ -167,9 +167,22 @@ $ attach(a^b, b: c) quad
|
||||
|
||||
#let a0 = math.attach(math.alpha, b: [0])
|
||||
#let a1 = $alpha^1$
|
||||
#let a2 = $attach(a1, bl: 3)$
|
||||
|
||||
$ a0 + a1 + a0_2 \
|
||||
a1_2 + a0^2 + a1^2 $
|
||||
a1_2 + a0^2 + a1^2 \
|
||||
a2 + a2_2 + a2^2 $
|
||||
|
||||
--- math-attach-nested-deep-base ---
|
||||
// Test attachments when the base has attachments and is nested arbitrarily
|
||||
// deep.
|
||||
#{
|
||||
let var = $x^1$
|
||||
for i in range(24) {
|
||||
var = $var$
|
||||
}
|
||||
$var_2$
|
||||
}
|
||||
|
||||
--- math-attach-scripts-extended-shapes ---
|
||||
// Test script attachments positioning if the base is an extended shape (or a
|
||||
|
@ -83,3 +83,11 @@ $ stretch(base, size: #50%) $
|
||||
// Test stretching with attachments when nested in an equation.
|
||||
#let body = $stretch(=)$
|
||||
$ body^"text" $
|
||||
|
||||
#{
|
||||
let body = $stretch(=)$
|
||||
for i in range(24) {
|
||||
body = $body$
|
||||
}
|
||||
$body^"long text"$
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user