Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Converts Markdown to styled HTML with WeChat-compatible themes, code highlighting, math, PlantUML, and footnotes.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
scripts/main.test.ts
1import assert from "node:assert/strict";2import { execFile } from "node:child_process";3import fs from "node:fs/promises";4import os from "node:os";5import path from "node:path";6import process from "node:process";7import test from "node:test";8import { fileURLToPath } from "node:url";9import { promisify } from "node:util";1011const execFileAsync = promisify(execFile);12const SCRIPT_DIR = path.dirname(fileURLToPath(import.meta.url));13const SCRIPT_PATH = path.join(SCRIPT_DIR, "main.ts");1415async function makeTempDir(prefix: string): Promise<string> {16return fs.mkdtemp(path.join(os.tmpdir(), prefix));17}1819test("CLI forwards wrapper title and package render options", async () => {20const root = await makeTempDir("baoyu-markdown-to-html-cli-");21const markdownPath = path.join(root, "article.md");22await fs.writeFile(markdownPath, "## Section\n\nParagraph with **bold** text.\n", "utf-8");2324const { stdout } = await execFileAsync(25process.execPath,26[27"--import",28"tsx",29SCRIPT_PATH,30markdownPath,31"--theme", "grace",32"--color", "red",33"--font-family", "mono",34"--font-size", "18",35"--keep-title",36"--title", "Overridden",37],38{ cwd: SCRIPT_DIR },39);4041const result = JSON.parse(stdout.trim()) as {42htmlPath: string;43title: string;44};4546assert.equal(result.title, "Overridden");4748const html = await fs.readFile(result.htmlPath, "utf-8");49assert.match(html, /<title>Overridden<\/title>/);50assert.match(html, /<h2[^>]*style="[^"]*background: #A93226/);51assert.match(html, /<strong[^>]*style="[^"]*color: #A93226/);52assert.match(53html,54/<body[^>]*style="[^"]*font-family: Menlo, Monaco, 'Courier New', monospace;[^"]*font-size: 18px/,55);56});57