fix(utils): preserved deeper lazy continuations

This commit is contained in:
can1357
2026-08-16 01:52:57 +02:00
parent 6d82e578f3
commit 36465c4e1a
2 changed files with 9 additions and 2 deletions
+2 -2
View File
@@ -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;
+7
View File
@@ -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)}`, () => {