summaryrefslogtreecommitdiff
path: root/src/model/realize.rs
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2022-12-02 15:41:39 +0100
committerLaurenz <laurmaedje@gmail.com>2022-12-02 15:45:18 +0100
commit9bc90c371fb41a2d6dc08eb4673e5be15f829514 (patch)
tree454a47ce82c2229e79a139a8bdeaed9add1e0a14 /src/model/realize.rs
parent5110a41de1ca2236739ace2d37a1af912bb029f1 (diff)
Introspection
Diffstat (limited to 'src/model/realize.rs')
-rw-r--r--src/model/realize.rs13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/model/realize.rs b/src/model/realize.rs
index 46e0d678..abe20901 100644
--- a/src/model/realize.rs
+++ b/src/model/realize.rs
@@ -3,6 +3,10 @@ use crate::diag::SourceResult;
/// Whether the target is affected by show rules in the given style chain.
pub fn applicable(target: &Content, styles: StyleChain) -> bool {
+ if target.has::<dyn Prepare>() && !target.is_prepared() {
+ return true;
+ }
+
// Find out how many recipes there are.
let mut n = styles.recipes().count();
@@ -90,7 +94,7 @@ fn try_apply(
let make = |s| {
let mut content = item!(text)(s);
- content.copy_meta(&target);
+ content.copy_modifiers(&target);
content
};
@@ -124,6 +128,13 @@ fn try_apply(
}
}
+/// Preparations before execution of any show rule.
+#[capability]
+pub trait Prepare {
+ /// Prepare the node for show rule application.
+ fn prepare(&self, vt: &mut Vt, this: Content, styles: StyleChain) -> Content;
+}
+
/// The base recipe for a node.
#[capability]
pub trait Show {