summaryrefslogtreecommitdiff
path: root/src/library/text/mod.rs
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2022-04-23 21:55:58 +0200
committerLaurenz <laurmaedje@gmail.com>2022-04-23 21:55:58 +0200
commit04fb8b288aa7c80607da79db7d085a4820b95a9d (patch)
tree7ca96d09d511274ebac298c329d5eef53a290d9c /src/library/text/mod.rs
parent7a2cc3e7d29d16c5cf9b5a93a688e14da93c8662 (diff)
Show rules with type ascribed object
Diffstat (limited to 'src/library/text/mod.rs')
-rw-r--r--src/library/text/mod.rs30
1 files changed, 22 insertions, 8 deletions
diff --git a/src/library/text/mod.rs b/src/library/text/mod.rs
index bde553e2..e477e76d 100644
--- a/src/library/text/mod.rs
+++ b/src/library/text/mod.rs
@@ -471,10 +471,17 @@ impl StrongNode {
}
impl Show for StrongNode {
- fn show(&self, ctx: &mut Context, styles: StyleChain) -> TypResult<Content> {
- Ok(styles
- .show::<Self, _>(ctx, [Value::Content(self.0.clone())])?
- .unwrap_or_else(|| self.0.clone().styled(TextNode::STRONG, Toggle)))
+ fn encode(&self) -> Dict {
+ dict! { "body" => Value::Content(self.0.clone()) }
+ }
+
+ fn show(
+ &self,
+ _: &mut Context,
+ _: StyleChain,
+ realized: Option<Content>,
+ ) -> TypResult<Content> {
+ Ok(realized.unwrap_or_else(|| self.0.clone().styled(TextNode::STRONG, Toggle)))
}
}
@@ -490,9 +497,16 @@ impl EmphNode {
}
impl Show for EmphNode {
- fn show(&self, ctx: &mut Context, styles: StyleChain) -> TypResult<Content> {
- Ok(styles
- .show::<Self, _>(ctx, [Value::Content(self.0.clone())])?
- .unwrap_or_else(|| self.0.clone().styled(TextNode::EMPH, Toggle)))
+ fn encode(&self) -> Dict {
+ dict! { "body" => Value::Content(self.0.clone()) }
+ }
+
+ fn show(
+ &self,
+ _: &mut Context,
+ _: StyleChain,
+ realized: Option<Content>,
+ ) -> TypResult<Content> {
+ Ok(realized.unwrap_or_else(|| self.0.clone().styled(TextNode::EMPH, Toggle)))
}
}