const fs = require("fs"); const vm = require("vm"); const s = fs.readFileSync(__dirname + "/../release/app.js", "utf8"); const w = { document: { readyState: "complete", getElementById: () => null, addEventListener: () => {}, documentElement: { setAttribute() {}, style: { setProperty() {} } }, body: {}, }, localStorage: { getItem: () => null, setItem() {} }, scrollTo() {}, }; w.window = w; vm.createContext(w); vm.runInContext(s, w); if (!w.MarkdownLite) { console.error("FAIL no MarkdownLite"); process.exit(1); } const md = [ "# 标题", "", "**粗体** 和 *斜体*", "", "- 列表A", "- 列表B", "", "> 引用一行", "", "```", "code here", "```", "", "正文段落。", ].join("\n"); const html = w.MarkdownLite.markdownToHtml(md, { theme: "dark", dropCap: true }); const checks = { strong: html.indexOf("= 0, list: html.indexOf("md-list") >= 0, quote: html.indexOf("md-quote") >= 0, pre: html.indexOf("md-pre") >= 0, p: html.indexOf("= 0, }; console.log(JSON.stringify(checks, null, 2)); console.log(html.slice(0, 400)); if (!checks.strong || !checks.list || !checks.quote || !checks.pre) { process.exit(1); } console.log("md smoke ok");