summaryrefslogtreecommitdiff
path: root/library/src
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2022-12-05 12:21:10 +0100
committerLaurenz <laurmaedje@gmail.com>2022-12-05 12:21:10 +0100
commit1d324235bd80fe8d1fb21b1e73ae9e3dfe918078 (patch)
tree342b3ad9f0ca40dbf6f51c2b29646ca6803fe85a /library/src
parent1bb05677faa7bd6566e1231ed2b16547f476b143 (diff)
Make show rule fallible again
Diffstat (limited to 'library/src')
-rw-r--r--library/src/basics/heading.rs4
-rw-r--r--library/src/math/mod.rs4
-rw-r--r--library/src/meta/link.rs4
-rw-r--r--library/src/meta/outline.rs9
-rw-r--r--library/src/meta/reference.rs4
-rw-r--r--library/src/text/deco.rs6
-rw-r--r--library/src/text/misc.rs8
-rw-r--r--library/src/text/raw.rs4
-rw-r--r--library/src/text/shift.rs11
9 files changed, 32 insertions, 22 deletions
diff --git a/library/src/basics/heading.rs b/library/src/basics/heading.rs
index 58d0d3bf..0033f021 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<Content> {
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 9d25d485..a276908d 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<Content> {
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 52163371..34304ea9 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<Content> {
+ Ok(self.body.clone())
}
}
diff --git a/library/src/meta/outline.rs b/library/src/meta/outline.rs
index b680a1ac..53535be5 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<Content> {
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 c8e8ebdc..a04fd13f 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<Content> {
+ Ok(TextNode::packed(format_eco!("@{}", self.0)))
}
}
diff --git a/library/src/text/deco.rs b/library/src/text/deco.rs
index 4c9f6dcd..a6fa490f 100644
--- a/library/src/text/deco.rs
+++ b/library/src/text/deco.rs
@@ -47,8 +47,8 @@ impl<const L: DecoLine> DecoNode<L> {
}
impl<const L: DecoLine> Show for DecoNode<L> {
- fn show(&self, _: &mut Vt, _: &Content, styles: StyleChain) -> Content {
- self.0.clone().styled(
+ fn show(&self, _: &mut Vt, _: &Content, styles: StyleChain) -> SourceResult<Content> {
+ Ok(self.0.clone().styled(
TextNode::DECO,
Decoration {
line: L,
@@ -57,7 +57,7 @@ impl<const L: DecoLine> Show for DecoNode<L> {
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 c3897a8e..896c03ac 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<Content> {
+ 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<Content> {
+ Ok(self.0.clone().styled(TextNode::EMPH, Toggle))
}
}
diff --git a/library/src/text/raw.rs b/library/src/text/raw.rs
index 9c04fedf..a043019a 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<Content> {
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 3419cc91..92e963e8 100644
--- a/library/src/text/shift.rs
+++ b/library/src/text/shift.rs
@@ -43,7 +43,12 @@ impl<const S: ShiftKind> ShiftNode<S> {
}
impl<const S: ShiftKind> Show for ShiftNode<S> {
- fn show(&self, vt: &mut Vt, _: &Content, styles: StyleChain) -> Content {
+ fn show(
+ &self,
+ vt: &mut Vt,
+ _: &Content,
+ styles: StyleChain,
+ ) -> SourceResult<Content> {
let mut transformed = None;
if styles.get(Self::TYPOGRAPHIC) {
if let Some(text) = search_text(&self.0, S) {
@@ -53,12 +58,12 @@ impl<const S: ShiftKind> Show for ShiftNode<S> {
}
};
- 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)
- })
+ }))
}
}