fix(coding-agent): render HTML-like message content verbatim in exports

closes #3484
This commit is contained in:
Mario Zechner
2026-04-21 09:24:22 +02:00
parent ac99bdba00
commit c6cef7c806
2 changed files with 13 additions and 10 deletions

View File

@@ -1448,18 +1448,21 @@
// INITIALIZATION
// ============================================================
// Escape HTML tags in text (but not code blocks)
function escapeHtmlTags(text) {
return text.replace(/<(?=[a-zA-Z\/])/g, '&lt;');
}
// Configure marked with syntax highlighting and HTML escaping for text
// Configure marked with syntax highlighting and TUI-compatible HTML handling
const strictStrikethroughRegex = /^(~~)(?=[^\s~])((?:\\.|[^\\])*?(?:\\.|[^\s~\\]))\1(?=[^~]|$)/;
marked.use({
breaks: true,
gfm: true,
tokenizer: {
// Treat HTML-like input as plain text so tags are shown verbatim,
// matching the TUI markdown renderer.
html() {
return undefined;
},
tag() {
return undefined;
},
del(src) {
const match = strictStrikethroughRegex.exec(src);
if (!match) return undefined;
@@ -1493,10 +1496,6 @@
}
return `<pre><code class="hljs">${highlighted}</code></pre>`;
},
// Text content: escape HTML tags
text(token) {
return escapeHtmlTags(escapeHtml(token.text));
},
// Inline code: escape HTML
codespan(token) {
return `<code>${escapeHtml(token.text)}</code>`;