refactor: consolidate escape functions and extract weight constants

- Create escape.rs with shared html_escape, html_escape_into, xml_escape
- Remove duplicate implementations from render.rs, highlight.rs, feed.rs, sitemap.rs
- Add DEFAULT_WEIGHT (50) and DEFAULT_WEIGHT_HIGH (99) constants to content.rs
- Replace all magic number weight defaults with named constants

No functional changes; all 67 tests pass.
This commit is contained in:
Timothy DeHerrera
2026-02-05 14:35:24 -07:00
parent 7a7dc929b1
commit 16f04eb95b
7 changed files with 84 additions and 55 deletions

View File

@@ -1,5 +1,6 @@
//! Markdown to HTML rendering via pulldown-cmark with syntax highlighting.
use crate::escape::html_escape;
use crate::highlight::{highlight_code, Language};
use pulldown_cmark::{CodeBlockKind, Event, HeadingLevel, Options, Parser, Tag, TagEnd};
use serde::Serialize;
@@ -247,13 +248,6 @@ pub fn markdown_to_html(markdown: &str) -> (String, Vec<Anchor>) {
(html_output, anchors)
}
fn html_escape(s: &str) -> String {
s.replace('&', "&amp;")
.replace('<', "&lt;")
.replace('>', "&gt;")
.replace('"', "&quot;")
}
/// Convert heading text to a URL-friendly slug ID.
fn slugify(text: &str) -> String {
text.to_lowercase()