summaryrefslogtreecommitdiff
path: root/src/library/text
diff options
context:
space:
mode:
Diffstat (limited to 'src/library/text')
-rw-r--r--src/library/text/deco.rs7
-rw-r--r--src/library/text/link.rs13
-rw-r--r--src/library/text/mod.rs14
-rw-r--r--src/library/text/raw.rs13
-rw-r--r--src/library/text/shift.rs7
5 files changed, 32 insertions, 22 deletions
diff --git a/src/library/text/deco.rs b/src/library/text/deco.rs
index 6a4905c8..ead928f6 100644
--- a/src/library/text/deco.rs
+++ b/src/library/text/deco.rs
@@ -44,8 +44,11 @@ impl<const L: DecoLine> Show for DecoNode<L> {
Self(self.0.unguard(sel)).pack()
}
- fn encode(&self, _: StyleChain) -> Dict {
- dict! { "body" => Value::Content(self.0.clone()) }
+ fn field(&self, name: &str) -> Option<Value> {
+ match name {
+ "body" => Some(Value::Content(self.0.clone())),
+ _ => None,
+ }
}
fn realize(
diff --git a/src/library/text/link.rs b/src/library/text/link.rs
index 7c4a95ed..98a867a8 100644
--- a/src/library/text/link.rs
+++ b/src/library/text/link.rs
@@ -58,16 +58,17 @@ impl Show for LinkNode {
.pack()
}
- fn encode(&self, _: StyleChain) -> Dict {
- dict! {
- "url" => match &self.dest {
+ fn field(&self, name: &str) -> Option<Value> {
+ match name {
+ "url" => Some(match &self.dest {
Destination::Url(url) => Value::Str(url.clone().into()),
Destination::Internal(loc) => Value::Dict(loc.encode()),
- },
- "body" => match &self.body {
+ }),
+ "body" => Some(match &self.body {
Some(body) => Value::Content(body.clone()),
None => Value::None,
- },
+ }),
+ _ => None,
}
}
diff --git a/src/library/text/mod.rs b/src/library/text/mod.rs
index 2d302b9a..d7d2ee38 100644
--- a/src/library/text/mod.rs
+++ b/src/library/text/mod.rs
@@ -515,8 +515,11 @@ impl Show for StrongNode {
Self(self.0.unguard(sel)).pack()
}
- fn encode(&self, _: StyleChain) -> Dict {
- dict! { "body" => Value::Content(self.0.clone()) }
+ fn field(&self, name: &str) -> Option<Value> {
+ match name {
+ "body" => Some(Value::Content(self.0.clone())),
+ _ => None,
+ }
}
fn realize(&self, _: Tracked<dyn World>, _: StyleChain) -> SourceResult<Content> {
@@ -540,8 +543,11 @@ impl Show for EmphNode {
Self(self.0.unguard(sel)).pack()
}
- fn encode(&self, _: StyleChain) -> Dict {
- dict! { "body" => Value::Content(self.0.clone()) }
+ fn field(&self, name: &str) -> Option<Value> {
+ match name {
+ "body" => Some(Value::Content(self.0.clone())),
+ _ => None,
+ }
}
fn realize(&self, _: Tracked<dyn World>, _: StyleChain) -> SourceResult<Content> {
diff --git a/src/library/text/raw.rs b/src/library/text/raw.rs
index d237aa92..6d19deff 100644
--- a/src/library/text/raw.rs
+++ b/src/library/text/raw.rs
@@ -46,14 +46,11 @@ impl Show for RawNode {
Self { text: self.text.clone(), ..*self }.pack()
}
- fn encode(&self, styles: StyleChain) -> Dict {
- dict! {
- "text" => Value::Str(self.text.clone().into()),
- "block" => Value::Bool(self.block),
- "lang" => match styles.get(Self::LANG) {
- Some(lang) => Value::Str(lang.clone().into()),
- None => Value::None,
- },
+ fn field(&self, name: &str) -> Option<Value> {
+ match name {
+ "text" => Some(Value::Str(self.text.clone().into())),
+ "block" => Some(Value::Bool(self.block)),
+ _ => None,
}
}
diff --git a/src/library/text/shift.rs b/src/library/text/shift.rs
index adad5dc0..e2a636a6 100644
--- a/src/library/text/shift.rs
+++ b/src/library/text/shift.rs
@@ -38,8 +38,11 @@ impl<const S: ScriptKind> Show for ShiftNode<S> {
Self(self.0.clone()).pack()
}
- fn encode(&self, _: StyleChain) -> Dict {
- dict! { "body" => Value::Content(self.0.clone()) }
+ fn field(&self, name: &str) -> Option<Value> {
+ match name {
+ "body" => Some(Value::Content(self.0.clone())),
+ _ => None,
+ }
}
fn realize(