summaryrefslogtreecommitdiff
path: root/src/library/math
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2022-04-24 14:39:53 +0200
committerLaurenz <laurmaedje@gmail.com>2022-04-24 14:53:43 +0200
commit50e4002a2a65c27f46895103c59cb775ca60d16d (patch)
treedbd43c16ae8456536c89d64d2cfff293bb6b1148 /src/library/math
parent04fb8b288aa7c80607da79db7d085a4820b95a9d (diff)
Split `show` into `realize` and `finalize`
Diffstat (limited to 'src/library/math')
-rw-r--r--src/library/math/mod.rs17
1 files changed, 9 insertions, 8 deletions
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<Content> {
+ Ok(Content::Text(self.formula.trim().into()))
+ }
+
+ fn finalize(
&self,
_: &mut Context,
styles: StyleChain,
- realized: Option<Content>,
+ mut realized: Content,
) -> TypResult<Content> {
- 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)
}
}