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 type { ComponentProps } from "svelte"; import { compile } from "svelte/compiler"; import { describe, expect, expectTypeOf, it } from "vite-plus/test"; import { createSSRApp, h } from "vue"; import { renderToString as renderVue } from "vue/server-renderer"; import tabs from "../src/index.ts"; import { createIcons, type IconCollection } from "comark-icon"; import { components as htmlComponents } from "../src/html.ts"; import { components as reactComponents } from "../src/react.ts"; import { components as vueComponents } from "../src/vue.ts"; import type { Tabs as SvelteTabs } from "../src/svelte/index.js"; 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, the HTML renderer's inline // styles and script, and the ids, which each framework makes its own way. It drops the mark a component's root carries // too, which lets its styles lay out the server render before the script starts. const normalize = (html: string) => html .replace(/ data-comark-mounts(="")?/g, "") .replace(/]*>.*?<\/style>|