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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
//! ### Antwerp
//! [Antwerp](https://crates.io/crates/antwerp) is an open-source framework ported from JavaScript to Rust for GitHub pages and built with the Marcus HTML to MarkDown parser.
//! It outputs static web pages in `dist/` using HTML and MarkDown templates in `public/`, which are converted to HTML using the [Marcus](https://crates.io/crates/marcus) MarkDown to HTML parser.
//!
//! References & Getting Started:
//! - <https://crates.io/crates/antwerp>
//! - <https://github.com/Malekaia/Antwerp>
//! - <https://docs.rs/antwerp/latest/antwerp/>
//! - <https://crates.io/crates/marcus>
//! - <https://github.com/Malekaia/Marcus/>
//! - <https://docs.rs/marcus/latest/marcus/>
//! - <https://developer.mozilla.org/en-US/docs/Web/HTML>
//! - <https://www.markdownguide.org/>
use cratefilter_output;
use crateparse_templates;
use HashMap;
use ;
/// Type alias representing a `Vector` of `String` for filter lists in block declarations.
///
/// For example, the following block:
///
/// `{% block ... filter_1 | filter_2 | filter_n %}...{% endblock ... %}`
///
/// Would produce a `Vector` equivalent to:
///
/// `vec![String::from("filter_1"), String::from("filter_2"), String::from("filter_n")]`
pub type Filters = ;
/// Contains information for blocks derived from block declarations in templates.
///
/// Fields:
/// - `filters`: a `Vector` of `String` for filter lists in block declarations (see [`Filters`])
/// - `content_outer`: a String containing the outer content of a block (see `content_outer` of [`Block`])
/// - `content`: a String containing the inner content of a block (see `content` of [`Block`])
/// Type alias representing a `HashMap` where key: `String` and value: [`Block`].
///
/// A `HashMap` with this type is used to contain the blocks (organised by name) of a given HTML or MarkDown template.
///
/// For example, a template with a single block declaration:
///
/// `{% block test filter_1 | filter_2 | filter_n %}This is a test block{% endblock test %}`
///
/// Would produce the following `HashMap`:
///
/// ```rust
/// Blocks {
/// "test": Block {
/// filters: vec!["filter_1", "filter_2", "filter_n"],
/// content_outer: "{% block test filter_1 | filter_2 | filter_n %}This is a test block{% endblock test %}",
/// content: "This is a test block"
/// }
/// }
/// ```
pub type Blocks = ;
/// Contains template information derived from HTML and MarkDown templates.
///
/// Fields:
/// - `extends`: a `String` containing the file path provided by an extends statement (see `extends` of [`Template`])
/// - `output`: a `String` containing the file path of the output file
/// - `output_dir`: a `String` containing the directory of the output file
/// - `content`: a `String` containing the file content of the given template
/// - `blocks`: contains the blocks (organised by name) of a given HTML or MarkDown template (see [`Blocks`])
/// Type alias representing a `HashMap` where key: `String` and value: [`Template`].
///
/// A `HashMap` with this type is used to contain the template information (organised by file path) of a given HTML or MarkDown template.
///
/// For example, the following Markdown template containing an extends statement and a single block:
///
/// ```markdown
/// {% extends "base.html" %}
/// {% block title %}Homepage{% endblock title %}
/// ```
///
/// Would produce the a `HashMap`similar to:
///
/// ```rust
/// Templates {
/// "/home/<USERNAME>/<PATH>/<TO>/<PROJECT>/public/file.md": Template {
/// extends: "/home/<USERNAME>/<PATH>/<TO>/<PROJECT>/public/base.html",
/// output: "/home/<USERNAME>/<PATH>/<TO>/<PROJECT>/dist/file.html",
/// output_dir: "/home/<USERNAME>/<PATH>/<TO>/<PROJECT>/dist/",
/// content: "{% extends "base.html" %}\n{% block title %}Homepage{% endblock title %}",
/// blocks: {
/// title: Block {
/// filters: vec![],
/// content_outer: "{% block title %}Homepage{% endblock title %}",
/// content: "Homepage"
/// }
/// }
/// }
/// }
/// ```
pub type Templates = ;
/// Type aliases for filter methods
pub type FilterMethod = fn ;
pub type FilterMethods = ;
/// [`Build`](build) Parses HTML and MarkDown templates in `public/` and writes the HTML output to `dist/`
///
/// 1. Extracts template data from templates in `public/`
/// 3. Replaces block declarations in base template with content from child templates
/// 4. Inserts default block content for undefined blocks in child templates
/// 2. Uses filters to modify content before inserting into parent template
/// 5. Creates the output directory and writes the HTML template to the output file
///
/// **Note**: For sample templates and input, see [README.md](https://github.com/Malekaia/Antwerp#readme).
/// Test for GitHub Workflows (`.github/workflows/build.yaml`)