fix(utils): detached deeper code after padded blanks

This commit is contained in:
can1357
2026-08-16 01:54:05 +02:00
parent 36465c4e1a
commit ffd838b256
2 changed files with 9 additions and 2 deletions
+2 -2
View File
@@ -1080,8 +1080,8 @@ function blockTokens(src: string, lexer: Lexer, output: Token[]): Token[] {
let prevBlankish = false; let prevBlankish = false;
while (i < lines.length) { while (i < lines.length) {
const next = lines[i]!; const next = lines[i]!;
const lazyIndent = !prevBlankish && next.trim() !== "" && /^ {4}/.test(next); const indented = next.trim() !== "" && /^ {4}/.test(next);
if (!lazyIndent && isBlockStart(lines, i)) break; if (indented ? prevBlankish : isBlockStart(lines, i)) break;
prevBlankish = next.trim() === ""; prevBlankish = next.trim() === "";
raw += next; raw += next;
i++; i++;
+7
View File
@@ -112,6 +112,13 @@ describe("marked compatibility", () => {
["hr", "---\n"], ["hr", "---\n"],
], ],
], ],
[
"lead\n \n deeper code\n",
[
["paragraph", "lead\n \n"],
["code", " deeper code\n"],
],
],
]; ];
for (const [source, shape] of lazyBoundaryShapes) { for (const [source, shape] of lazyBoundaryShapes) {
test(`keeps the lazy-continuation boundary shape for ${JSON.stringify(source)}`, () => { test(`keeps the lazy-continuation boundary shape for ${JSON.stringify(source)}`, () => {