pub struct ListGrouper { /* private fields */ }Expand description
Tracks active list entities across consecutive blocks so that items belonging to the same logical list share a single list entity.
Uses a vec indexed by indent level. When indent decreases, deeper entries are truncated so that outer lists resume correctly.
Implementations§
Source§impl ListGrouper
impl ListGrouper
pub fn new() -> Self
Sourcepub fn try_reuse(&mut self, style: &ListStyle, indent: u32) -> Option<EntityId>
pub fn try_reuse(&mut self, style: &ListStyle, indent: u32) -> Option<EntityId>
Returns an existing list entity id if the style and indent match
a previously registered list at this level. Returns None if a
new list entity must be created (caller should then call register).
Sourcepub fn try_reuse_delim(
&mut self,
style: &ListStyle,
indent: u32,
prefix: &str,
suffix: &str,
) -> Option<EntityId>
pub fn try_reuse_delim( &mut self, style: &ListStyle, indent: u32, prefix: &str, suffix: &str, ) -> Option<EntityId>
Like try_reuse but also requires the ordered-list
delimiter affixes to match. Used by the djot importer, which preserves
the ./)/( ) delimiter on the List entity.
Sourcepub fn register(&mut self, id: EntityId, style: ListStyle, indent: u32)
pub fn register(&mut self, id: EntityId, style: ListStyle, indent: u32)
Register a newly created list entity at the given indent level.
Sourcepub fn register_delim(
&mut self,
id: EntityId,
style: ListStyle,
indent: u32,
prefix: String,
suffix: String,
)
pub fn register_delim( &mut self, id: EntityId, style: ListStyle, indent: u32, prefix: String, suffix: String, )
Like register but records the ordered-list delimiter
affixes so subsequent try_reuse_delim calls
can distinguish lists with different delimiters.