Commit aa653316 authored by lukas.burgey's avatar lukas.burgey

--wip--

parent 9539ef46
......@@ -2,7 +2,7 @@ import { Component, OnInit, Inject } from '@angular/core';
import { MAT_DIALOG_DATA } from '@angular/material/dialog';
import { DomSanitizer, SafeHtml } from '@angular/platform-browser';
import marked, { Renderer } from 'marked';
import marked from 'marked';
import { Observable, BehaviorSubject } from 'rxjs';
import DOMPurify from 'dompurify';
......@@ -16,7 +16,6 @@ import { Answers, DeploymentState } from '../../types/types.module';
})
export class QuestionnaireComponent implements OnInit {
md: any;
public answers$ = <BehaviorSubject<Answers>> new BehaviorSubject(undefined);
constructor(
......@@ -24,12 +23,6 @@ export class QuestionnaireComponent implements OnInit {
public userService: UserService,
@Inject(MAT_DIALOG_DATA) public state$: Observable<DeploymentState>,
) {
// https://ndportmann.com/client-side-markdown-to-html/
const renderer = new Renderer();
this.md = marked.setOptions({
renderer: renderer,
breaks: true
});
state$.subscribe(
(state: DeploymentState) => {
......@@ -59,8 +52,9 @@ export class QuestionnaireComponent implements OnInit {
ngOnInit() {
}
// https://ndportmann.com/client-side-markdown-to-html/
markdownToSafeHtml(value: string): SafeHtml {
const html = this.md(value);
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