summaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
author+merlan #flirora <uruwi@protonmail.com>2024-06-11 05:14:26 -0400
committerGitHub <noreply@github.com>2024-06-11 09:14:26 +0000
commita10e3324c21daf25fd8e8fc5336aa72718a87e47 (patch)
tree420be1032e6e8b070776c9000cbc90a3146a7a86 /crates
parent20475ab0bf4f28511064195b71890a3cf5d188a1 (diff)
interrupt_styles: Check all potential style matches (#4345)
Diffstat (limited to 'crates')
-rw-r--r--crates/typst/src/realize/behaviour.rs6
-rw-r--r--crates/typst/src/realize/mod.rs9
2 files changed, 12 insertions, 3 deletions
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<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)>,
}
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::<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()
{