You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

26 lines
652 B

import { Pipe, PipeTransform } from '@angular/core';
import { DomSanitizer, SafeHtml } from '@angular/platform-browser';
import { marked } from 'marked';
import { configureMarkedRenderer } from '../services/markdown-config';
configureMarkedRenderer();
@Pipe({
name: 'gfMarkdown',
pure: true,
standalone: true
})
export class GfMarkdownPipe implements PipeTransform {
public constructor(private sanitizer: DomSanitizer) {}
public transform(value: string): SafeHtml {
if (!value) {
return '';
}
const html = marked.parse(value, { async: false }) as string;
return this.sanitizer.bypassSecurityTrustHtml(html);
}
}