forked from ordinals/ord
-
Notifications
You must be signed in to change notification settings - Fork 35
/
build.rs
32 lines (25 loc) Β· 684 Bytes
/
build.rs
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
use {
pulldown_cmark::{html, Parser},
std::{env, ffi::OsStr, fs, path::Path},
};
fn main() {
println!("cargo:rerun-if-changed=markdown");
for result in fs::read_dir("markdown").unwrap() {
let entry = result.unwrap();
let path = entry.path();
if path.extension() != Some(OsStr::new("md")) {
continue;
}
let input = fs::read_to_string(&path).unwrap();
let parser = Parser::new(&input);
let mut output = String::new();
html::push_html(&mut output, parser);
fs::write(
Path::new(&env::var("OUT_DIR").unwrap())
.join(path.file_stem().unwrap())
.with_extension("html"),
output,
)
.unwrap();
}
}