From c23f1576dca2ea79b8f1368b1d1def661cc517cc Mon Sep 17 00:00:00 2001 From: Mario Zechner Date: Thu, 13 Nov 2025 21:43:18 +0100 Subject: [PATCH] Fix markdown component nested list rendering. --- packages/tui/src/components/markdown.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/tui/src/components/markdown.ts b/packages/tui/src/components/markdown.ts index 685f760c..5795a469 100644 --- a/packages/tui/src/components/markdown.ts +++ b/packages/tui/src/components/markdown.ts @@ -459,9 +459,10 @@ export class Markdown implements Component { const itemLines = this.renderListItem(item.tokens || [], depth); if (itemLines.length > 0) { - // First line - check if it's a nested list (contains cyan ANSI code for bullets) + // First line - check if it's a nested list + // A nested list will start with indent (spaces) followed by cyan bullet const firstLine = itemLines[0]; - const isNestedList = firstLine.includes("\x1b[36m"); // cyan color code + const isNestedList = /^\s+\x1b\[36m[-\d]/.test(firstLine); // starts with spaces + cyan + bullet char if (isNestedList) { // This is a nested list, just add it as-is (already has full indent) @@ -474,7 +475,7 @@ export class Markdown implements Component { // Rest of the lines for (let j = 1; j < itemLines.length; j++) { const line = itemLines[j]; - const isNestedListLine = line.includes("\x1b[36m"); // cyan bullet color + const isNestedListLine = /^\s+\x1b\[36m[-\d]/.test(line); // starts with spaces + cyan + bullet char if (isNestedListLine) { // Nested list line - already has full indent