From 36465c4e1ab042f27ff0aa746be33dd770ca9b75 Mon Sep 17 00:00:00 2001 From: can1357 Date: Sun, 16 Aug 2026 01:52:57 +0200 Subject: [PATCH] fix(utils): preserved deeper lazy continuations --- packages/utils/src/marked/core.ts | 4 ++-- packages/utils/test/marked.test.ts | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/utils/src/marked/core.ts b/packages/utils/src/marked/core.ts index e73b36920..fb4e9fb24 100644 --- a/packages/utils/src/marked/core.ts +++ b/packages/utils/src/marked/core.ts @@ -1072,7 +1072,7 @@ function blockTokens(src: string, lexer: Lexer, output: Token[]): Token[] { let raw = line; i++; // An indented code block cannot interrupt a paragraph (CommonMark lazy - // continuation): a 4-space-indented line directly attached to nonblank + // continuation): a line indented by at least 4 spaces directly attached to // paragraph text stays inside the paragraph, bypassing every block-start // probe — matching marked's paragraph rule. After a whitespace-padded // blank line the indent is no longer attached, so it still opens an @@ -1080,7 +1080,7 @@ function blockTokens(src: string, lexer: Lexer, output: Token[]): Token[] { let prevBlankish = false; while (i < lines.length) { const next = lines[i]!; - const lazyIndent = !prevBlankish && /^ {4}\S/.test(next); + const lazyIndent = !prevBlankish && next.trim() !== "" && /^ {4}/.test(next); if (!lazyIndent && isBlockStart(lines, i)) break; prevBlankish = next.trim() === ""; raw += next; diff --git a/packages/utils/test/marked.test.ts b/packages/utils/test/marked.test.ts index 1448b8044..d7907520f 100644 --- a/packages/utils/test/marked.test.ts +++ b/packages/utils/test/marked.test.ts @@ -105,6 +105,13 @@ describe("marked compatibility", () => { ["hr", "---\n"], ], ], + [ + "lead\n deeper attached\n---\n", + [ + ["paragraph", "lead\n deeper attached\n"], + ["hr", "---\n"], + ], + ], ]; for (const [source, shape] of lazyBoundaryShapes) { test(`keeps the lazy-continuation boundary shape for ${JSON.stringify(source)}`, () => {