diff options
| author | Laurenz <laurmaedje@gmail.com> | 2022-05-03 15:58:15 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2022-05-03 15:58:15 +0200 |
| commit | d59109e8fffa1d0b03234329e12f5d3e578804e8 (patch) | |
| tree | fe7453da6f2ae327993e5ca6436ddc6a448a2c41 /src/library/structure | |
| parent | f77f1f61bf05ae506689be3c40252c5807276280 (diff) | |
Support recursive show rules
Diffstat (limited to 'src/library/structure')
| -rw-r--r-- | src/library/structure/heading.rs | 4 | ||||
| -rw-r--r-- | src/library/structure/list.rs | 13 | ||||
| -rw-r--r-- | src/library/structure/table.rs | 9 |
3 files changed, 25 insertions, 1 deletions
diff --git a/src/library/structure/heading.rs b/src/library/structure/heading.rs index 4f6c54f3..468757ad 100644 --- a/src/library/structure/heading.rs +++ b/src/library/structure/heading.rs @@ -64,6 +64,10 @@ impl HeadingNode { } impl Show for HeadingNode { + fn unguard(&self, sel: Selector) -> ShowNode { + Self { body: self.body.unguard(sel), ..*self }.pack() + } + fn encode(&self) -> Dict { dict! { "level" => Value::Int(self.level.get() as i64), diff --git a/src/library/structure/list.rs b/src/library/structure/list.rs index 4356ffb4..fca7d5ce 100644 --- a/src/library/structure/list.rs +++ b/src/library/structure/list.rs @@ -75,6 +75,17 @@ impl<const L: ListKind> ListNode<L> { } impl<const L: ListKind> Show for ListNode<L> { + fn unguard(&self, sel: Selector) -> ShowNode { + Self { + items: self.items.map(|item| ListItem { + body: Box::new(item.body.unguard(sel)), + ..*item + }), + ..*self + } + .pack() + } + fn encode(&self) -> Dict { dict! { "start" => Value::Int(self.start as i64), @@ -83,7 +94,7 @@ impl<const L: ListKind> Show for ListNode<L> { "items" => Value::Array( self.items .items() - .map(|item| Value::Content((*item.body).clone())) + .map(|item| Value::Content(item.body.as_ref().clone())) .collect() ), } diff --git a/src/library/structure/table.rs b/src/library/structure/table.rs index 7b3f2ac5..304a8681 100644 --- a/src/library/structure/table.rs +++ b/src/library/structure/table.rs @@ -51,6 +51,15 @@ impl TableNode { } impl Show for TableNode { + fn unguard(&self, sel: Selector) -> ShowNode { + Self { + tracks: self.tracks.clone(), + gutter: self.gutter.clone(), + cells: self.cells.iter().map(|cell| cell.unguard(sel)).collect(), + } + .pack() + } + fn encode(&self) -> Dict { dict! { "cells" => Value::Array( |
