Angular 2+ module for converting Markdown to HTML with Highlight.js for code snippets.
npm install @nvxme/ngx-md-render --save
...
import { MdRenderModule } from '@nvxme/ngx-md-render';
@NgModule({
imports: [
...
MdRenderModule,
],
...
})
...
source: string;
rendered: SafeHtml;
...
constructor(private sanitizer: DomSanitizer,
private mdRender: MdRenderService) {
}
...
const html = this.mdRender.render(this.source);
const this.rendered = this.sanitizer.bypassSecurityTrustHtml(html);
<div [innerHtml]="rendered"></div>
Import style in .angular-cli.json
:
{
...
"styles": [
"styles.css",
"../node_modules/highlight.js/styles/dracula.css"
],