summaryrefslogtreecommitdiff
path: root/src/library/text
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2022-05-03 15:58:15 +0200
committerLaurenz <laurmaedje@gmail.com>2022-05-03 15:58:15 +0200
commitd59109e8fffa1d0b03234329e12f5d3e578804e8 (patch)
treefe7453da6f2ae327993e5ca6436ddc6a448a2c41 /src/library/text
parentf77f1f61bf05ae506689be3c40252c5807276280 (diff)
Support recursive show rules
Diffstat (limited to 'src/library/text')
-rw-r--r--src/library/text/deco.rs6
-rw-r--r--src/library/text/link.rs8
-rw-r--r--src/library/text/mod.rs8
-rw-r--r--src/library/text/par.rs5
-rw-r--r--src/library/text/raw.rs4
5 files changed, 29 insertions, 2 deletions
diff --git a/src/library/text/deco.rs b/src/library/text/deco.rs
index 70040f9c..34c70720 100644
--- a/src/library/text/deco.rs
+++ b/src/library/text/deco.rs
@@ -36,11 +36,15 @@ impl<const L: DecoLine> DecoNode<L> {
pub const EVADE: bool = true;
fn construct(_: &mut Context, args: &mut Args) -> TypResult<Content> {
- Ok(Content::show(Self(args.expect::<Content>("body")?)))
+ Ok(Content::show(Self(args.expect("body")?)))
}
}
impl<const L: DecoLine> Show for DecoNode<L> {
+ fn unguard(&self, sel: Selector) -> ShowNode {
+ Self(self.0.unguard(sel)).pack()
+ }
+
fn encode(&self) -> Dict {
dict! { "body" => Value::Content(self.0.clone()) }
}
diff --git a/src/library/text/link.rs b/src/library/text/link.rs
index 710fbc47..423bcbfb 100644
--- a/src/library/text/link.rs
+++ b/src/library/text/link.rs
@@ -28,6 +28,14 @@ impl LinkNode {
}
impl Show for LinkNode {
+ fn unguard(&self, sel: Selector) -> ShowNode {
+ Self {
+ url: self.url.clone(),
+ body: self.body.as_ref().map(|body| body.unguard(sel)),
+ }
+ .pack()
+ }
+
fn encode(&self) -> Dict {
dict! {
"url" => Value::Str(self.url.clone()),
diff --git a/src/library/text/mod.rs b/src/library/text/mod.rs
index ecc0c546..df00d87a 100644
--- a/src/library/text/mod.rs
+++ b/src/library/text/mod.rs
@@ -463,6 +463,10 @@ impl StrongNode {
}
impl Show for StrongNode {
+ fn unguard(&self, sel: Selector) -> ShowNode {
+ Self(self.0.unguard(sel)).pack()
+ }
+
fn encode(&self) -> Dict {
dict! { "body" => Value::Content(self.0.clone()) }
}
@@ -484,6 +488,10 @@ impl EmphNode {
}
impl Show for EmphNode {
+ fn unguard(&self, sel: Selector) -> ShowNode {
+ Self(self.0.unguard(sel)).pack()
+ }
+
fn encode(&self) -> Dict {
dict! { "body" => Value::Content(self.0.clone()) }
}
diff --git a/src/library/text/par.rs b/src/library/text/par.rs
index 669d07ba..6c274e7e 100644
--- a/src/library/text/par.rs
+++ b/src/library/text/par.rs
@@ -618,7 +618,10 @@ fn shared_get<'a, K: Key<'a>>(
children: &StyleVec<ParChild>,
key: K,
) -> Option<K::Output> {
- children.maps().all(|map| !map.contains(key)).then(|| styles.get(key))
+ children
+ .styles()
+ .all(|map| !map.contains(key))
+ .then(|| styles.get(key))
}
/// Find suitable linebreaks.
diff --git a/src/library/text/raw.rs b/src/library/text/raw.rs
index ee6c6356..c711aa16 100644
--- a/src/library/text/raw.rs
+++ b/src/library/text/raw.rs
@@ -51,6 +51,10 @@ impl RawNode {
}
impl Show for RawNode {
+ fn unguard(&self, _: Selector) -> ShowNode {
+ Self { text: self.text.clone(), ..*self }.pack()
+ }
+
fn encode(&self) -> Dict {
dict! {
"text" => Value::Str(self.text.clone()),