From 1662d9006a74301a00a0497f5ae22f945ed5f582 Mon Sep 17 00:00:00 2001 From: xierenhong Date: Fri, 28 Nov 2025 23:31:04 +0800 Subject: [PATCH] feat: add custom list rendering with ordered/unordered support --- src/ui/Markdown.tsx | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/ui/Markdown.tsx b/src/ui/Markdown.tsx index c9abb1689..8129ea6f3 100644 --- a/src/ui/Markdown.tsx +++ b/src/ui/Markdown.tsx @@ -33,6 +33,25 @@ export function Markdown({ children, ...options }: Props) { return chalk.bold.dim(text); } }, + list: (body: string, ordered?: boolean) => { + let content = body.trim(); + // Collapse multiple newlines to single newline to reduce vertical spacing + content = content.replace(/\n\n+/g, '\n'); + if (ordered) { + let count = 0; + content = content + .split('\n') + .map((line) => { + if (line.startsWith('* ')) { + count++; + return line.replace(/^\* /, `${count}. `); + } + return line; + }) + .join('\n'); + } + return content; + }, ...options, }; // @ts-expect-error