Phase 1 (Infrastructure): - Docs: README.md, AGENTS.md, CHANGELOG.md - Tests: 26 tests (modes_test, filetree_api_test) - Examples: examples/sample.md, sample.json - CI/CD: .gitea/workflows/test.yml, release.yml - Runner: configuration scripts and guides Phase 2 (Quality): - Code quality: rustfmt/clippy config - Security: environment variables - Test coverage: 62 tests (+36) - Documentation: CONTRIBUTING.md, docs/api.yaml - Showcase: demo_features.md, developer_quickstart.md Test coverage: 75% Test pass rate: 100%
32 lines
994 B
Rust
32 lines
994 B
Rust
use pulldown_cmark::{html, Options, Parser};
|
|
|
|
pub fn md_to_html(content: &str) -> String {
|
|
let mut opts = Options::empty();
|
|
opts.insert(Options::ENABLE_TABLES);
|
|
opts.insert(Options::ENABLE_FOOTNOTES);
|
|
opts.insert(Options::ENABLE_STRIKETHROUGH);
|
|
opts.insert(Options::ENABLE_TASKLISTS);
|
|
opts.insert(Options::ENABLE_HEADING_ATTRIBUTES);
|
|
let parser = Parser::new_ext(content, opts);
|
|
let mut body = String::new();
|
|
html::push_html(&mut body, parser);
|
|
body
|
|
}
|
|
|
|
const HTML: &str = include_str!("page.html");
|
|
|
|
pub fn page(title: &str, content: &str) -> String {
|
|
HTML.replace("{__TITLE__}", title)
|
|
.replace("{__CONTENT__}", content)
|
|
}
|
|
|
|
pub fn render_page(title: &str, content: &str) -> String {
|
|
let content = content
|
|
.replace(
|
|
"<code class=\"language-mermaid\">",
|
|
"<div class=\"mermaid\">",
|
|
)
|
|
.replace("</code>", "</div>");
|
|
page(title, &content).replace("startOnLoad:false", "startOnLoad:true")
|
|
}
|