Commit 710913fd authored by lukas.burgey's avatar lukas.burgey

--wip--

parent aa653316
......@@ -54,6 +54,12 @@ export class QuestionnaireComponent implements OnInit {
// https://ndportmann.com/client-side-markdown-to-html/
markdownToSafeHtml(value: string): SafeHtml {
// https://github.com/markedjs/marked/issues/51#issuecomment-9607945
const src = value.replace(/\r\n|\r/g, '\n')
.replace(/\t/g, ' ')
.replace(/^[\w\<][^\n]*\n+/mg, (m) => {
return /\n{2}/.test(m) ? m : m.replace(/\s+$/, '') + ' \n';
});
const html = marked(value, { breaks: true});
const safeHtml = DOMPurify.sanitize(html);
return this.sanitizer.bypassSecurityTrustHtml(safeHtml);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment