summaryrefslogtreecommitdiff
path: root/src/library/structure/list.rs
diff options
context:
space:
mode:
authorMartin Haug <mhaug@live.de>2022-06-04 12:57:45 +0200
committerMartin Haug <mhaug@live.de>2022-06-04 12:57:45 +0200
commit4640585fbdf72df993dbed46799844aa78996cce (patch)
tree38a09389885a61068970441d6d27178a2ae4f115 /src/library/structure/list.rs
parenta937462491a63f5cff3551b5bb8bc45fb350f0b6 (diff)
First iteration of outline items
Diffstat (limited to 'src/library/structure/list.rs')
-rw-r--r--src/library/structure/list.rs20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/library/structure/list.rs b/src/library/structure/list.rs
index 84603eb3..563426b4 100644
--- a/src/library/structure/list.rs
+++ b/src/library/structure/list.rs
@@ -2,10 +2,11 @@ use std::fmt::Write;
use unscanny::Scanner;
-use crate::library::layout::{BlockSpacing, GridNode, TrackSizing};
+use crate::library::layout::{BlockSpacing, GridNode, GridSemantics, TrackSizing};
use crate::library::prelude::*;
use crate::library::text::ParNode;
use crate::library::utility::Numbering;
+use crate::model::StyleEntry;
/// An unordered (bulleted) or ordered (numbered) list.
#[derive(Debug, Hash)]
@@ -76,9 +77,12 @@ impl<const L: ListKind> ListNode<L> {
impl<const L: ListKind> Show for ListNode<L> {
fn unguard(&self, sel: Selector) -> ShowNode {
+ let mut map = StyleMap::with_role(Role::ListItemBody);
+ map.push(StyleEntry::Unguard(sel));
+
Self {
items: self.items.map(|item| ListItem {
- body: Box::new(item.body.unguard(sel)),
+ body: Box::new(item.body.clone().styled_with_map(map.clone())),
..*item
}),
..*self
@@ -108,9 +112,12 @@ impl<const L: ListKind> Show for ListNode<L> {
for (item, map) in self.items.iter() {
number = item.number.unwrap_or(number);
+
+ let mut label_map = map.clone();
+ label_map.push(StyleEntry::Role(Role::ListLabel));
+
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(label_map).pack());
cells.push(LayoutNode::default());
cells.push((*item.body).clone().styled_with_map(map.clone()).pack());
number += 1;
@@ -134,6 +141,7 @@ impl<const L: ListKind> Show for ListNode<L> {
]),
gutter: Spec::with_y(vec![TrackSizing::Relative(gutter.into())]),
cells,
+ semantic: GridSemantics::List,
}))
}
@@ -155,7 +163,9 @@ impl<const L: ListKind> Show for ListNode<L> {
}
}
- Ok(realized.spaced(above, below))
+ Ok(realized
+ .styled_with_map(StyleMap::with_role(Role::List(L == ORDERED)))
+ .spaced(above, below))
}
}