fix(markdown): correct list item whitespace and indentation

This commit is contained in:
mitchell 2026-06-19 14:54:03 -04:00
parent 5b138df664
commit e1033398e9
3 changed files with 6 additions and 4 deletions

View file

@ -7,7 +7,7 @@
"ttsc": "dist/tts.js" "ttsc": "dist/tts.js"
}, },
"scripts": { "scripts": {
"dev": "pnpm run bundle src/index.ts &>/dev/null && node dist/index.js", "dev": "pnpm run bundle src/index.ts >/dev/null && node dist/index.js",
"check": "biome check --write && pnpm run tc", "check": "biome check --write && pnpm run tc",
"clean": "rm -rf dist", "clean": "rm -rf dist",
"build": "pnpm run check && pnpm run bundle --minify src/index.ts && pnpm run bundle --minify src/tts.ts", "build": "pnpm run check && pnpm run bundle --minify src/index.ts && pnpm run bundle --minify src/tts.ts",

View file

@ -51,7 +51,7 @@ export default class Renderer {
this.charsSinceNL = this.charsSinceNL - columns; this.charsSinceNL = this.charsSinceNL - columns;
} }
if (this.lineCount >= Math.max(rows - 10, 1)) { if (this.lineCount >= Math.max(rows - 4, 1)) {
this.moveClearReset(-this.lineCount, pipe); this.moveClearReset(-this.lineCount, pipe);
} }
} }

View file

@ -76,11 +76,12 @@ class LmcRenderer extends Renderer {
this.listitem(item, ordered ? num + index : undefined), this.listitem(item, ordered ? num + index : undefined),
) )
.join("\n"); .join("\n");
return `\n${renderedItems}\n`; return `\n${renderedItems}\n`;
} }
override listitem({ tokens }: Tokens.ListItem, num?: number) { override listitem({ tokens }: Tokens.ListItem, num?: number) {
const text = this.parser.parse(tokens).trim(); const text = this.parser.parse(tokens);
let marker = ""; let marker = "";
if (num !== undefined) { if (num !== undefined) {
marker = `${num}.`; marker = `${num}.`;
@ -91,7 +92,8 @@ class LmcRenderer extends Renderer {
const item = `${marker} ${text}`; const item = `${marker} ${text}`;
return item return item
.split("\n") .split("\n")
.map((line) => (line.length > 0 ? ` ${line}` : "")) .filter((line) => line.length > 0)
.map((line) => ` ${line}`)
.join("\n"); .join("\n");
} }