diff --git a/crates/typst/src/realize/behaviour.rs b/crates/typst/src/realize/behaviour.rs index de6fb8a0..945d2f2a 100644 --- a/crates/typst/src/realize/behaviour.rs +++ b/crates/typst/src/realize/behaviour.rs @@ -231,7 +231,13 @@ impl<'a> Default for BehavedBuilder<'a> { /// A sequence of elements with associated styles. #[derive(Clone, PartialEq, Hash)] pub struct StyleVec { + /// The elements themselves. elements: EcoVec, + /// A run-length encoded list of style lists. + /// + /// Each element is a (styles, count) pair. Any elements whose + /// style falls after the end of this list is considered to + /// have an empty style list. styles: EcoVec<(Styles, usize)>, } diff --git a/crates/typst/src/realize/mod.rs b/crates/typst/src/realize/mod.rs index 40e9a9b0..caad222a 100644 --- a/crates/typst/src/realize/mod.rs +++ b/crates/typst/src/realize/mod.rs @@ -220,16 +220,19 @@ impl<'a, 'v, 't> Builder<'a, 'v, 't> { { bail!(span, "document set rules must appear before any content"); } - } else if let Some(Some(span)) = local.interruption::() { + } + if let Some(Some(span)) = local.interruption::() { if self.doc.is_none() { bail!(span, "page configuration is not allowed inside of containers"); } self.interrupt_page(outer, false)?; - } else if local.interruption::().is_some() + } + if local.interruption::().is_some() || local.interruption::().is_some() { self.interrupt_par()?; - } else if local.interruption::().is_some() + } + if local.interruption::().is_some() || local.interruption::().is_some() || local.interruption::().is_some() { diff --git a/tests/ref/issue-4340-set-document-and-page.png b/tests/ref/issue-4340-set-document-and-page.png new file mode 100644 index 00000000..4737d2eb Binary files /dev/null and b/tests/ref/issue-4340-set-document-and-page.png differ diff --git a/tests/suite/layout/page.typ b/tests/suite/layout/page.typ index c3576ede..f833af59 100644 --- a/tests/suite/layout/page.typ +++ b/tests/suite/layout/page.typ @@ -258,3 +258,11 @@ Default page numbers now. Hi #pagebreak() = Second + +--- issue-4340-set-document-and-page --- +// Test custom page fields being applied on the last page +// if the document has custom fields. +#set document(author: "") +#set page(fill: gray) +text +#pagebreak()