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:
@@ -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('&', "&")
|
||||
.replace('<', "<")
|
||||
.replace('>', ">")
|
||||
.replace('"', """)
|
||||
}
|
||||
|
||||
/// Convert heading text to a URL-friendly slug ID.
|
||||
fn slugify(text: &str) -> String {
|
||||
text.to_lowercase()
|
||||
|
||||
Reference in New Issue
Block a user