42 lines
1.4 KiB
Rust
42 lines
1.4 KiB
Rust
use std::{fs, path::Path};
|
|
|
|
use comrak::markdown_to_html;
|
|
use marqdo_lint::input::profile_options;
|
|
|
|
fn main() {
|
|
let manifest = Path::new(env!("CARGO_MANIFEST_DIR"));
|
|
let fixtures = [
|
|
(
|
|
"examples/good/branches.mq.md",
|
|
"examples/rendered/branches.html",
|
|
),
|
|
(
|
|
"examples/bad/branch-single-item.mq.md",
|
|
"examples/rendered/branch-single-item.html",
|
|
),
|
|
(
|
|
"examples/bad/branches-unlisted.mq.md",
|
|
"examples/rendered/branches-unlisted.html",
|
|
),
|
|
(
|
|
"examples/nested/inventory.mq.md",
|
|
"examples/rendered/inventory.html",
|
|
),
|
|
(
|
|
"examples/knowledge/discount.mq.md",
|
|
"examples/rendered/discount.html",
|
|
),
|
|
];
|
|
let options = profile_options();
|
|
|
|
for (source, target) in fixtures {
|
|
let source_path = manifest.join(source);
|
|
let markdown = fs::read_to_string(&source_path).expect("读取渲染 Fixture");
|
|
let body = markdown_to_html(&markdown, &options);
|
|
let html = format!("<!doctype html>\n<html lang=\"zh-CN\">\n<meta charset=\"utf-8\">\n<title>Marqdo Lint Review Fixture</title>\n<body>\n{body}</body>\n</html>\n");
|
|
let target = manifest.join(target);
|
|
fs::create_dir_all(target.parent().expect("Fixture 父目录")).expect("创建渲染目录");
|
|
fs::write(target, html).expect("写入渲染 Fixture");
|
|
}
|
|
}
|