raw
1
17
21#[derive(Debug, Clone, PartialEq)]
23pub struct Document {
24 pub blocks: Vec<Block>,
26}
27
28
32#[derive(Debug, Clone, PartialEq)]
34pub enum Block {
35 Paragraph(Vec<Inline>),
37
38 Heading(Heading),
40
41 ThematicBreak,
43
44 BlockQuote(Vec<Block>),
46
47 List(List),
49
50 CodeBlock(CodeBlock),
52
53 HtmlBlock(String),
55
56 Definition(LinkDefinition),
58
59 Table(Table),
61
62 FootnoteDefinition(FootnoteDefinition),
64
65 Callout(Callout),
67
68 Empty,
70}
71
72#[derive(Debug, Clone, PartialEq, Eq)]
74pub struct Heading {
75 pub kind: HeadingKind,
77
78 pub content: Vec<Inline>,
80}
81
82#[derive(Debug, Clone, Copy, PartialEq, Eq)]
84pub enum HeadingKind {
85 Atx(u8),
87
88 Setext(SetextHeading),
90}
91
92#[derive(Debug, Clone, Copy, PartialEq, Eq)]
94pub enum SetextHeading {
95 Level1,
97
98 Level2,
100}
101
102
106#[derive(Debug, Clone, PartialEq)]
108pub struct List {
109 pub kind: ListKind,
112
113 pub items: Vec<ListItem>,
115}
116
117#[derive(Debug, Clone, Copy, PartialEq, Eq)]
119pub enum ListKind {
120 Ordered(ListOrderedKindOptions),
122
123 Bullet(ListBulletKind),
125}
126
127#[derive(Debug, Clone, Copy, PartialEq, Eq)]
129pub struct ListOrderedKindOptions {
130 pub start: u64,
132}
133
134#[derive(Debug, Clone, Copy, PartialEq, Eq)]
136pub enum ListBulletKind {
137 Dash,
139
140 Star,
142
143 Plus,
145}
146
147#[derive(Debug, Clone, PartialEq)]
149pub struct ListItem {
150 pub task: Option<TaskState>,
152
153 pub blocks: Vec<Block>,
155}
156
157#[derive(Debug, Clone, Copy, PartialEq, Eq)]
159pub enum TaskState {
160 Incomplete,
162
163 Complete,
165}
166
167
171#[derive(Debug, Clone, PartialEq, Eq)]
173pub struct CodeBlock {
174 pub kind: CodeBlockKind,
176
177 pub literal: String,
179}
180
181#[derive(Debug, Clone, PartialEq, Eq)]
183pub enum CodeBlockKind {
184 Indented,
186
187 Fenced { info: Option<String> },
189}
190
191
195#[derive(Debug, Clone, PartialEq, Eq)]
197pub struct LinkDefinition {
198 pub label: Vec<Inline>,
200
201 pub destination: String,
203
204 pub title: Option<String>,
206}
207
208
212#[derive(Debug, Clone, PartialEq, Eq)]
215pub struct Table {
216 pub rows: Vec<TableRow>,
218
219 pub alignments: Vec<Alignment>,
221}
222
223pub type TableRow = Vec<TableCell>;
225
226pub type TableCell = Vec<Inline>;
228
229#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
231pub enum Alignment {
232 None,
234
235 #[default]
237 Left,
238
239 Center,
241
242 Right,
244}
245
246
250#[derive(Debug, Clone, PartialEq)]
251pub struct FootnoteDefinition {
252 pub label: String,
254
255 pub blocks: Vec<Block>,
257}
258
259
263#[derive(Debug, Clone, PartialEq)]
264pub struct Callout {
265 pub level: String,
266
267 pub title: Option<String>,
268
269 pub foldable: bool,
270
271 pub open: bool,
272
273 pub blocks: Vec<Block>,
275}
276
277
281#[derive(Debug, Clone, PartialEq, Hash, Eq)]
282pub enum Inline {
283 Text(String),
285
286 LineBreak,
288
289 Code(String),
291
292 Html(String),
294
295 Link(Link),
297
298 LinkReference(LinkReference),
300
301 Tag(Tag),
303 Wikilink(Wikilink),
305
306 Image(Image),
308
309 Emphasis(Vec<Inline>),
311 Strong(Vec<Inline>),
313 Strikethrough(Vec<Inline>),
315
316 Autolink(String),
318
319 FootnoteReference(String),
321
322 Empty,
324}
325
326#[derive(Debug, Clone, PartialEq, Hash, Eq)]
328pub struct Link {
329 pub destination: String,
331
332 pub title: Option<String>,
334
335 pub children: Vec<Inline>,
337}
338
339#[derive(Debug, Clone, PartialEq, Hash, Eq)]
341pub struct Image {
342 pub destination: String,
344
345 pub title: Option<String>,
347
348 pub alt: String,
350}
351
352#[derive(Debug, Clone, PartialEq, Hash, Eq)]
353pub struct LinkReference {
354 pub label: Vec<Inline>,
356
357 pub text: Vec<Inline>,
359}
360
361#[derive(Debug, Clone, PartialEq, Hash, Eq)]
362pub struct Tag {
363 pub text: String,
365}
366
367#[derive(Debug, Clone, PartialEq, Hash, Eq)]
368pub struct Wikilink {
369 pub link: String,
371
372 pub target: Option<String>,
374
375 pub name: Option<String>,
377}
378