From 50e4002a2a65c27f46895103c59cb775ca60d16d Mon Sep 17 00:00:00 2001 From: Laurenz Date: Sun, 24 Apr 2022 14:39:53 +0200 Subject: Split `show` into `realize` and `finalize` --- src/library/math/mod.rs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'src/library/math') diff --git a/src/library/math/mod.rs b/src/library/math/mod.rs index 587949d7..345bb3f6 100644 --- a/src/library/math/mod.rs +++ b/src/library/math/mod.rs @@ -35,26 +35,27 @@ impl Show for MathNode { } } - fn show( + fn realize(&self, _: &mut Context, _: StyleChain) -> TypResult { + Ok(Content::Text(self.formula.trim().into())) + } + + fn finalize( &self, _: &mut Context, styles: StyleChain, - realized: Option, + mut realized: Content, ) -> TypResult { - let mut content = - realized.unwrap_or_else(|| Content::Text(self.formula.trim().into())); - let mut map = StyleMap::new(); if let Smart::Custom(family) = styles.get(Self::FAMILY) { map.set_family(family.clone(), styles); } - content = content.styled_with_map(map); + realized = realized.styled_with_map(map); if self.display { - content = Content::Block(content.pack()); + realized = Content::block(realized); } - Ok(content) + Ok(realized) } } -- cgit v1.2.3