mirror of
https://github.com/earendil-works/pi.git
synced 2026-06-18 15:54:04 +08:00
fix(tui): separate list items with blank lines in loose lists
This commit is contained in:
@@ -572,6 +572,7 @@ export class Markdown implements Component {
|
||||
|
||||
for (let i = 0; i < token.items.length; i++) {
|
||||
const item = token.items[i];
|
||||
const isLastItem = i === token.items.length - 1;
|
||||
const bullet = token.ordered
|
||||
? this.options.preserveOrderedListMarkers
|
||||
? (this.getOrderedListMarker(item) ?? `${startNumber + i}. `)
|
||||
@@ -604,6 +605,10 @@ export class Markdown implements Component {
|
||||
if (!renderedAnyLine) {
|
||||
lines.push(firstPrefix);
|
||||
}
|
||||
|
||||
if (token.loose && !isLastItem) {
|
||||
lines.push("");
|
||||
}
|
||||
}
|
||||
|
||||
return lines;
|
||||
|
||||
@@ -149,6 +149,37 @@ describe("Markdown component", () => {
|
||||
assert.ok(plainLines.some((line) => line.includes("2. Second ordered")));
|
||||
});
|
||||
|
||||
it("should render blank lines between loose list items", () => {
|
||||
const markdown = new Markdown(
|
||||
`1. Lorem ipsum dolor sit amet.
|
||||
|
||||
Ut enim ad minim veniam.
|
||||
|
||||
2. Duis aute irure dolor.
|
||||
|
||||
Excepteur sint occaecat cupidatat.
|
||||
|
||||
3. Beep boop`,
|
||||
0,
|
||||
0,
|
||||
defaultMarkdownTheme,
|
||||
);
|
||||
|
||||
const lines = markdown.render(80).map((line) => stripAnsi(line).trimEnd());
|
||||
|
||||
assert.deepStrictEqual(lines, [
|
||||
"1. Lorem ipsum dolor sit amet.",
|
||||
"",
|
||||
" Ut enim ad minim veniam.",
|
||||
"",
|
||||
"2. Duis aute irure dolor.",
|
||||
"",
|
||||
" Excepteur sint occaecat cupidatat.",
|
||||
"",
|
||||
"3. Beep boop",
|
||||
]);
|
||||
});
|
||||
|
||||
it("should render task list markers", () => {
|
||||
const markdown = new Markdown("- [ ] beep\n- [x] boop", 0, 0, defaultMarkdownTheme);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user