18 lines
518 B
TypeScript
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();
|
|
}
|