ayco.io-astro/commands/md-to-html.ts

14 lines
368 B
TypeScript

import rehypeStringify from 'rehype-stringify'
import remarkParse from 'remark-parse'
import remarkRehype from 'remark-rehype'
import { unified } from 'unified'
export async function mdToHTML(md: string): Promise<string> {
const file = await unified()
.use(remarkParse)
.use(remarkRehype)
.use(rehypeStringify)
.process(md)
return String(file)
}