summaryrefslogtreecommitdiff
path: root/src/eval/show.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/eval/show.rs')
-rw-r--r--src/eval/show.rs32
1 files changed, 24 insertions, 8 deletions
diff --git a/src/eval/show.rs b/src/eval/show.rs
index f8d98d52..c374c2df 100644
--- a/src/eval/show.rs
+++ b/src/eval/show.rs
@@ -13,14 +13,26 @@ pub trait Show: 'static {
/// Encode this node into a dictionary.
fn encode(&self) -> Dict;
- /// Show this node in the given styles and optionally given the realization
- /// of a show rule.
- fn show(
+ /// The base recipe for this node that is executed if there is no
+ /// user-defined show rule.
+ fn realize(&self, ctx: &mut Context, styles: StyleChain) -> TypResult<Content>;
+
+ /// Finalize this node given the realization of a base or user recipe. Use
+ /// this for effects that should work even in the face of a user-defined
+ /// show rule, for example:
+ /// - Application of general settable properties
+ /// - Attaching things like semantics to a heading
+ ///
+ /// Defaults to just the realized content.
+ #[allow(unused_variables)]
+ fn finalize(
&self,
ctx: &mut Context,
styles: StyleChain,
- realized: Option<Content>,
- ) -> TypResult<Content>;
+ realized: Content,
+ ) -> TypResult<Content> {
+ Ok(realized)
+ }
/// Convert to a packed show node.
fn pack(self) -> ShowNode
@@ -55,13 +67,17 @@ impl Show for ShowNode {
self.0.encode()
}
- fn show(
+ fn realize(&self, ctx: &mut Context, styles: StyleChain) -> TypResult<Content> {
+ self.0.realize(ctx, styles)
+ }
+
+ fn finalize(
&self,
ctx: &mut Context,
styles: StyleChain,
- realized: Option<Content>,
+ realized: Content,
) -> TypResult<Content> {
- self.0.show(ctx, styles, realized)
+ self.0.finalize(ctx, styles, realized)
}
fn pack(self) -> ShowNode {