#[derive(Debug, Clone, PartialEq)]
pub enum DocNode {
Document(Document),
Heading(Heading),
Paragraph(Paragraph),
List(List),
ListItem(ListItem),
Definition(Definition),
Verbatim(Verbatim),
Annotation(Annotation),
Inline(InlineContent),
Table(Table),
Image(Image),
Video(Video),
Audio(Audio),
}
#[derive(Debug, Clone, PartialEq)]
pub struct Document {
pub title: Option<Vec<InlineContent>>,
pub subtitle: Option<Vec<InlineContent>>,
pub children: Vec<DocNode>,
}
#[derive(Debug, Clone, PartialEq)]
pub struct Heading {
pub level: usize,
pub content: Vec<InlineContent>,
pub children: Vec<DocNode>,
}
#[derive(Debug, Clone, PartialEq)]
pub struct Paragraph {
pub content: Vec<InlineContent>,
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum ListStyle {
Bullet,
Numeric,
AlphaLower,
AlphaUpper,
RomanLower,
RomanUpper,
}
impl ListStyle {
pub fn is_ordered(self) -> bool {
!matches!(self, ListStyle::Bullet)
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum ListForm {
Short,
Extended,
}
#[derive(Debug, Clone, PartialEq)]
pub struct List {
pub items: Vec<ListItem>,
pub ordered: bool,
pub style: ListStyle,
pub form: ListForm,
}
#[derive(Debug, Clone, PartialEq)]
pub struct ListItem {
pub content: Vec<InlineContent>,
pub children: Vec<DocNode>,
}
#[derive(Debug, Clone, PartialEq)]
pub struct Definition {
pub term: Vec<InlineContent>,
pub description: Vec<DocNode>,
}
#[derive(Debug, Clone, PartialEq)]
pub struct Verbatim {
pub subject: Option<String>,
pub language: Option<String>,
pub content: String,
}
#[derive(Debug, Clone, PartialEq)]
pub struct Annotation {
pub label: String,
pub parameters: Vec<(String, String)>,
pub content: Vec<DocNode>,
}
#[derive(Debug, Clone, PartialEq)]
pub struct Table {
pub rows: Vec<TableRow>,
pub header: Vec<TableRow>,
pub caption: Option<Vec<InlineContent>>,
pub footnotes: Vec<DocNode>,
pub fullwidth: bool,
}
#[derive(Debug, Clone, PartialEq)]
pub struct TableRow {
pub cells: Vec<TableCell>,
}
#[derive(Debug, Clone, PartialEq)]
pub struct TableCell {
pub content: Vec<DocNode>,
pub header: bool,
pub align: TableCellAlignment,
pub colspan: usize,
pub rowspan: usize,
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum TableCellAlignment {
Left,
Center,
Right,
None,
}
#[derive(Debug, Clone, PartialEq)]
pub enum InlineContent {
Text(String),
Bold(Vec<InlineContent>),
Italic(Vec<InlineContent>),
Code(String),
Math(String),
Reference(String),
Link {
text: String,
href: String,
},
Image(Image),
}
#[derive(Debug, Clone, PartialEq)]
pub struct Image {
pub src: String,
pub alt: String,
pub title: Option<String>,
}
#[derive(Debug, Clone, PartialEq)]
pub struct Video {
pub src: String,
pub title: Option<String>,
pub poster: Option<String>,
}
#[derive(Debug, Clone, PartialEq)]
pub struct Audio {
pub src: String,
pub title: Option<String>,
}