fix(coding-agent): render HTML-like message content verbatim in exports
closes #3484
This commit is contained in:
@@ -2,6 +2,10 @@
|
|||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Fixed exported session markdown to render Markdown while showing HTML-like message content such as `<file name="...">...</file>` verbatim, so shared sessions match the TUI instead of letting the browser interpret message text ([#3484](https://github.com/badlogic/pi-mono/issues/3484))
|
||||||
|
|
||||||
## [0.68.0] - 2026-04-20
|
## [0.68.0] - 2026-04-20
|
||||||
|
|
||||||
### New Features
|
### New Features
|
||||||
|
|||||||
@@ -1448,18 +1448,21 @@
|
|||||||
// INITIALIZATION
|
// INITIALIZATION
|
||||||
// ============================================================
|
// ============================================================
|
||||||
|
|
||||||
// Escape HTML tags in text (but not code blocks)
|
// Configure marked with syntax highlighting and TUI-compatible HTML handling
|
||||||
function escapeHtmlTags(text) {
|
|
||||||
return text.replace(/<(?=[a-zA-Z\/])/g, '<');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Configure marked with syntax highlighting and HTML escaping for text
|
|
||||||
const strictStrikethroughRegex = /^(~~)(?=[^\s~])((?:\\.|[^\\])*?(?:\\.|[^\s~\\]))\1(?=[^~]|$)/;
|
const strictStrikethroughRegex = /^(~~)(?=[^\s~])((?:\\.|[^\\])*?(?:\\.|[^\s~\\]))\1(?=[^~]|$)/;
|
||||||
|
|
||||||
marked.use({
|
marked.use({
|
||||||
breaks: true,
|
breaks: true,
|
||||||
gfm: true,
|
gfm: true,
|
||||||
tokenizer: {
|
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) {
|
del(src) {
|
||||||
const match = strictStrikethroughRegex.exec(src);
|
const match = strictStrikethroughRegex.exec(src);
|
||||||
if (!match) return undefined;
|
if (!match) return undefined;
|
||||||
@@ -1493,10 +1496,6 @@
|
|||||||
}
|
}
|
||||||
return `<pre><code class="hljs">${highlighted}</code></pre>`;
|
return `<pre><code class="hljs">${highlighted}</code></pre>`;
|
||||||
},
|
},
|
||||||
// Text content: escape HTML tags
|
|
||||||
text(token) {
|
|
||||||
return escapeHtmlTags(escapeHtml(token.text));
|
|
||||||
},
|
|
||||||
// Inline code: escape HTML
|
// Inline code: escape HTML
|
||||||
codespan(token) {
|
codespan(token) {
|
||||||
return `<code>${escapeHtml(token.text)}</code>`;
|
return `<code>${escapeHtml(token.text)}</code>`;
|
||||||
|
|||||||
Reference in New Issue
Block a user