fix: indent wrapped list items and remove codespan padding

This commit is contained in:
mitchell 2026-05-04 16:45:27 -04:00
parent 22fc4c874f
commit c051f340a8

View file

@ -87,7 +87,6 @@ export async function renderMarkdown(
return depth === 0 ? `${trimmed}\n\n` : `\n${trimmed}`;
},
listItem: (children, { index, depth, ordered, start, checked }) => {
const indent = " ".repeat(depth);
let marker = "";
if (checked !== undefined) {
marker = checked ? "• [✓]" : "• [ ]";
@ -98,9 +97,12 @@ export async function renderMarkdown(
marker = "•";
}
return Bun.wrapAnsi(`${indent} ${marker} ${children}\n`, columns, {
trim: false,
});
const cols = columns - (depth + 1) * 2;
return Bun.wrapAnsi(`${marker} ${children}`, cols, { trim: false })
.split("\n")
.map((line) => ` ${line}`)
.join("\n")
.concat("\n");
},
hr: () => `${chalk.dim("─".repeat(columns))}\n\n`,
table: (_children) => {
@ -126,7 +128,7 @@ export async function renderMarkdown(
strong: (children) => chalk.bold(children),
emphasis: (children) => chalk.italic(children),
strikethrough: (children) => chalk.grey.strikethrough(children),
codespan: (children) => chalk.bgBlack.yellowBright(` ${children} `),
codespan: (children) => chalk.bgBlack.yellowBright(children),
link: (children, { href }) =>
chalk.blueBright.underline(terminalLink(children, href)),
image: () => "",