1 import { Injectable } from '@angular/core'
2 import { LinkifierService } from '@app/shared/renderer/linkifier.service'
3 import * as sanitizeHtml from 'sanitize-html'
6 export class HtmlRendererService {
8 constructor (private linkifier: LinkifierService) {
12 toSafeHtml (text: string) {
13 // Convert possible markdown to html
14 const html = this.linkifier.linkify(text)
16 return sanitizeHtml(html, {
17 allowedTags: [ 'a', 'p', 'span', 'br' ],
18 allowedSchemes: [ 'http', 'https' ],
20 'a': [ 'href', 'class', 'target' ]
23 a: (tagName, attribs) => {
26 attribs: Object.assign(attribs, {
28 rel: 'noopener noreferrer'