Last active
March 13, 2017 18:10
-
-
Save P1xt/bf705f1dd90200f383000539ab674a01 to your computer and use it in GitHub Desktop.
Angular 2 pipe to use the marked npm package to convert markdown
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Pipe, PipeTransform } from '@angular/core'; | |
var marked = require('marked'); | |
@Pipe({ | |
name: 'mark' | |
}) | |
export class MarkPipe implements PipeTransform { | |
transform(value: any, args?: any): any { | |
marked.setOptions({ sanitize: true}); | |
return marked(value); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment