chore init
This commit is contained in:
1 parent
1b7406b1d3
commit
a0d312a884
60 files changed
+5046
-125
No files matched your search
@@ -0,0 +1,10 @@
|
||||
import { marked } from "marked";
|
||||
import DOMPurify from "dompurify";
|
||||
|
||||
marked.setOptions({ gfm: true, breaks: true });
|
||||
|
||||
export function markdownToHtml(source: string): string {
|
||||
const rawHtml = marked.parse(source, { async: false }) as string;
|
||||
if (typeof window === "undefined") return rawHtml;
|
||||
return DOMPurify.sanitize(rawHtml, { USE_PROFILES: { html: true } });
|
||||
}
|
||||
Reference in new issue
Block a user