import { readFile } from "node:fs/promises"; import { renderHtmlFromDocument } from "@comark/html"; import { MarkdownDocument as ReactDocument } from "@comark/react"; import { MarkdownDocument as VueDocument } from "@comark/vue"; import { type MarkdownDocument, parseMarkdown } from "comark"; import { createElement } from "react"; import { renderToString as renderReact } from "react-dom/server"; import { compile } from "svelte/compiler"; import { describe, expect, it } from "vite-plus/test"; import { createSSRApp, h } from "vue"; import { renderToString as renderVue } from "vue/server-renderer"; import code from "../src/index.ts"; import { components as htmlComponents } from "../src/html.ts"; import { components as reactComponents } from "../src/react.ts"; import { components as vueComponents } from "../src/vue.ts"; const renderers = { html: (value: MarkdownDocument) => renderHtmlFromDocument(value, { components: htmlComponents }), vue: (value: MarkdownDocument) => renderVue(createSSRApp({ render: () => h(VueDocument, { value, components: vueComponents }) })), react: (value: MarkdownDocument) => renderReact(createElement(ReactDocument, { value, components: reactComponents })), }; // Drops what differs only in serialization: comments, whitespace, empty attribute values, and the HTML renderer's // inline styles and script. const normalize = (html: string) => html .replace(/]*>.*?<\/style>|