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
#[allow(dead_code)]
#[derive(Debug, Clone)]
pub struct Section {
pub level: u8,
pub title: String,
pub body: String,
pub parent: Option<usize>,
pub children: Vec<usize>,
}
impl Section {
pub fn new() -> Section {
Section {
level: 0,
title: String::new(),
body: String::new(),
parent: None,
children: Vec::new(),
}
}
pub fn append_to_body(&mut self, line: String) {
self.body.push_str(&line);
self.body.push('\n');
}
pub fn add_child(&mut self, child: usize) {
self.children.push(child);
}
}
pub type Document = Vec<Section>;