diff options
| author | Laurenz <laurmaedje@gmail.com> | 2022-11-07 12:21:12 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2022-11-07 12:46:05 +0100 |
| commit | efd1853d069fbd1476e82d015da4d0d04cfaccc0 (patch) | |
| tree | 842b745c134306539d10c61be9485794fe8dc7dc /library/src/math/mod.rs | |
| parent | eb951c008beea502042db4a3a0e8d1f8b51f6f52 (diff) | |
Show it!
- New show rule syntax
- Set if syntax
- Removed wrap syntax
Diffstat (limited to 'library/src/math/mod.rs')
| -rw-r--r-- | library/src/math/mod.rs | 17 |
1 files changed, 11 insertions, 6 deletions
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<BlockSpacing> = Some(Ratio::one().into()); + + fn field(&self, name: &str) -> Option<Value> { + 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<Value> { - None - } - - fn realize(&self, _: Tracked<dyn World>, _: StyleChain) -> SourceResult<Content> { + fn show(&self, _: Tracked<dyn World>, _: StyleChain) -> SourceResult<Content> { 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<dyn World>, |
