use crate::Range;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum CalloutType {
Note,
Tip,
Important,
Warning,
Caution,
}
impl CalloutType {
pub fn css_suffix(self) -> &'static str {
match self {
Self::Note => "note",
Self::Tip => "tip",
Self::Important => "important",
Self::Warning => "warning",
Self::Caution => "caution",
}
}
pub fn title(self) -> &'static str {
match self {
Self::Note => "Note",
Self::Tip => "Tip",
Self::Important => "Important",
Self::Warning => "Warning",
Self::Caution => "Caution",
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub enum Alignment {
#[default]
None,
Left,
Center,
Right,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum BlockEvent {
ParagraphStart,
ParagraphEnd,
HeadingStart {
level: u8,
},
HeadingEnd {
level: u8,
},
CodeBlockStart {
info: Option<Range>,
},
CodeBlockEnd,
BlockQuoteStart {
callout: Option<CalloutType>,
},
BlockQuoteEnd,
ListStart {
kind: ListKind,
tight: bool,
},
ListEnd {
kind: ListKind,
tight: bool,
},
ListItemStart {
task: TaskState,
},
ListItemEnd,
ThematicBreak,
HtmlBlockStart,
HtmlBlockEnd,
HtmlBlockText(Range),
SoftBreak,
Text(Range),
Code(Range),
VirtualSpaces(u8),
TableStart,
TableEnd,
TableHeadStart,
TableHeadEnd,
TableBodyStart,
TableBodyEnd,
TableRowStart,
TableRowEnd,
TableCellStart {
alignment: Alignment,
},
TableCellEnd,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum ListKind {
Unordered,
Ordered {
start: u32,
delimiter: u8,
},
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub enum TaskState {
#[default]
None,
Unchecked,
Checked,
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_event_size() {
assert!(std::mem::size_of::<BlockEvent>() <= 24);
}
#[test]
fn test_list_kind() {
let ul = ListKind::Unordered;
let ol = ListKind::Ordered {
start: 1,
delimiter: b'.',
};
assert_ne!(ul, ol);
}
#[test]
fn test_task_state_default() {
assert_eq!(TaskState::default(), TaskState::None);
}
}