import { unified } from 'unified'; import remarkParse from 'remark-parse'; import remarkRehype from 'remark-rehype'; import rehypeStringify from 'rehype-stringify'; let processor: any; function getProcessor() { if (!processor) { processor = unified() .use(remarkParse) .use(remarkRehype, { allowDangerousHtml: true }) .use(rehypeStringify, { allowDangerousHtml: true }); } return processor; } export async function renderMarkdown(md: string): Promise { const result = await getProcessor().process(md); return String(result); }