summaryrefslogtreecommitdiff
path: root/src/library/structure
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2022-06-08 19:31:07 +0200
committerGitHub <noreply@github.com>2022-06-08 19:31:07 +0200
commitcd5a14bc240b21f8f538ff7fc1d116d23611d6c5 (patch)
treef4b8a7e8a941f8653d5061d2f7acc0bfd8d92b13 /src/library/structure
parentb905048d4bb497252028df6d21b525fefb6b64c3 (diff)
parent72d3f3fffabe6872eb7839585bea925b89aac6a4 (diff)
Merge pull request #75 from typst/semantics
Frame Role and PDF outline
Diffstat (limited to 'src/library/structure')
-rw-r--r--src/library/structure/heading.rs5
-rw-r--r--src/library/structure/list.rs16
-rw-r--r--src/library/structure/table.rs9
3 files changed, 22 insertions, 8 deletions
diff --git a/src/library/structure/heading.rs b/src/library/structure/heading.rs
index a0973b90..af2b3626 100644
--- a/src/library/structure/heading.rs
+++ b/src/library/structure/heading.rs
@@ -65,7 +65,8 @@ impl HeadingNode {
impl Show for HeadingNode {
fn unguard(&self, sel: Selector) -> ShowNode {
- Self { body: self.body.unguard(sel), ..*self }.pack()
+ let body = self.body.unguard(sel).role(Role::Heading(self.level.get()));
+ Self { body, ..*self }.pack()
}
fn encode(&self, _: StyleChain) -> Dict {
@@ -114,7 +115,7 @@ impl Show for HeadingNode {
realized = realized.underlined();
}
- realized = realized.styled_with_map(map);
+ realized = realized.styled_with_map(map).role(Role::Heading(self.level.get()));
realized = realized.spaced(
resolve!(Self::ABOVE).resolve(styles),
resolve!(Self::BELOW).resolve(styles),
diff --git a/src/library/structure/list.rs b/src/library/structure/list.rs
index 84603eb3..015ef520 100644
--- a/src/library/structure/list.rs
+++ b/src/library/structure/list.rs
@@ -78,7 +78,7 @@ 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)),
+ body: Box::new(item.body.unguard(sel).role(Role::ListItemBody)),
..*item
}),
..*self
@@ -108,9 +108,15 @@ impl<const L: ListKind> Show for ListNode<L> {
for (item, map) in self.items.iter() {
number = item.number.unwrap_or(number);
+
cells.push(LayoutNode::default());
- cells
- .push(label.resolve(ctx, L, number)?.styled_with_map(map.clone()).pack());
+ cells.push(
+ label
+ .resolve(ctx, L, number)?
+ .styled_with_map(map.clone())
+ .role(Role::ListLabel)
+ .pack(),
+ );
cells.push(LayoutNode::default());
cells.push((*item.body).clone().styled_with_map(map.clone()).pack());
number += 1;
@@ -155,7 +161,9 @@ impl<const L: ListKind> Show for ListNode<L> {
}
}
- Ok(realized.spaced(above, below))
+ Ok(realized
+ .role(Role::List { ordered: L == ORDERED })
+ .spaced(above, below))
}
}
diff --git a/src/library/structure/table.rs b/src/library/structure/table.rs
index cd70db30..0f74fc96 100644
--- a/src/library/structure/table.rs
+++ b/src/library/structure/table.rs
@@ -52,7 +52,11 @@ impl Show for TableNode {
Self {
tracks: self.tracks.clone(),
gutter: self.gutter.clone(),
- cells: self.cells.iter().map(|cell| cell.unguard(sel)).collect(),
+ cells: self
+ .cells
+ .iter()
+ .map(|cell| cell.unguard(sel).role(Role::TableCell))
+ .collect(),
}
.pack()
}
@@ -100,7 +104,8 @@ impl Show for TableNode {
tracks: self.tracks.clone(),
gutter: self.gutter.clone(),
cells,
- }))
+ })
+ .role(Role::Table))
}
fn finalize(