Skip to content

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

End Markdown quotes at blank boundaries

Emre Sokullu608f23689075
diff --git a/src/chrome/src/ui/markdown-render.js b/src/chrome/src/ui/markdown-render.js
index d042ee91e..f3fee85ae 100644
--- a/src/chrome/src/ui/markdown-render.js
+++ b/src/chrome/src/ui/markdown-render.js
@@ -394,6 +394,10 @@ function unfinishedContainerEnd(source, start, container, boundaryCache) {
end = pendingBlankStart ?? offset;
break;
}
+ if (pendingBlankStart != null && container.quoteDepth && !container.listPrefix) {
+ end = pendingBlankStart;
+ break;
+ }
pendingBlankStart = null;
offset += match[0].length;
}
diff --git a/src/firefox/src/ui/markdown-render.js b/src/firefox/src/ui/markdown-render.js
index d042ee91e..f3fee85ae 100644
--- a/src/firefox/src/ui/markdown-render.js
+++ b/src/firefox/src/ui/markdown-render.js
@@ -394,6 +394,10 @@ function unfinishedContainerEnd(source, start, container, boundaryCache) {
end = pendingBlankStart ?? offset;
break;
}
+ if (pendingBlankStart != null && container.quoteDepth && !container.listPrefix) {
+ end = pendingBlankStart;
+ break;
+ }
pendingBlankStart = null;
offset += match[0].length;
}
diff --git a/test/markdown-render.mjs b/test/markdown-render.mjs
index f4d38424e..935b33b9d 100644
--- a/test/markdown-render.mjs
+++ b/test/markdown-render.mjs
@@ -397,6 +397,14 @@ for (const build of ['chrome', 'firefox']) {
}), '> BLOCK');
assert.deepEqual(quoteBlankBlocks, [{ info: 'text', code: 'hello\n\n\nagain\n' }]);
+ const unprefixedQuoteBreak = '> ```text\n> first\n\n> second\n> ```\nAfter';
+ const unprefixedQuoteBlocks = [];
+ assert.equal(helpers.replaceMarkdownCodeFences(unprefixedQuoteBreak, (info, code) => {
+ unprefixedQuoteBlocks.push({ info, code });
+ return 'BLOCK';
+ }), '> BLOCK\n> second\n> ```\nAfter');
+ assert.deepEqual(unprefixedQuoteBlocks, [{ info: 'text', code: 'first\n' }]);
+
const wideQuotedListBlank = '10. > ```text\n > hello\n >\n > again\n > ```';
const wideQuotedListBlocks = [];
assert.equal(helpers.replaceMarkdownCodeFences(wideQuotedListBlank, (info, code) => {