加固 UI HTML 注释转义
循环替换连续连字符,防止注释边界被提前闭合
This commit is contained in:
@@ -9,9 +9,10 @@ pub(super) fn font_face_rule(
|
||||
}
|
||||
|
||||
pub(super) fn html_comment(label: &str, value: serde_json::Value) -> Markup {
|
||||
let text = serde_json::to_string_pretty(&value)
|
||||
.unwrap_or_else(|_| "{}".to_string())
|
||||
.replace("--", "- -");
|
||||
let mut text = serde_json::to_string_pretty(&value).unwrap_or_else(|_| "{}".to_string());
|
||||
while text.contains("--") {
|
||||
text = text.replace("--", "- -");
|
||||
}
|
||||
PreEscaped(format!("<!-- {label}:\n{text}\n-->"))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user