summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrancisco J. Sanchez <zheoni@outlook.es>2023-10-25 17:16:34 +0200
committerGitHub <noreply@github.com>2023-10-25 17:16:34 +0200
commitc29a31b6c5b55d7416f967fede5b1db2c523a615 (patch)
treeed00dd9b4d50a9e054df98a314187b0bebcbaf73
parent866bd27d2e90db09b65964fadfb2627aa8ebfe3e (diff)
Fix pagebreak.to check (#2475)
-rw-r--r--crates/typst-library/src/layout/page.rs5
-rw-r--r--tests/ref/layout/pagebreak-parity.pngbin3897 -> 4860 bytes
-rw-r--r--tests/typ/layout/pagebreak-parity.typ12
3 files changed, 16 insertions, 1 deletions
diff --git a/crates/typst-library/src/layout/page.rs b/crates/typst-library/src/layout/page.rs
index b2efed19..495b390d 100644
--- a/crates/typst-library/src/layout/page.rs
+++ b/crates/typst-library/src/layout/page.rs
@@ -378,7 +378,10 @@ impl PageElem {
let mut frames = child.layout(vt, styles, regions)?.into_frames();
// Align the child to the pagebreak's parity.
- if extend_to.is_some_and(|p| p.matches(page_counter.physical().get())) {
+ // Check for page count after adding the pending frames
+ if extend_to
+ .is_some_and(|p| !p.matches(page_counter.physical().get() + frames.len()))
+ {
// Insert empty page after the current pages.
let size = area.map(Abs::is_finite).select(area, Size::zero());
frames.push(Frame::hard(size));
diff --git a/tests/ref/layout/pagebreak-parity.png b/tests/ref/layout/pagebreak-parity.png
index af08bac1..8c05dc92 100644
--- a/tests/ref/layout/pagebreak-parity.png
+++ b/tests/ref/layout/pagebreak-parity.png
Binary files differ
diff --git a/tests/typ/layout/pagebreak-parity.typ b/tests/typ/layout/pagebreak-parity.typ
index 4d6ae941..1cfbd450 100644
--- a/tests/typ/layout/pagebreak-parity.typ
+++ b/tests/typ/layout/pagebreak-parity.typ
@@ -21,3 +21,15 @@ Seventh
First
#pagebreak(to: "odd")
Third
+
+---
+#set page(height: 30pt, width: 80pt)
+
+// Test when content extends to more than one page
+First
+
+Second
+
+#pagebreak(to: "odd")
+
+Third