Skip to content

Open-source AI browser agent for Chrome and Firefox (monorepo) 🧠

Keep trailing blank outside quoted Markdown fences

Emre Sokullu7c4f546772e4
diff --git a/src/chrome/src/ui/markdown-render.js b/src/chrome/src/ui/markdown-render.js
index 96d7b6bdf..46997f85f 100644
--- a/src/chrome/src/ui/markdown-render.js
+++ b/src/chrome/src/ui/markdown-render.js
@@ -452,6 +452,7 @@ function unfinishedContainerEnd(source, start, container, boundaryCache) {
pendingBlankStart = null;
offset += match[0].length;
}
+ if (pendingBlankStart != null && container.quoteDepth) end = pendingBlankStart;
boundaryCache.set(key, { start, end });
return end;
}
diff --git a/src/firefox/src/ui/markdown-render.js b/src/firefox/src/ui/markdown-render.js
index 96d7b6bdf..46997f85f 100644
--- a/src/firefox/src/ui/markdown-render.js
+++ b/src/firefox/src/ui/markdown-render.js
@@ -452,6 +452,7 @@ function unfinishedContainerEnd(source, start, container, boundaryCache) {
pendingBlankStart = null;
offset += match[0].length;
}
+ if (pendingBlankStart != null && container.quoteDepth) end = pendingBlankStart;
boundaryCache.set(key, { start, end });
return end;
}
diff --git a/test/markdown-render.mjs b/test/markdown-render.mjs
index c79b465da..d25cf7b32 100644
--- a/test/markdown-render.mjs
+++ b/test/markdown-render.mjs
@@ -516,6 +516,14 @@ for (const build of ['chrome', 'firefox']) {
}), '> BLOCK');
assert.deepEqual(trailingQuoteBlocks, [{ info: 'text', code: 'hello\n\n' }]);
+ const unprefixedTrailingBlank = '> ~~~text\n> hello\n\n';
+ const unprefixedTrailingBlocks = [];
+ assert.equal(helpers.replaceMarkdownCodeFences(unprefixedTrailingBlank, (info, code) => {
+ unprefixedTrailingBlocks.push({ info, code });
+ return 'BLOCK';
+ }), '> BLOCK\n');
+ assert.deepEqual(unprefixedTrailingBlocks, [{ info: 'text', code: 'hello\n' }]);
+
const quotedBlankBeforeProse = '> ~~~text\n> hello\n>\nOutside';
const quotedBlankBlocks = [];
assert.equal(helpers.replaceMarkdownCodeFences(quotedBlankBeforeProse, (info, code) => {