1#[derive(Debug, Clone, PartialEq)]
5pub enum Inline {
6 Text(String),
7 SoftBreak,
8 HardBreak,
9 Code(String),
10 Strong(Vec<Inline>),
11 Emphasis(Vec<Inline>),
12 Strikethrough(Vec<Inline>),
13 Link {
14 text: Vec<Inline>,
15 url: String,
16 },
17 Image {
18 alt: String,
19 url: String,
20 },
21 Math(String, bool),
23 Html(String),
24 FootnoteRef(String),
25}
26
27#[derive(Debug, Clone, PartialEq)]
28pub struct ListItem {
29 pub checked: Option<bool>,
31 pub children: Vec<Block>,
32}
33
34#[derive(Debug, Clone, Copy, PartialEq, Eq)]
35pub enum Alignment {
36 None,
37 Left,
38 Center,
39 Right,
40}
41
42#[derive(Debug, Clone, PartialEq)]
43pub enum Block {
44 Paragraph(Vec<Inline>),
45 Heading {
46 level: u8,
47 children: Vec<Inline>,
48 },
49 Code {
50 lang: String,
51 text: String,
52 },
53 BlockQuote(Vec<Block>),
54 List {
55 ordered: bool,
56 start: u64,
57 items: Vec<ListItem>,
58 },
59 Table {
60 headers: Vec<Vec<Inline>>,
61 rows: Vec<Vec<Vec<Inline>>>,
62 aligns: Vec<Alignment>,
63 },
64 ThematicBreak,
65 Html(String),
66 FootnoteDefinition {
67 label: String,
68 children: Vec<Block>,
69 },
70}
71
72#[derive(Debug, Clone, PartialEq, Default)]
74pub struct Ast {
75 pub children: Vec<Block>,
76}
77
78impl Ast {
79 pub fn is_empty(&self) -> bool {
80 self.children.is_empty()
81 }
82}