import { describe, expect, test } from "vitest"; import { processBlocksSync, processTokensSync } from "./marked"; function renderHtml(md: string): string { const tokens = processTokensSync(md, []); const textToken = tokens.find((token) => token.type === "text"); if (!textToken || textToken.type !== "text") return ""; return typeof textToken.html === "string" ? textToken.html : ""; } // Full pipeline render (block splitting + optional streaming repairs), as used by MarkdownRenderer function renderBlocksHtml(md: string, streaming: boolean): string { return processBlocksSync(md, [], streaming) .flatMap((block) => block.tokens) .map((token) => (token.type === "text" && typeof token.html === "string" ? token.html : "")) .join(""); } describe("marked basic rendering", () => { test("renders bold text", () => { const html = renderHtml("**bold**"); expect(html).toContain("bold"); }); test("renders links", () => { const html = renderHtml("[link](https://example.com)"); expect(html).toContain('"); }); test("renders paragraphs", () => { const html = renderHtml("hello world"); expect(html).toContain("

hello world

"); }); }); describe("marked image renderer", () => { test("renders video extensions as