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
Handle empty ordered markers and thematic lines
Emre Sokullu7e7425310f50
diff --git a/src/chrome/src/ui/markdown-render.js b/src/chrome/src/ui/markdown-render.jsindex 4eed36b40..f5d77e050 100644--- a/src/chrome/src/ui/markdown-render.js+++ b/src/chrome/src/ui/markdown-render.js@@ -347,8 +347,8 @@ function listContinuationContainer(source, position, prefix, indentation, noListconst 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);+ && (/^[ \t]*\d{1,9}[.)][ \t]*$/.test(line)+ || (/^[ \t]*\d{1,9}[.)][ \t]/.test(line) && !/^[ \t]*1[.)][ \t]/.test(line)));if (precedingContainer.listPrefix && !nonInterruptingOrderedMarker) {let container = missingQuotes? fenceContainer(`${precedingContainer.containerPrefix}${'> '.repeat(missingQuotes)}`)@@ -378,8 +378,10 @@ function listContinuationContainer(source, position, prefix, indentation, noList// A fenced continuation may be up to three columns deeper than ordinary// list content, so continue back to the enclosing list marker first.if (lineIndent < 2) {+ const thematicBreak = /^(?:(?:-[ \t]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})$/.test(content);const lazyParagraph = !quotePrefix && !lineIndent && !current.quoteDepth- && !/^(?:#{1,6}(?:\s|$)|(?:[-+*]|1[.)])\s+|>|`{3,}|~{3,}|(?:[-*_]\s*){3,})/.test(content);+ && !thematicBreak+ && !/^(?:#{1,6}(?:\s|$)|(?:[-+*]|1[.)])[ \t]+\S|>|`{3,}|~{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 4eed36b40..f5d77e050 100644--- a/src/firefox/src/ui/markdown-render.js+++ b/src/firefox/src/ui/markdown-render.js@@ -347,8 +347,8 @@ function listContinuationContainer(source, position, prefix, indentation, noListconst 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);+ && (/^[ \t]*\d{1,9}[.)][ \t]*$/.test(line)+ || (/^[ \t]*\d{1,9}[.)][ \t]/.test(line) && !/^[ \t]*1[.)][ \t]/.test(line)));if (precedingContainer.listPrefix && !nonInterruptingOrderedMarker) {let container = missingQuotes? fenceContainer(`${precedingContainer.containerPrefix}${'> '.repeat(missingQuotes)}`)@@ -378,8 +378,10 @@ function listContinuationContainer(source, position, prefix, indentation, noList// A fenced continuation may be up to three columns deeper than ordinary// list content, so continue back to the enclosing list marker first.if (lineIndent < 2) {+ const thematicBreak = /^(?:(?:-[ \t]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})$/.test(content);const lazyParagraph = !quotePrefix && !lineIndent && !current.quoteDepth- && !/^(?:#{1,6}(?:\s|$)|(?:[-+*]|1[.)])\s+|>|`{3,}|~{3,}|(?:[-*_]\s*){3,})/.test(content);+ && !thematicBreak+ && !/^(?:#{1,6}(?:\s|$)|(?:[-+*]|1[.)])[ \t]+\S|>|`{3,}|~{3,})/.test(content);if (lazyParagraph) {if (!lineStart) break;lineEnd = lineStart - 1;diff --git a/test/markdown-render.mjs b/test/markdown-render.mjsindex 523193977..e36bcd794 100644--- a/test/markdown-render.mjs+++ b/test/markdown-render.mjs@@ -445,6 +445,16 @@ for (const build of ['chrome', 'firefox']) {}), '- item\n2. continuation\n BLOCK\nOutside');assert.deepEqual(lazyOrderedParagraphBlocks, [{ info: 'text', code: 'hi\n' }]);+ for (const continuation of ['2.', '2. ', '1.', '1. ', '---text', '-_*']) {+ const source = `- item\n${continuation}\n \`\`\`text\n hi\nOutside`;+ const blocks = [];+ assert.equal(helpers.replaceMarkdownCodeFences(source, (info, code) => {+ blocks.push({ info, code });+ return 'BLOCK';+ }), `- item\n${continuation}\n BLOCK\nOutside`);+ assert.deepEqual(blocks, [{ info: 'text', code: 'hi\n' }]);+ }+const noCloser = '> ```text\n> inside\nOutside';const noCloserBlocks = [];assert.equal(helpers.replaceMarkdownCodeFences(noCloser, (info, code) => {