diff --git a/library/src/basics/heading.rs b/library/src/basics/heading.rs index 58d0d3bf5..0033f021d 100644 --- a/library/src/basics/heading.rs +++ b/library/src/basics/heading.rs @@ -71,12 +71,12 @@ impl Prepare for HeadingNode { } impl Show for HeadingNode { - fn show(&self, _: &mut Vt, this: &Content, _: StyleChain) -> Content { + fn show(&self, _: &mut Vt, this: &Content, _: StyleChain) -> SourceResult { let mut realized = self.body.clone(); if let Some(Value::Str(numbering)) = this.field("numbers") { realized = TextNode::packed(numbering) + SpaceNode.pack() + realized; } - BlockNode(realized).pack() + Ok(BlockNode(realized).pack()) } } diff --git a/library/src/math/mod.rs b/library/src/math/mod.rs index 9d25d4853..a276908d3 100644 --- a/library/src/math/mod.rs +++ b/library/src/math/mod.rs @@ -30,7 +30,7 @@ impl MathNode { } impl Show for MathNode { - fn show(&self, _: &mut Vt, _: &Content, styles: StyleChain) -> Content { + fn show(&self, _: &mut Vt, _: &Content, styles: StyleChain) -> SourceResult { let mut map = StyleMap::new(); map.set_family(FontFamily::new("NewComputerModernMath"), styles); @@ -44,7 +44,7 @@ impl Show for MathNode { realized = realized.aligned(Axes::with_x(Some(Align::Center.into()))) } - realized + Ok(realized) } } diff --git a/library/src/meta/link.rs b/library/src/meta/link.rs index 521633710..34304ea9c 100644 --- a/library/src/meta/link.rs +++ b/library/src/meta/link.rs @@ -50,8 +50,8 @@ impl LinkNode { } impl Show for LinkNode { - fn show(&self, _: &mut Vt, _: &Content, _: StyleChain) -> Content { - self.body.clone() + fn show(&self, _: &mut Vt, _: &Content, _: StyleChain) -> SourceResult { + Ok(self.body.clone()) } } diff --git a/library/src/meta/outline.rs b/library/src/meta/outline.rs index b680a1ac3..53535be59 100644 --- a/library/src/meta/outline.rs +++ b/library/src/meta/outline.rs @@ -44,7 +44,12 @@ impl Prepare for OutlineNode { } impl Show for OutlineNode { - fn show(&self, vt: &mut Vt, _: &Content, styles: StyleChain) -> Content { + fn show( + &self, + vt: &mut Vt, + _: &Content, + styles: StyleChain, + ) -> SourceResult { let mut seq = vec![]; if let Some(title) = styles.get(Self::TITLE) { let body = title.clone().unwrap_or_else(|| { @@ -137,6 +142,6 @@ impl Show for OutlineNode { ancestors.push(node); } - BlockNode(Content::sequence(seq)).pack() + Ok(BlockNode(Content::sequence(seq)).pack()) } } diff --git a/library/src/meta/reference.rs b/library/src/meta/reference.rs index c8e8ebdc5..a04fd13f1 100644 --- a/library/src/meta/reference.rs +++ b/library/src/meta/reference.rs @@ -20,7 +20,7 @@ impl RefNode { } impl Show for RefNode { - fn show(&self, _: &mut Vt, _: &Content, _: StyleChain) -> Content { - TextNode::packed(format_eco!("@{}", self.0)) + fn show(&self, _: &mut Vt, _: &Content, _: StyleChain) -> SourceResult { + Ok(TextNode::packed(format_eco!("@{}", self.0))) } } diff --git a/library/src/text/deco.rs b/library/src/text/deco.rs index 4c9f6dcda..a6fa490f4 100644 --- a/library/src/text/deco.rs +++ b/library/src/text/deco.rs @@ -47,8 +47,8 @@ impl DecoNode { } impl Show for DecoNode { - fn show(&self, _: &mut Vt, _: &Content, styles: StyleChain) -> Content { - self.0.clone().styled( + fn show(&self, _: &mut Vt, _: &Content, styles: StyleChain) -> SourceResult { + Ok(self.0.clone().styled( TextNode::DECO, Decoration { line: L, @@ -57,7 +57,7 @@ impl Show for DecoNode { extent: styles.get(Self::EXTENT), evade: styles.get(Self::EVADE), }, - ) + )) } } diff --git a/library/src/text/misc.rs b/library/src/text/misc.rs index c3897a8e1..896c03ac6 100644 --- a/library/src/text/misc.rs +++ b/library/src/text/misc.rs @@ -62,8 +62,8 @@ impl StrongNode { } impl Show for StrongNode { - fn show(&self, _: &mut Vt, _: &Content, styles: StyleChain) -> Content { - self.0.clone().styled(TextNode::DELTA, Delta(styles.get(Self::DELTA))) + fn show(&self, _: &mut Vt, _: &Content, styles: StyleChain) -> SourceResult { + Ok(self.0.clone().styled(TextNode::DELTA, Delta(styles.get(Self::DELTA)))) } } @@ -104,8 +104,8 @@ impl EmphNode { } impl Show for EmphNode { - fn show(&self, _: &mut Vt, _: &Content, _: StyleChain) -> Content { - self.0.clone().styled(TextNode::EMPH, Toggle) + fn show(&self, _: &mut Vt, _: &Content, _: StyleChain) -> SourceResult { + Ok(self.0.clone().styled(TextNode::EMPH, Toggle)) } } diff --git a/library/src/text/raw.rs b/library/src/text/raw.rs index 9c04fedff..a043019a7 100644 --- a/library/src/text/raw.rs +++ b/library/src/text/raw.rs @@ -56,7 +56,7 @@ impl Prepare for RawNode { } impl Show for RawNode { - fn show(&self, _: &mut Vt, _: &Content, styles: StyleChain) -> Content { + fn show(&self, _: &mut Vt, _: &Content, styles: StyleChain) -> SourceResult { let lang = styles.get(Self::LANG).as_ref().map(|s| s.to_lowercase()); let foreground = THEME .settings @@ -109,7 +109,7 @@ impl Show for RawNode { map.set(TextNode::SMART_QUOTES, false); map.set_family(FontFamily::new("IBM Plex Mono"), styles); - realized.styled_with_map(map) + Ok(realized.styled_with_map(map)) } } diff --git a/library/src/text/shift.rs b/library/src/text/shift.rs index 3419cc91d..92e963e80 100644 --- a/library/src/text/shift.rs +++ b/library/src/text/shift.rs @@ -43,7 +43,12 @@ impl ShiftNode { } impl Show for ShiftNode { - fn show(&self, vt: &mut Vt, _: &Content, styles: StyleChain) -> Content { + fn show( + &self, + vt: &mut Vt, + _: &Content, + styles: StyleChain, + ) -> SourceResult { let mut transformed = None; if styles.get(Self::TYPOGRAPHIC) { if let Some(text) = search_text(&self.0, S) { @@ -53,12 +58,12 @@ impl Show for ShiftNode { } }; - transformed.unwrap_or_else(|| { + Ok(transformed.unwrap_or_else(|| { let mut map = StyleMap::new(); map.set(TextNode::BASELINE, styles.get(Self::BASELINE)); map.set(TextNode::SIZE, styles.get(Self::SIZE)); self.0.clone().styled_with_map(map) - }) + })) } } diff --git a/src/model/realize.rs b/src/model/realize.rs index abe20901d..b4e38e304 100644 --- a/src/model/realize.rs +++ b/src/model/realize.rs @@ -47,7 +47,7 @@ pub fn realize( if let Some(showable) = target.with::() { let guard = Guard::Base(target.id()); if realized.is_none() && !target.is_guarded(guard) { - realized = Some(showable.show(vt, target, styles)); + realized = Some(showable.show(vt, target, styles)?); } } @@ -139,7 +139,12 @@ pub trait Prepare { #[capability] pub trait Show { /// Execute the base recipe for this node. - fn show(&self, vt: &mut Vt, this: &Content, styles: StyleChain) -> Content; + fn show( + &self, + vt: &mut Vt, + this: &Content, + styles: StyleChain, + ) -> SourceResult; } /// Post-process a node after it was realized.