mod event;
mod parser;
pub use event::{Alignment, BlockEvent, CalloutType, ListKind, TaskState};
pub use parser::BlockParser;
pub fn fixup_list_tight(events: &mut [BlockEvent]) {
let mut list_starts: Vec<usize> = Vec::new();
let mut patches: Vec<(usize, bool)> = Vec::new();
for i in 0..events.len() {
match &events[i] {
BlockEvent::ListStart { .. } => {
list_starts.push(i);
}
BlockEvent::ListEnd { tight, .. } => {
if let Some(start_idx) = list_starts.pop() {
patches.push((start_idx, *tight));
}
}
_ => {}
}
}
for (start_idx, tight) in patches {
if let BlockEvent::ListStart { kind, .. } = &events[start_idx] {
let kind = *kind;
events[start_idx] = BlockEvent::ListStart { kind, tight };
}
}
}