//#region: Markdown parsing utils import rehypeFormat from "rehype-format"; 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 parseMarkdown(textToParseIntoMarkdown: string): Promise { const markdownProcessor = unified() .use(remarkParse) .use(remarkGfm) .use(remarkRehype, { allowDangerousHtml: true }) .use(rehypeFormat) .use(rehypeStringify); const processedMarkdownValue = (await markdownProcessor.process(textToParseIntoMarkdown)); return processedMarkdownValue; }; //#endregion