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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
use kb::ast::*;
use kb::generator::generate;
fn main() {
let doc = Document {
blocks: vec![
Block::Heading {
level: 1,
title: Title("Knowledge Base Demo".into()),
tags: vec![Tag("demo".into()), Tag("kb".into())],
children: vec![
Block::Paragraph {
inlines: vec![
Inline::Plain("This document was generated by the ".into()),
Inline::Bold(vec![Inline::Plain("tftio-kb".into())]),
Inline::Plain(" Rust crate. It demonstrates ".into()),
Inline::Italic(vec![Inline::Plain("all".into())]),
Inline::Plain(" block and inline constructors in the AST.".into()),
],
},
Block::PropertyDrawer {
entries: vec![
("ID".into(), "demo-001".into()),
("CREATED".into(), "<2026-05-01 Fri>".into()),
],
},
],
},
Block::Heading {
level: 2,
title: Title("Inline Formatting".into()),
tags: vec![],
children: vec![Block::Paragraph {
inlines: vec![
Inline::Plain("The AST supports ".into()),
Inline::Bold(vec![Inline::Plain("bold".into())]),
Inline::Plain(", ".into()),
Inline::Italic(vec![Inline::Plain("italic".into())]),
Inline::Plain(", ".into()),
Inline::InlineCode("inline code".into()),
Inline::Plain(", ".into()),
Inline::Verbatim("verbatim".into()),
Inline::Plain(", and ".into()),
Inline::Link {
target: "https://example.com".into(),
description: Some("links".into()),
},
Inline::Plain(" with descriptions, plus bare ".into()),
Inline::Link {
target: "https://sqlite.org".into(),
description: None,
},
Inline::Plain(" links.".into()),
],
}],
},
Block::Heading {
level: 2,
title: Title("Code Block".into()),
tags: vec![],
children: vec![Block::SrcBlock {
language: "rust".into(),
content: "fn main() {\n println!(\"Hello from kb!\");\n}".into(),
}],
},
Block::Heading {
level: 2,
title: Title("Lists".into()),
tags: vec![],
children: vec![
Block::Paragraph {
inlines: vec![Inline::Plain("Unordered list with checkboxes:".into())],
},
Block::List {
list_type: ListType::Unordered,
items: vec![
ListItem {
content: vec![Block::Paragraph {
inlines: vec![Inline::Plain("Design the AST types".into())],
}],
checkbox: Checkbox::Checked,
},
ListItem {
content: vec![Block::Paragraph {
inlines: vec![Inline::Plain("Implement the generator".into())],
}],
checkbox: Checkbox::Checked,
},
ListItem {
content: vec![Block::Paragraph {
inlines: vec![Inline::Plain("Write the parser".into())],
}],
checkbox: Checkbox::Checked,
},
ListItem {
content: vec![Block::Paragraph {
inlines: vec![Inline::Plain("Add storage layer".into())],
}],
checkbox: Checkbox::Unchecked,
},
],
},
Block::Paragraph {
inlines: vec![Inline::Plain("Ordered list:".into())],
},
Block::List {
list_type: ListType::Ordered(1),
items: vec![
ListItem {
content: vec![Block::Paragraph {
inlines: vec![Inline::Plain("Phase 1: scaffold".into())],
}],
checkbox: Checkbox::NoCheckbox,
},
ListItem {
content: vec![Block::Paragraph {
inlines: vec![Inline::Plain("Phase 2: core types".into())],
}],
checkbox: Checkbox::NoCheckbox,
},
],
},
],
},
Block::Heading {
level: 2,
title: Title("Quote Block".into()),
tags: vec![],
children: vec![Block::QuoteBlock {
children: vec![Block::Paragraph {
inlines: vec![Inline::Plain(
"The KB is headless. Clients translate between the canonical document model and whatever format their consumer wants.".into(),
)],
}],
}],
},
Block::Heading {
level: 2,
title: Title("Planning".into()),
tags: vec![],
children: vec![Block::Planning {
entries: vec![
PlanningEntry::Scheduled(Timestamp("<2026-05-01 Fri>".into())),
PlanningEntry::Deadline(Timestamp("<2026-05-15 Fri>".into())),
],
}],
},
Block::HorizontalRule,
Block::Paragraph {
inlines: vec![Inline::Plain("End of generated document.".into())],
},
Block::Comment {
text: "This comment should not appear in rendered output".into(),
},
],
};
println!("{}", generate(&doc));
}