summaryrefslogtreecommitdiff
path: root/src/library/structure
diff options
context:
space:
mode:
Diffstat (limited to 'src/library/structure')
-rw-r--r--src/library/structure/heading.rs11
-rw-r--r--src/library/structure/list.rs18
-rw-r--r--src/library/structure/reference.rs7
-rw-r--r--src/library/structure/table.rs14
4 files changed, 23 insertions, 27 deletions
diff --git a/src/library/structure/heading.rs b/src/library/structure/heading.rs
index c967c6d7..fa96248f 100644
--- a/src/library/structure/heading.rs
+++ b/src/library/structure/heading.rs
@@ -73,12 +73,11 @@ impl Show for HeadingNode {
Self { body: self.body.unguard(sel), ..*self }.pack()
}
- fn encode(&self, styles: StyleChain) -> Dict {
- dict! {
- "level" => Value::Int(self.level.get() as i64),
- "body" => Value::Content(self.body.clone()),
- "outlined" => Value::Bool(styles.get(Self::OUTLINED)),
- "numbered" => Value::Bool(styles.get(Self::NUMBERED)),
+ fn field(&self, name: &str) -> Option<Value> {
+ match name {
+ "level" => Some(Value::Int(self.level.get() as i64)),
+ "body" => Some(Value::Content(self.body.clone())),
+ _ => None,
}
}
diff --git a/src/library/structure/list.rs b/src/library/structure/list.rs
index 082c98c3..8a57069e 100644
--- a/src/library/structure/list.rs
+++ b/src/library/structure/list.rs
@@ -90,16 +90,14 @@ impl<const L: ListKind> Show for ListNode<L> {
.pack()
}
- fn encode(&self, _: StyleChain) -> Dict {
- dict! {
- "tight" => Value::Bool(self.tight),
- "attached" => Value::Bool(self.attached),
- "items" => Value::Array(
- self.items
- .items()
- .map(|item| item.encode())
- .collect()
- ),
+ fn field(&self, name: &str) -> Option<Value> {
+ match name {
+ "tight" => Some(Value::Bool(self.tight)),
+ "attached" => Some(Value::Bool(self.attached)),
+ "items" => Some(Value::Array(
+ self.items.items().map(|item| item.encode()).collect(),
+ )),
+ _ => None,
}
}
diff --git a/src/library/structure/reference.rs b/src/library/structure/reference.rs
index 0a9f4f9c..425ee518 100644
--- a/src/library/structure/reference.rs
+++ b/src/library/structure/reference.rs
@@ -16,9 +16,10 @@ impl Show for RefNode {
Self(self.0.clone()).pack()
}
- fn encode(&self, _: StyleChain) -> Dict {
- dict! {
- "label" => Value::Str(self.0.clone().into()),
+ fn field(&self, name: &str) -> Option<Value> {
+ match name {
+ "label" => Some(Value::Str(self.0.clone().into())),
+ _ => None,
}
}
diff --git a/src/library/structure/table.rs b/src/library/structure/table.rs
index a2f583f7..41dcd104 100644
--- a/src/library/structure/table.rs
+++ b/src/library/structure/table.rs
@@ -57,14 +57,12 @@ impl Show for TableNode {
.pack()
}
- fn encode(&self, _: StyleChain) -> Dict {
- dict! {
- "cells" => Value::Array(
- self.cells
- .iter()
- .map(|cell| Value::Content(cell.clone()))
- .collect()
- ),
+ fn field(&self, name: &str) -> Option<Value> {
+ match name {
+ "cells" => Some(Value::Array(
+ self.cells.iter().cloned().map(Value::Content).collect(),
+ )),
+ _ => None,
}
}