mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-26 12:26:38 -06:00
fix(ui): preserve standalone safe line breaks
This commit is contained in:
@@ -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" : "");
|
||||
}
|
||||
|
||||
@@ -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)" />',
|
||||
|
||||
Reference in New Issue
Block a user