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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
use crate::ast::html::HtmlEntity;
use crate::ast::segments::Formatting;
use crate::ir::html::HtmlNode;

use super::macros::Macro;

#[derive(Debug, Clone, PartialEq)]
pub enum Segment<'a> {
    LineBreak,
    Text(&'a str),
    Text2(String),
    EscapedText(&'a str),
    Limiter,
    Braces(Braces<'a>),
    Math(Math<'a>),
    Link(Link<'a>),
    Image(Image<'a>),
    InlineHtml(HtmlNode<'a>),
    HtmlEntity(HtmlEntity),
    Format(InlineFormat<'a>),
    Code(Code<'a>),
}

#[derive(Debug, Clone, PartialEq)]
pub struct Braces<'a> {
    pub macros: Vec<Macro<'a>>,
    pub segments: Vec<Segment<'a>>,
}

#[derive(Debug, Clone, PartialEq)]
pub struct Math<'a> {
    pub macros: Vec<Macro<'a>>,
    pub text: String,
}

#[derive(Debug, Clone, PartialEq)]
pub struct Link<'a> {
    pub macros: Vec<Macro<'a>>,
    pub href: Option<String>,
    pub text: Vec<Segment<'a>>,
    pub title: Option<String>,
    pub footnote: Option<u32>,
}

#[derive(Debug, Clone, PartialEq)]
pub struct Image<'a> {
    pub macros: Vec<Macro<'a>>,
    pub href: Option<String>,
    pub alt: Vec<Segment<'a>>,
    pub title: Option<String>,
}

#[derive(Debug, Clone, PartialEq)]
pub struct InlineFormat<'a> {
    pub formatting: Formatting,
    pub segments: Vec<Segment<'a>>,
}

#[derive(Debug, Clone, PartialEq)]
pub struct Code<'a> {
    pub macros: Vec<Macro<'a>>,
    pub segments: Vec<Segment<'a>>,
}