Open-source AI browser agent for Chrome and Firefox (monorepo) ðŸ§
JavaScript ai-agentai-agentsai-toolsbrowser-aibrowser-automationbrowser-extensionchrome-aichrome-devtoolschrome-extensionchrome-extensionsfirefox-addonfirefox-addonsfirefox-extensionfirefox-extensionsgemmagemma4minimaxoffline-aioffline-llmqwen
Respect lazy ordered Markdown continuations
Emre Sokullubaa234d8b8e5
diff --git a/src/chrome/src/ui/markdown-render.js b/src/chrome/src/ui/markdown-render.jsindex e35d991ee..4eed36b40 100644--- a/src/chrome/src/ui/markdown-render.js+++ b/src/chrome/src/ui/markdown-render.js@@ -344,7 +344,12 @@ function listContinuationContainer(source, position, prefix, indentation, noListconst missingQuotes = current.quoteDepth - precedingContainer.quoteDepth;if (missingQuotes < 0 || (missingQuotes && !current.leadingQuoteIndent)) return noList();- if (precedingContainer.listPrefix) {+ const followsNonblankLine = lineStart > 0+ && Boolean(source.slice(source.lastIndexOf('\n', lineStart - 2) + 1, lineStart - 1).trim());+ const nonInterruptingOrderedMarker = followsNonblankLine && !current.quoteDepth+ && /^[ \t]*\d{1,9}[.)][ \t]/.test(line)+ && !/^[ \t]*1[.)][ \t]/.test(line);+ if (precedingContainer.listPrefix && !nonInterruptingOrderedMarker) {let container = missingQuotes? fenceContainer(`${precedingContainer.containerPrefix}${'> '.repeat(missingQuotes)}`): precedingContainer;@@ -374,7 +379,7 @@ function listContinuationContainer(source, position, prefix, indentation, noList// list content, so continue back to the enclosing list marker first.if (lineIndent < 2) {const lazyParagraph = !quotePrefix && !lineIndent && !current.quoteDepth- && !/^(?:#{1,6}(?:\s|$)|(?:[-+*]|\d+[.)])\s+|>|`{3,}|~{3,}|(?:[-*_]\s*){3,})/.test(content);+ && !/^(?:#{1,6}(?:\s|$)|(?:[-+*]|1[.)])\s+|>|`{3,}|~{3,}|(?:[-*_]\s*){3,})/.test(content);if (lazyParagraph) {if (!lineStart) break;lineEnd = lineStart - 1;diff --git a/src/firefox/src/ui/markdown-render.js b/src/firefox/src/ui/markdown-render.jsindex e35d991ee..4eed36b40 100644--- a/src/firefox/src/ui/markdown-render.js+++ b/src/firefox/src/ui/markdown-render.js@@ -344,7 +344,12 @@ function listContinuationContainer(source, position, prefix, indentation, noListconst missingQuotes = current.quoteDepth - precedingContainer.quoteDepth;if (missingQuotes < 0 || (missingQuotes && !current.leadingQuoteIndent)) return noList();- if (precedingContainer.listPrefix) {+ const followsNonblankLine = lineStart > 0+ && Boolean(source.slice(source.lastIndexOf('\n', lineStart - 2) + 1, lineStart - 1).trim());+ const nonInterruptingOrderedMarker = followsNonblankLine && !current.quoteDepth+ && /^[ \t]*\d{1,9}[.)][ \t]/.test(line)+ && !/^[ \t]*1[.)][ \t]/.test(line);+ if (precedingContainer.listPrefix && !nonInterruptingOrderedMarker) {let container = missingQuotes? fenceContainer(`${precedingContainer.containerPrefix}${'> '.repeat(missingQuotes)}`): precedingContainer;@@ -374,7 +379,7 @@ function listContinuationContainer(source, position, prefix, indentation, noList// list content, so continue back to the enclosing list marker first.if (lineIndent < 2) {const lazyParagraph = !quotePrefix && !lineIndent && !current.quoteDepth- && !/^(?:#{1,6}(?:\s|$)|(?:[-+*]|\d+[.)])\s+|>|`{3,}|~{3,}|(?:[-*_]\s*){3,})/.test(content);+ && !/^(?:#{1,6}(?:\s|$)|(?:[-+*]|1[.)])\s+|>|`{3,}|~{3,}|(?:[-*_]\s*){3,})/.test(content);if (lazyParagraph) {if (!lineStart) break;lineEnd = lineStart - 1;diff --git a/test/markdown-render.mjs b/test/markdown-render.mjsindex 494bbf30a..523193977 100644--- a/test/markdown-render.mjs+++ b/test/markdown-render.mjs@@ -437,6 +437,14 @@ for (const build of ['chrome', 'firefox']) {}), '- item\n > BLOCK\nAfter');assert.deepEqual(quoteListContinuationBlocks, [{ info: 'text', code: 'hello\n' }]);+ const lazyOrderedParagraph = '- item\n2. continuation\n ```text\n hi\nOutside';+ const lazyOrderedParagraphBlocks = [];+ assert.equal(helpers.replaceMarkdownCodeFences(lazyOrderedParagraph, (info, code) => {+ lazyOrderedParagraphBlocks.push({ info, code });+ return 'BLOCK';+ }), '- item\n2. continuation\n BLOCK\nOutside');+ assert.deepEqual(lazyOrderedParagraphBlocks, [{ info: 'text', code: 'hi\n' }]);+const noCloser = '> ```text\n> inside\nOutside';const noCloserBlocks = [];assert.equal(helpers.replaceMarkdownCodeFences(noCloser, (info, code) => {