summaryrefslogtreecommitdiff
path: root/src/text.rs
blob: e9dbdebf5568571df160c6e3ea33e85c3b25a3a8 (plain) (blame)
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
pub enum Text {
    Normal(String),
    Bold(String),
    Italic(String),
    BoldItalic(String),
    Code(String),
    WikiLink(String),
    Hyperlink(Hyperlink),
}
impl std::fmt::Debug for Text {
    fn fmt(&self, f: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> {
        let string = match self {
            Text::Normal(text) => format!("Normal ('{}')", text),
            Text::Bold(text) => format!("Bold ('{}')", text),
            Text::Italic(text) => format!("Italic ('{}')", text),
            Text::BoldItalic(text) => format!("BoldItalic ('{}')", text),
            Text::Code(text) => format!("Code ('{}')", text),
            Text::WikiLink(text) => format!("WikiLink ('{}')", text),
            Text::Hyperlink(Hyperlink { label, target }) => {
                format!("Hyperlink (label:'{}',  target:'{}')", label, target)
            }
        };
        f.write_str(&string)
    }
}

pub struct Hyperlink {
    pub label: String,
    pub target: String,
}