fix(ui): preserve standalone safe line breaks

This commit is contained in:
Dallin Romney
2026-08-25 19:22:13 -07:00
parent 09057b8a0f
commit b970336e62
2 changed files with 8 additions and 2 deletions
+2 -2
View File
@@ -73,8 +73,8 @@ function renderRawMarkdownHtml(
if (progressBars) {
return PROGRESS_HTML_RE.test(content.trim()) ? content : "";
}
if (!block && /^<br\s*\/?>$/iu.test(content)) {
return "<br>";
if (/^<br\s*\/?>$/iu.test(content.trim())) {
return block ? "<br>\n" : "<br>";
}
return escapeMarkdownHtml(content) + (block ? "\n" : "");
}
+6
View File
@@ -145,6 +145,12 @@ describe("toSanitizedMarkdownHtml", () => {
expect(cell?.textContent).toBe("一二");
});
it("renders an attribute-free line break between Markdown blocks", () => {
const html = toSanitizedMarkdownHtml("before\n\n<br>\n\nafter");
expect(html).toBe("<p>before</p>\n<br>\n<p>after</p>\n");
});
it.each([
'<br onclick="alert(1)">',
'<br onmouseover="alert(1)" />',