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, Copy, PartialEq)]
66pub enum ListForm {
67 Short,
69 Extended,
71}
72
73#[derive(Debug, Clone, PartialEq)]
75pub struct List {
76 pub items: Vec<ListItem>,
77 pub ordered: bool,
78 pub style: ListStyle,
79 pub form: ListForm,
80}
81
82#[derive(Debug, Clone, PartialEq)]
84pub struct ListItem {
85 pub content: Vec<InlineContent>,
86 pub children: Vec<DocNode>,
87}
88
89#[derive(Debug, Clone, PartialEq)]
91pub struct Definition {
92 pub term: Vec<InlineContent>,
93 pub description: Vec<DocNode>,
94}
95
96#[derive(Debug, Clone, PartialEq)]
98pub struct Verbatim {
99 pub subject: Option<String>,
100 pub language: Option<String>,
101 pub content: String,
102}
103
104#[derive(Debug, Clone, PartialEq)]
106pub struct Annotation {
107 pub label: String,
108 pub parameters: Vec<(String, String)>,
109 pub content: Vec<DocNode>,
110}
111
112#[derive(Debug, Clone, PartialEq)]
114pub struct Table {
115 pub rows: Vec<TableRow>,
116 pub header: Vec<TableRow>,
117 pub caption: Option<Vec<InlineContent>>,
118}
119
120#[derive(Debug, Clone, PartialEq)]
122pub struct TableRow {
123 pub cells: Vec<TableCell>,
124}
125
126#[derive(Debug, Clone, PartialEq)]
128pub struct TableCell {
129 pub content: Vec<DocNode>,
130 pub header: bool,
131 pub align: TableCellAlignment,
132}
133
134#[derive(Debug, Clone, Copy, PartialEq)]
136pub enum TableCellAlignment {
137 Left,
138 Center,
139 Right,
140 None,
141}
142
143#[derive(Debug, Clone, PartialEq)]
145pub enum InlineContent {
146 Text(String),
147 Bold(Vec<InlineContent>),
148 Italic(Vec<InlineContent>),
149 Code(String),
150 Math(String),
151 Reference(String),
152 Marker(String),
153 Image(Image),
154}
155
156#[derive(Debug, Clone, PartialEq)]
158pub struct Image {
159 pub src: String,
160 pub alt: String,
161 pub title: Option<String>,
162}
163
164#[derive(Debug, Clone, PartialEq)]
166pub struct Video {
167 pub src: String,
168 pub title: Option<String>,
169 pub poster: Option<String>,
170}
171
172#[derive(Debug, Clone, PartialEq)]
174pub struct Audio {
175 pub src: String,
176 pub title: Option<String>,
177}