1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
use std::borrow::Cow;

#[derive(Debug, Clone, PartialEq, Eq)]
pub struct MarkdownTree<'a> {
    pub root: BlockTree<'a>,
}

#[derive(Debug, Clone, PartialEq, Eq)]
pub struct BlockTree<'a> {
    pub root: Vec<BlockItem<'a>>,
}

#[derive(Debug, Clone, PartialEq, Eq)]
pub enum BlockItem<'a> {
    Paragraph(InlineTree<'a>),
    Headline(u8, InlineTree<'a>),
    BulletList(ListTree<'a>),
    OrderedList(ListTree<'a>),
    BlockQuote(BlockTree<'a>),
    Container(Vec<String>, BlockTree<'a>),
}

#[derive(Debug, Clone, PartialEq, Eq)]
pub struct ListTree<'a> {
    pub root: Vec<ListItem<'a>>,
}

#[derive(Debug, Clone, PartialEq, Eq)]
pub struct ListItem<'a> {
    pub name: InlineTree<'a>,
    pub children: Vec<BlockItem<'a>>,
}

#[derive(Debug, Clone, PartialEq, Eq)]
pub struct InlineTree<'a> {
    pub root: Vec<InlineItem<'a>>,
}

#[derive(Debug, Clone, PartialEq, Eq)]
pub enum InlineItem<'a> {
    Text(Cow<'a, str>),
    Italic(InlineTree<'a>),
    Strong(InlineTree<'a>),
    Break,
}