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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
use crate::{ast::ASTKind, utils::join_ast_list, AST};
use std::fmt::{self, Display, Formatter};
impl Display for AST {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
let children = self.children();
match &self.kind() {
ASTKind::None => write!(f, ""),
ASTKind::Statements => {
let s: Vec<_> = children.iter().map(|e| format!("{}", e)).collect();
write!(f, "{}", s.join("\n\n"))
}
ASTKind::Header { .. } => unimplemented!(),
ASTKind::HorizontalRule { .. } => unimplemented!(),
ASTKind::Paragraph { .. } => unimplemented!(),
ASTKind::CodeBlock(inner) => Display::fmt(inner, f),
ASTKind::MathBlock { .. } => unimplemented!(),
ASTKind::TableView { .. } => unimplemented!(),
ASTKind::ListView(inner) => Display::fmt(inner, f),
ASTKind::Normal(inner) => write!(f, "{}", inner),
ASTKind::Raw { .. } => unimplemented!(),
ASTKind::Code { .. } => unimplemented!(),
ASTKind::Italic { .. } => unimplemented!(),
ASTKind::Bold => write!(f, "**{}**", join_ast_list(&children)),
ASTKind::Emphasis { .. } => unimplemented!(),
ASTKind::Underline { .. } => unimplemented!(),
ASTKind::Strikethrough { .. } => unimplemented!(),
ASTKind::Undercover { .. } => unimplemented!(),
ASTKind::MathInline { .. } => unimplemented!(),
ASTKind::MathDisplay { .. } => unimplemented!(),
ASTKind::Link { .. } => unimplemented!(),
ASTKind::Escaped { .. } => unimplemented!(),
ASTKind::Command { .. } => unimplemented!(),
ASTKind::String { .. } => unimplemented!(),
ASTKind::Number { .. } => unimplemented!(),
ASTKind::Boolean { .. } => unimplemented!(),
ASTKind::Array { .. } => unimplemented!(),
ASTKind::Object => unimplemented!(),
}
}
}