From 7367cfdfe365a2a14774d555d78d718fe1c8a6ec Mon Sep 17 00:00:00 2001 From: mitchell Date: Tue, 12 May 2026 16:34:13 -0400 Subject: [PATCH] fix: blockquote and list whitespace handling in markdown rendering --- src/render/markdown.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/render/markdown.ts b/src/render/markdown.ts index beaf244..e1f652e 100644 --- a/src/render/markdown.ts +++ b/src/render/markdown.ts @@ -64,13 +64,14 @@ export async function renderMarkdown( const lines = Bun.wrapAnsi(`\n${children.trim()}`, columns - 2, { trim: false, }) - .replace(/\n(\s?[a-zA-Z_-]+\s?)\n/g, "\n$1") .replace(/\n+/g, "\n") .concat("\n") .split("\n"); const toRender = lines - .map((line) => `${chalk.dim("> ")}${line}`) + .map((line) => `> ${line}`) .join("\n") + .replace(/(\n> +\S+) *\n> */g, "$1 ") + .replaceAll(">", chalk.dim(">")) .concat("\n\n"); return toRender; }, @@ -91,9 +92,7 @@ export async function renderMarkdown( return `\`\`\`${chalk.blue(meta?.language ?? "")}\n${toRender}\`\`\`\n`; }, list: (children, { depth }) => { - const trimmed = children - .replace(/\n+/g, "\n") - .replace(/\n(\s?[a-zA-Z_-]+\s?)\n/g, "\n$1"); + const trimmed = children.replace(/\n+/g, "\n"); return depth === 0 ? `${trimmed}\n` : `\n${trimmed}`; }, listItem: (children, { index, depth, ordered, start, checked }) => { @@ -112,6 +111,7 @@ export async function renderMarkdown( .split("\n") .map((line) => (line.length > 0 ? ` ${line}` : "")) .join("\n") + .replace(/(\n +\S+) *\n */g, "$1 ") .concat("\n"); }, hr: () => `${chalk.dim("─".repeat(columns))}\n\n`,