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/math/mod.rs | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'src/library/math') diff --git a/src/library/math/mod.rs b/src/library/math/mod.rs index e6548438..587949d7 100644 --- a/src/library/math/mod.rs +++ b/src/library/math/mod.rs @@ -28,11 +28,21 @@ impl MathNode { } impl Show for MathNode { - fn show(&self, ctx: &mut Context, styles: StyleChain) -> TypResult { - let args = [Value::Str(self.formula.clone()), Value::Bool(self.display)]; - let mut content = styles - .show::(ctx, args)? - .unwrap_or_else(|| Content::Text(self.formula.trim().into())); + fn encode(&self) -> Dict { + dict! { + "formula" => Value::Str(self.formula.clone()), + "display" => Value::Bool(self.display) + } + } + + fn show( + &self, + _: &mut Context, + styles: StyleChain, + realized: Option, + ) -> 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) { -- cgit v1.2.3