diff --git a/src/render/markdown.ts b/src/render/markdown.ts index 55cf103..c0f25fd 100644 --- a/src/render/markdown.ts +++ b/src/render/markdown.ts @@ -53,9 +53,13 @@ export async function renderMarkdown( ); }, paragraph: (children) => - Bun.wrapAnsi(`${children}\n\n`, columns - 2, { trim: false }), + Bun.wrapAnsi(`${children}\n\n`, columns, { trim: false }), blockquote: (children) => { - const lines = Bun.wrapAnsi(children, columns).split("\n"); + const lines = Bun.wrapAnsi(`\n${children.trim()}`, columns - 2, { + trim: false, + }) + .concat("\n") + .split("\n"); const toRender = lines .map((line) => `${chalk.dim("> ")}${line}`) .join("\n") @@ -78,8 +82,10 @@ export async function renderMarkdown( return `\`\`\`${chalk.blue(meta?.language ?? "")}\n${toRender}\`\`\`\n`; }, - list: (children, { depth }) => - `${depth > 0 ? "\n" : ""}${children.trimEnd()}${depth === 0 ? "\n\n" : ""}`, + list: (children, { depth }) => { + const trimmed = children.trimEnd(); + return depth === 0 ? `${trimmed}\n\n` : `\n${trimmed}`; + }, listItem: (children, { index, depth, ordered, start, checked }) => { const indent = " ".repeat(depth); let marker = ""; @@ -91,6 +97,7 @@ export async function renderMarkdown( } else { marker = "•"; } + return Bun.wrapAnsi(`${indent} ${marker} ${children}\n`, columns, { trim: false, }); @@ -101,7 +108,7 @@ export async function renderMarkdown( .header(header) .body(body) .border() - .maxColWidth(Math.floor(columns / header.length) - 2) + .maxColWidth(Math.floor(columns / header.length) - 3) .toString(); header = []; body = [];