docs: establish marqdo-lint architecture and examples
This commit is contained in:
1 parent
326c9bb119
commit
68b14db095
19 files changed
+1338
No files matched your search
@@ -0,0 +1,30 @@
|
||||
use std::{fs, path::Path};
|
||||
|
||||
use comrak::{markdown_to_html, 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/nested/inventory.mq.md", "examples/rendered/inventory.html"),
|
||||
("examples/knowledge/discount.mq.md", "examples/rendered/discount.html"),
|
||||
];
|
||||
let mut options = Options::default();
|
||||
options.extension.table = true;
|
||||
options.extension.strikethrough = true;
|
||||
options.extension.tasklist = true;
|
||||
options.extension.math_dollars = true;
|
||||
options.extension.math_dollars_block = true;
|
||||
options.extension.front_matter_delimiter = Some("---".to_string());
|
||||
|
||||
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");
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user