Last active
November 24, 2021 16:27
-
-
Save yehuthi/d0a4f0f39c4a4124fb3973b2916c3bd1 to your computer and use it in GitHub Desktop.
[Svelte] Markdown Action
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { marked } from 'marked'; | |
import dompurify from 'dompurify'; | |
export default function ( | |
element: HTMLElement, | |
markdown: string | |
): { update: (markdown: string) => void } { | |
function update(markdown: string) { | |
element.innerHTML = dompurify.sanitize(marked(markdown)); | |
} | |
update(markdown); | |
return { update }; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment