summaryrefslogtreecommitdiff
path: root/src/library/math.rs
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2022-02-18 15:02:02 +0100
committerLaurenz <laurmaedje@gmail.com>2022-02-18 16:57:53 +0100
commite01970b20a058ab1b4ebea916f229c9b706c84e4 (patch)
tree5c5efc75abd6e607bd45a0602603231edf520503 /src/library/math.rs
parent05ec0f993b4a1b8481e494ee16285d23f000872f (diff)
Basic show rules
Diffstat (limited to 'src/library/math.rs')
-rw-r--r--src/library/math.rs19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/library/math.rs b/src/library/math.rs
index d3c8b5e5..40a1990e 100644
--- a/src/library/math.rs
+++ b/src/library/math.rs
@@ -22,11 +22,18 @@ impl MathNode {
}
impl Show for MathNode {
- fn show(&self, _: &mut Vm, _: StyleChain) -> TypResult<Template> {
- let mut template = Template::Text(self.formula.trim().into());
- if self.display {
- template = Template::Block(template.pack());
- }
- Ok(template.monospaced())
+ fn show(&self, vm: &mut Vm, styles: StyleChain) -> TypResult<Template> {
+ Ok(styles
+ .show(self, vm, [
+ Value::Str(self.formula.clone()),
+ Value::Bool(self.display),
+ ])?
+ .unwrap_or_else(|| {
+ let mut template = Template::Text(self.formula.trim().into());
+ if self.display {
+ template = Template::Block(template.pack());
+ }
+ template.monospaced()
+ }))
}
}