- assets/page/{page.html,page.css,page.js} now hold the UI. build_page only
fills __MDP_*__ placeholders, so editing the page no longer means escaping
braces inside a format! string. Output was verified byte-identical for the
home page, a math/mermaid document and the startup page.
- src/markdown.rs: md -> html pipeline (GFM, AI-output dialect, front matter,
embedded images, ==highlight==, heading ids).
- src/page.rs: page assembly.
- src/escape.rs: shared JS/HTML escaping.
- src/main.rs drops from 5535 to 3709 lines. No behavior change; 62 tests.
26 lines
635 B
Rust
26 lines
635 B
Rust
//! Small text/JS escaping helpers shared by the page builder, the Markdown
|
|
//! pipeline and the renderer.
|
|
|
|
pub fn escape_js(s: &str) -> String {
|
|
s.replace('\\', "\\\\")
|
|
.replace('\'', "\\'")
|
|
.replace('\n', "\\n")
|
|
.replace('\r', "\\r")
|
|
}
|
|
|
|
pub fn html_escape_ta(s: &str) -> String {
|
|
s.replace('&', "&").replace('<', "<")
|
|
}
|
|
|
|
pub fn html_escape_attr(s: &str) -> String {
|
|
s.replace('&', "&")
|
|
.replace('"', """)
|
|
.replace('<', "<")
|
|
}
|
|
|
|
pub fn html_escape_text(s: &str) -> String {
|
|
s.replace('&', "&")
|
|
.replace('<', "<")
|
|
.replace('>', ">")
|
|
}
|