fix(tui): cleaned up markdown rendering of inline tags and entities

- Stripped `<span>` and `<text>` tags from rendered markdown while preserving their contents.
- Updated HTML entity normalization to handle common special characters and numeric codes within the TUI.
- Ensured whitespace surrounding stripped inline tags is preserved, preventing content merging.
This commit is contained in:
can1357
2026-06-20 07:38:58 +02:00
parent 62756efb8f
commit 571eb5c4db
5 changed files with 139 additions and 7 deletions
@@ -29,4 +29,18 @@ describe("Transcript Markdown", () => {
expect(html).toContain("&lt;img src=x onerror=alert(1)&gt;");
expect(html).not.toContain("<img src=x");
});
it("strips span and text HTML tags but preserves their contents and inline text rendering", () => {
const html = renderMarkdown("<span></span><text>▃</text>");
expect(html).toContain("▃");
expect(html).not.toContain("&lt;span&gt;");
expect(html).not.toContain("&lt;text&gt;");
});
it("unescapes HTML entities inside span and text HTML tags safely", () => {
const html = renderMarkdown("<span>&lt;▃&gt; &amp; &quot;test&quot; &#128512; &#x1F600;</span>");
expect(html).toContain("&lt;▃&gt; &amp; &quot;test&quot; &#128512; &#x1F600;");
});
});