From 04fb8b288aa7c80607da79db7d085a4820b95a9d Mon Sep 17 00:00:00 2001 From: Laurenz Date: Sat, 23 Apr 2022 21:55:58 +0200 Subject: Show rules with type ascribed object --- src/library/structure/heading.rs | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'src/library/structure/heading.rs') diff --git a/src/library/structure/heading.rs b/src/library/structure/heading.rs index 07e5e662..a352cc92 100644 --- a/src/library/structure/heading.rs +++ b/src/library/structure/heading.rs @@ -56,21 +56,26 @@ impl HeadingNode { } impl Show for HeadingNode { - fn show(&self, ctx: &mut Context, styles: StyleChain) -> TypResult { + fn encode(&self) -> Dict { + dict! { + "level" => Value::Int(self.level as i64), + "body" => Value::Content(self.body.clone()), + } + } + + fn show( + &self, + ctx: &mut Context, + styles: StyleChain, + realized: Option, + ) -> TypResult { macro_rules! resolve { ($key:expr) => { styles.get($key).resolve(ctx, self.level)? }; } - let args = [ - Value::Int(self.level as i64), - Value::Content(self.body.clone()), - ]; - - let mut body = styles - .show::(ctx, args)? - .unwrap_or_else(|| self.body.clone()); + let mut body = realized.unwrap_or_else(|| self.body.clone()); let mut map = StyleMap::new(); map.set(TextNode::SIZE, resolve!(Self::SIZE)); -- cgit v1.2.3