1#[derive(Debug, Clone, PartialEq)]
5pub enum DocNode {
6 Document(Document),
7 Heading(Heading),
8 Paragraph(Paragraph),
9 List(List),
10 ListItem(ListItem),
11 Definition(Definition),
12 Verbatim(Verbatim),
13 Annotation(Annotation),
14 Inline(InlineContent),
15 Table(Table),
16 Image(Image),
17 Video(Video),
18 Audio(Audio),
19}
20
21#[derive(Debug, Clone, PartialEq)]
23pub struct Document {
24 pub children: Vec<DocNode>,
25}
26
27#[derive(Debug, Clone, PartialEq)]
29pub struct Heading {
30 pub level: usize,
31 pub content: Vec<InlineContent>,
32 pub children: Vec<DocNode>,
33}
34
35#[derive(Debug, Clone, PartialEq)]
37pub struct Paragraph {
38 pub content: Vec<InlineContent>,
39}
40
41#[derive(Debug, Clone, Copy, PartialEq)]
43pub enum ListStyle {
44 Bullet,
46 Numeric,
48 AlphaLower,
50 AlphaUpper,
52 RomanLower,
54 RomanUpper,
56}
57
58impl ListStyle {
59 pub fn is_ordered(self) -> bool {
60 !matches!(self, ListStyle::Bullet)
61 }
62}
63
64#[derive(Debug, Clone, PartialEq)]
66pub struct List {
67 pub items: Vec<ListItem>,
68 pub ordered: bool,
69 pub style: ListStyle,
70}
71
72#[derive(Debug, Clone, PartialEq)]
74pub struct ListItem {
75 pub content: Vec<InlineContent>,
76 pub children: Vec<DocNode>,
77}
78
79#[derive(Debug, Clone, PartialEq)]
81pub struct Definition {
82 pub term: Vec<InlineContent>,
83 pub description: Vec<DocNode>,
84}
85
86#[derive(Debug, Clone, PartialEq)]
88pub struct Verbatim {
89 pub language: Option<String>,
90 pub content: String,
91}
92
93#[derive(Debug, Clone, PartialEq)]
95pub struct Annotation {
96 pub label: String,
97 pub parameters: Vec<(String, String)>,
98 pub content: Vec<DocNode>,
99}
100
101#[derive(Debug, Clone, PartialEq)]
103pub struct Table {
104 pub rows: Vec<TableRow>,
105 pub header: Vec<TableRow>,
106 pub caption: Option<Vec<InlineContent>>,
107}
108
109#[derive(Debug, Clone, PartialEq)]
111pub struct TableRow {
112 pub cells: Vec<TableCell>,
113}
114
115#[derive(Debug, Clone, PartialEq)]
117pub struct TableCell {
118 pub content: Vec<DocNode>,
119 pub header: bool,
120 pub align: TableCellAlignment,
121}
122
123#[derive(Debug, Clone, Copy, PartialEq)]
125pub enum TableCellAlignment {
126 Left,
127 Center,
128 Right,
129 None,
130}
131
132#[derive(Debug, Clone, PartialEq)]
134pub enum InlineContent {
135 Text(String),
136 Bold(Vec<InlineContent>),
137 Italic(Vec<InlineContent>),
138 Code(String),
139 Math(String),
140 Reference(String),
141 Marker(String),
142 Image(Image),
143}
144
145#[derive(Debug, Clone, PartialEq)]
147pub struct Image {
148 pub src: String,
149 pub alt: String,
150 pub title: Option<String>,
151}
152
153#[derive(Debug, Clone, PartialEq)]
155pub struct Video {
156 pub src: String,
157 pub title: Option<String>,
158 pub poster: Option<String>,
159}
160
161#[derive(Debug, Clone, PartialEq)]
163pub struct Audio {
164 pub src: String,
165 pub title: Option<String>,
166}