writedown/
ast.rs

1use crate::token;
2
3#[derive(Debug)]
4pub enum Node {
5    //Top(Option<Header>, Rc<Node>),
6    Section(Section),
7    Paragraph(Paragraph),
8    Func,
9    List,
10    Block(Block),
11    Math,
12    InlineCode,
13    Link,
14    Style(String),
15    Unknown(String),
16}
17
18#[derive(Debug)]
19pub struct Section {
20    pub level: usize,
21    pub title: String,
22    pub child: Vec<Node>,
23}
24
25#[derive(Debug)]
26pub struct Paragraph {
27    pub child: Vec<ParagraphChild>,
28}
29
30#[derive(Debug)]
31pub enum ParagraphChild {
32    Sentence(String),
33    Func(Func),
34}
35
36#[derive(Debug)]
37pub struct Func {
38    pub name: String,
39    pub arg: Option<Vec<String>>,
40    pub block: Option<String>,
41}
42
43#[derive(Debug)]
44pub struct Header {
45    pub doctype: Option<()>,
46    pub title: Option<String>,
47    pub author: Option<String>,
48    pub description: Option<String>,
49}
50
51#[derive(Debug)]
52pub enum Block {
53    Code(String),
54    Quote,
55}
56
57impl Section {
58    pub fn new(title: token::Title) -> Self {
59        Self {
60            level: title.level,
61            title: title.name,
62            child: vec![],
63        }
64    }
65}