Skip to content

Instantly share code, notes, and snippets.

@P1xt
Last active March 13, 2017 18:10
Show Gist options
  • Save P1xt/bf705f1dd90200f383000539ab674a01 to your computer and use it in GitHub Desktop.
Save P1xt/bf705f1dd90200f383000539ab674a01 to your computer and use it in GitHub Desktop.
Angular 2 pipe to use the marked npm package to convert markdown
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