fix: improve markdown list rendering and show messages for unsupported
This commit is contained in:
parent
c051f340a8
commit
decfd2bde0
1 changed files with 5 additions and 5 deletions
|
|
@ -83,8 +83,8 @@ export async function renderMarkdown(
|
|||
return `\`\`\`${chalk.blue(meta?.language ?? "")}\n${toRender}\`\`\`\n`;
|
||||
},
|
||||
list: (children, { depth }) => {
|
||||
const trimmed = children.trimEnd();
|
||||
return depth === 0 ? `${trimmed}\n\n` : `\n${trimmed}`;
|
||||
const trimmed = children.replaceAll("\n\n", "\n");
|
||||
return depth === 0 ? `${trimmed}\n` : `\n${trimmed}`;
|
||||
},
|
||||
listItem: (children, { index, depth, ordered, start, checked }) => {
|
||||
let marker = "";
|
||||
|
|
@ -100,7 +100,7 @@ export async function renderMarkdown(
|
|||
const cols = columns - (depth + 1) * 2;
|
||||
return Bun.wrapAnsi(`${marker} ${children}`, cols, { trim: false })
|
||||
.split("\n")
|
||||
.map((line) => ` ${line}`)
|
||||
.map((line) => (line.length > 0 ? ` ${line}` : ""))
|
||||
.join("\n")
|
||||
.concat("\n");
|
||||
},
|
||||
|
|
@ -131,9 +131,9 @@ export async function renderMarkdown(
|
|||
codespan: (children) => chalk.bgBlack.yellowBright(children),
|
||||
link: (children, { href }) =>
|
||||
chalk.blueBright.underline(terminalLink(children, href)),
|
||||
image: () => "",
|
||||
image: () => chalk.red("Images are unsupported (for now)\n"),
|
||||
text: (children) => children,
|
||||
html: () => "",
|
||||
html: () => chalk.red("HTML is unsupported\n"),
|
||||
});
|
||||
|
||||
return rendered.replace(/\n\n$/, "\n");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue