fix: indent wrapped list items and remove codespan padding
This commit is contained in:
parent
22fc4c874f
commit
c051f340a8
1 changed files with 7 additions and 5 deletions
|
|
@ -87,7 +87,6 @@ export async function renderMarkdown(
|
||||||
return depth === 0 ? `${trimmed}\n\n` : `\n${trimmed}`;
|
return depth === 0 ? `${trimmed}\n\n` : `\n${trimmed}`;
|
||||||
},
|
},
|
||||||
listItem: (children, { index, depth, ordered, start, checked }) => {
|
listItem: (children, { index, depth, ordered, start, checked }) => {
|
||||||
const indent = " ".repeat(depth);
|
|
||||||
let marker = "";
|
let marker = "";
|
||||||
if (checked !== undefined) {
|
if (checked !== undefined) {
|
||||||
marker = checked ? "• [✓]" : "• [ ]";
|
marker = checked ? "• [✓]" : "• [ ]";
|
||||||
|
|
@ -98,9 +97,12 @@ export async function renderMarkdown(
|
||||||
marker = "•";
|
marker = "•";
|
||||||
}
|
}
|
||||||
|
|
||||||
return Bun.wrapAnsi(`${indent} ${marker} ${children}\n`, columns, {
|
const cols = columns - (depth + 1) * 2;
|
||||||
trim: false,
|
return Bun.wrapAnsi(`${marker} ${children}`, cols, { trim: false })
|
||||||
});
|
.split("\n")
|
||||||
|
.map((line) => ` ${line}`)
|
||||||
|
.join("\n")
|
||||||
|
.concat("\n");
|
||||||
},
|
},
|
||||||
hr: () => `${chalk.dim("─".repeat(columns))}\n\n`,
|
hr: () => `${chalk.dim("─".repeat(columns))}\n\n`,
|
||||||
table: (_children) => {
|
table: (_children) => {
|
||||||
|
|
@ -126,7 +128,7 @@ export async function renderMarkdown(
|
||||||
strong: (children) => chalk.bold(children),
|
strong: (children) => chalk.bold(children),
|
||||||
emphasis: (children) => chalk.italic(children),
|
emphasis: (children) => chalk.italic(children),
|
||||||
strikethrough: (children) => chalk.grey.strikethrough(children),
|
strikethrough: (children) => chalk.grey.strikethrough(children),
|
||||||
codespan: (children) => chalk.bgBlack.yellowBright(` ${children} `),
|
codespan: (children) => chalk.bgBlack.yellowBright(children),
|
||||||
link: (children, { href }) =>
|
link: (children, { href }) =>
|
||||||
chalk.blueBright.underline(terminalLink(children, href)),
|
chalk.blueBright.underline(terminalLink(children, href)),
|
||||||
image: () => "",
|
image: () => "",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue