diff options
| author | Laurenz <laurmaedje@gmail.com> | 2022-04-23 21:55:58 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2022-04-23 21:55:58 +0200 |
| commit | 04fb8b288aa7c80607da79db7d085a4820b95a9d (patch) | |
| tree | 7ca96d09d511274ebac298c329d5eef53a290d9c /src/library/structure/heading.rs | |
| parent | 7a2cc3e7d29d16c5cf9b5a93a688e14da93c8662 (diff) | |
Show rules with type ascribed object
Diffstat (limited to 'src/library/structure/heading.rs')
| -rw-r--r-- | src/library/structure/heading.rs | 23 |
1 files changed, 14 insertions, 9 deletions
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<Content> { + 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<Content>, + ) -> TypResult<Content> { 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::<Self, _>(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)); |
