Files
ds-pages/app/utils/remark.ts
2025-08-08 17:14:09 +08:00

18 lines
518 B
TypeScript

import rehypeStarryNight from "rehype-starry-night";
import rehypeStringify from "rehype-stringify";
import remarkGfm from "remark-gfm";
import remarkParse from "remark-parse";
import remarkRehype from "remark-rehype";
import { unified } from "unified";
export async function markdownToHtml(markdown: string) {
const result = await unified()
.use(remarkParse)
.use(remarkRehype)
.use(remarkGfm)
.use(rehypeStarryNight)
.use(rehypeStringify)
.process(markdown);
return result.toString();
}