Skip to content

armgit / moli

Public Imported from GitHub
0

Best headless browser for AI agents. Lite, Fast, High-Compatibility. Built in Rust

Preserve literal characters in adjacent code HTML fallback

kevin43b8064a49c2
diff --git a/moli-html2md/src/writer.rs b/moli-html2md/src/writer.rs
index 6684a58f5..ddd444842 100644
--- a/moli-html2md/src/writer.rs
+++ b/moli-html2md/src/writer.rs
@@ -465,10 +465,6 @@ impl<'a> Writer<'a> {
'&' => self.output.push_str("&amp;"),
'<' => self.output.push_str("&lt;"),
'>' => self.output.push_str("&gt;"),
- '\\' | '`' | '*' | '_' | '[' | ']' | '|' | '~' => {
- self.output.push('\\');
- self.output.push(ch);
- }
_ => self.output.push(ch),
}
}
diff --git a/moli-html2md/tests/inline_boundaries.rs b/moli-html2md/tests/inline_boundaries.rs
index 51fe74785..07e9cc90e 100644
--- a/moli-html2md/tests/inline_boundaries.rs
+++ b/moli-html2md/tests/inline_boundaries.rs
@@ -82,6 +82,24 @@ fn inline_code_breaks_keep_separation_at_code_span_edges() {
);
}
+#[test]
+fn adjacent_code_html_fallback_keeps_literal_code_text() {
+ let source = r"<code>a*b_`\[x] &amp; &lt;tag&gt;</code><code>z</code>";
+ for preformatted_code in [false, true] {
+ let output = markdown_with(
+ source,
+ Options {
+ preformatted_code,
+ ..Options::default()
+ },
+ );
+ assert_eq!(
+ rendered_html(&output),
+ "<p><code>a*b_`\\[x] &amp; &lt;tag&gt;</code><code>z</code></p>\n"
+ );
+ }
+}
+
#[test]
fn inline_code_breaks_obey_the_depth_limit() {
let html = "<code>git<span><br></span>status</code>";