interrupt_styles: Check all potential style matches (#4345)

This commit is contained in:
+merlan #flirora 2024-06-11 05:14:26 -04:00 committed by GitHub
parent 20475ab0bf
commit a10e3324c2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 20 additions and 3 deletions

View File

@ -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<Content>,
/// 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)>,
}

View File

@ -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::<PageElem>() {
}
if let Some(Some(span)) = local.interruption::<PageElem>() {
if self.doc.is_none() {
bail!(span, "page configuration is not allowed inside of containers");
}
self.interrupt_page(outer, false)?;
} else if local.interruption::<ParElem>().is_some()
}
if local.interruption::<ParElem>().is_some()
|| local.interruption::<AlignElem>().is_some()
{
self.interrupt_par()?;
} else if local.interruption::<ListElem>().is_some()
}
if local.interruption::<ListElem>().is_some()
|| local.interruption::<EnumElem>().is_some()
|| local.interruption::<TermsElem>().is_some()
{

Binary file not shown.

After

Width:  |  Height:  |  Size: 222 B

View File

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