import assert from "node:assert/strict"; import test from "node:test"; import { renderMarkdown } from "./markdown.ts"; test("renders inline and display LaTeX as native MathML", async () => { const html = await renderMarkdown(String.raw`Inline $x^2$. $$ g(s) = \frac{1}{Z}p(s)\Phi(s) $$`); assert.equal((html.match(/x\^2<\/annotation>/); assert.doesNotMatch(html, /\$\$/); }); test("does not interpret ordinary currency as inline math", async () => { const html = await renderMarkdown("Costs range from $5 to $10."); assert.equal(html.trim(), "

Costs range from $5 to $10.

"); assert.doesNotMatch(html, / { const html = await renderMarkdown(`A statement[^note]. [^note]: Supporting detail.`); assert.match(html, //); assert.match(html, /
  • /); assert.match(html, /Supporting detail\./); }); test("safe Markdown mode escapes arbitrary HTML, SVG, and scripts", async () => { const html = await renderMarkdown( `\n\n\n\n
    text
    `, { allowRawHtml: false }, ); assert.doesNotMatch(html, /<(?:script|svg|circle|div)\b/i); assert.match(html, /<script>alert\("x"\)<\/script>/); assert.match(html, /<svg onload="alert\(1\)">/); assert.match(html, /<div data-owned="false">text<\/div>/); }); test("safe Markdown mode keeps HTML examples inert inside code fences", async () => { const html = await renderMarkdown( "```html\n\n```", { allowRawHtml: false }, ); assert.doesNotMatch(html, /