summaryrefslogtreecommitdiff
path: root/library/src/math/mod.rs
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2022-11-07 12:21:12 +0100
committerLaurenz <laurmaedje@gmail.com>2022-11-07 12:46:05 +0100
commitefd1853d069fbd1476e82d015da4d0d04cfaccc0 (patch)
tree842b745c134306539d10c61be9485794fe8dc7dc /library/src/math/mod.rs
parenteb951c008beea502042db4a3a0e8d1f8b51f6f52 (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.rs17
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>,