style: markdown render improvements
This commit is contained in:
parent
d822ba2141
commit
430e99a972
3 changed files with 12 additions and 7 deletions
|
|
@ -34,7 +34,7 @@ export async function renderMarkdown(
|
|||
|
||||
let currentTable = new CliTable3();
|
||||
|
||||
return Bun.markdown.render(md, {
|
||||
const rendered = Bun.markdown.render(md, {
|
||||
heading: (children, { level }) => {
|
||||
const colors = [
|
||||
chalk.cyan.underline,
|
||||
|
|
@ -69,7 +69,7 @@ export async function renderMarkdown(
|
|||
} catch {}
|
||||
}
|
||||
|
||||
return `\`\`\`${chalk.blue(meta?.language)}\n${toRender}\n\`\`\`\n`;
|
||||
return `\`\`\`${chalk.blue(meta?.language ?? "")}\n${toRender}\`\`\`\n`;
|
||||
},
|
||||
list: (children, { depth }) =>
|
||||
`${depth > 0 ? "\n" : ""}${children.trimEnd()}${depth === 0 ? "\n\n" : ""}`,
|
||||
|
|
@ -77,14 +77,14 @@ export async function renderMarkdown(
|
|||
const indent = " ".repeat(depth);
|
||||
let marker = "";
|
||||
if (checked !== undefined) {
|
||||
marker = checked ? "[x]" : "[ ]";
|
||||
marker = checked ? "[✓]" : "[ ]";
|
||||
} else if (ordered) {
|
||||
const n = (start ?? 1) + index;
|
||||
marker = `${n}.`;
|
||||
} else {
|
||||
marker = "-";
|
||||
marker = "•";
|
||||
}
|
||||
return `${indent}${marker} ${children}\n`;
|
||||
return `${indent} ${marker} ${children}\n`;
|
||||
},
|
||||
hr: () => `${chalk.dim("─".repeat(columns))}\n\n`,
|
||||
table: (_children) => {
|
||||
|
|
@ -111,4 +111,6 @@ export async function renderMarkdown(
|
|||
text: (children) => children,
|
||||
html: () => "",
|
||||
});
|
||||
|
||||
return rendered.replace(/\n\n$/, "\n");
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue