fix(ci): Found one low-severity formatting bug in the new loose-list parag (#74518)

Co-authored-by: openclaw-clawsweeper[bot] <280122609+openclaw-clawsweeper[bot]@users.noreply.github.com>
This commit is contained in:
clawsweeper[bot]
2026-04-29 14:07:55 -07:00
committed by GitHub
parent 0e46240543
commit 296d07c22f
2 changed files with 24 additions and 3 deletions

View File

@@ -331,6 +331,21 @@ second paragraph
2. next`);
});
it("preserves paragraph breaks inside loose blockquoted list items", () => {
const input = `> - first paragraph
>
> second paragraph
> - next`;
const result = markdownToIR(input);
expect(result.text).toBe(`• first paragraph
second paragraph
• next`);
});
it("does not add triple newlines before loose nested bullet lists", () => {
const input = `- parent

View File

@@ -5,6 +5,7 @@ import type { MarkdownTableMode } from "../config/types.base.js";
type ListState = {
type: "bullet" | "ordered";
index: number;
openLevel: number;
};
type LinkState = {
@@ -269,7 +270,8 @@ function appendParagraphSeparator(state: RenderState, token?: MarkdownToken) {
return;
} // Don't add paragraph separators inside tables
if (state.env.listStack.length > 0) {
const directListParagraphLevel = state.env.listStack.length * 2;
const currentList = state.env.listStack[state.env.listStack.length - 1];
const directListParagraphLevel = (currentList?.openLevel ?? 0) + 2;
if (
token?.type !== "paragraph_close" ||
token.hidden ||
@@ -685,7 +687,7 @@ function renderTokens(tokens: MarkdownToken[], state: RenderState): void {
if (state.env.listStack.length > 0) {
appendNestedListSeparator(state);
}
state.env.listStack.push({ type: "bullet", index: 0 });
state.env.listStack.push({ type: "bullet", index: 0, openLevel: token.level ?? 0 });
break;
case "bullet_list_close":
state.env.listStack.pop();
@@ -699,7 +701,11 @@ function renderTokens(tokens: MarkdownToken[], state: RenderState): void {
appendNestedListSeparator(state);
}
const start = Number(getAttr(token, "start") ?? "1");
state.env.listStack.push({ type: "ordered", index: start - 1 });
state.env.listStack.push({
type: "ordered",
index: start - 1,
openLevel: token.level ?? 0,
});
break;
}
case "ordered_list_close":