From efd1853d069fbd1476e82d015da4d0d04cfaccc0 Mon Sep 17 00:00:00 2001 From: Laurenz Date: Mon, 7 Nov 2022 12:21:12 +0100 Subject: Show it! - New show rule syntax - Set if syntax - Removed wrap syntax --- library/src/math/mod.rs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'library/src/math/mod.rs') diff --git a/library/src/math/mod.rs b/library/src/math/mod.rs index dae869ed..0fad2939 100644 --- a/library/src/math/mod.rs +++ b/library/src/math/mod.rs @@ -18,7 +18,7 @@ pub struct MathNode { pub display: bool, } -#[node(Show, LayoutInline, Texify)] +#[node(Show, Finalize, LayoutInline, Texify)] impl MathNode { /// The math font family. #[property(referenced)] @@ -29,6 +29,13 @@ impl MathNode { /// The spacing below display math. #[property(resolve, shorthand(around))] pub const BELOW: Option = Some(Ratio::one().into()); + + fn field(&self, name: &str) -> Option { + match name { + "display" => Some(Value::Bool(self.display)), + _ => None, + } + } } impl Show for MathNode { @@ -36,18 +43,16 @@ impl Show for MathNode { self.clone().pack() } - fn field(&self, _: &str) -> Option { - None - } - - fn realize(&self, _: Tracked, _: StyleChain) -> SourceResult { + fn show(&self, _: Tracked, _: StyleChain) -> SourceResult { Ok(if self.display { self.clone().pack().aligned(Axes::with_x(Some(Align::Center.into()))) } else { self.clone().pack() }) } +} +impl Finalize for MathNode { fn finalize( &self, _: Tracked, -- cgit v1.2.3