import { parseBlocks } from "./block.js"; import { render } from "./render.js"; import { readFileSync } from "fs"; import type { ParseOptions } from "./types.js"; export function convert(source: string, opts: ParseOptions = {}): string { const result = parseBlocks(source, opts); return render(result); } // CLI: node index.ts [file] [--markdown-compat] if (process.argv[1]?.endsWith("index.ts") || process.argv[1]?.endsWith("index.js")) { const args = process.argv.slice(2); const markdownCompat = args.includes("--markdown-compat"); const file = args.find((a: string) => !a.startsWith("--")); const source = file ? readFileSync(file, "utf8") : readFileSync("/dev/stdin", "utf8"); console.log(convert(source, { markdownCompat })); }