All checks were successful
deploy to server / build-and-deploy (push) Successful in 3m37s
21 lines
411 B
TypeScript
21 lines
411 B
TypeScript
import MarkdownIt from 'markdown-it';
|
|
|
|
const md = new MarkdownIt({
|
|
html: true,
|
|
linkify: true,
|
|
typographer: true,
|
|
breaks: true,
|
|
});
|
|
|
|
export function renderMarkdown(content: string): string {
|
|
const dirtyHtml = md.render(content);
|
|
|
|
if (typeof window !== 'undefined') {
|
|
import('dompurify').then((DOMPurify) => {
|
|
return DOMPurify.default.sanitize(dirtyHtml);
|
|
});
|
|
}
|
|
|
|
return dirtyHtml;
|
|
}
|