1.0.0-alpha.5 • Published 7 years ago

@nvxme/ngx-md-render v1.0.0-alpha.5

Weekly downloads
5
License
MIT
Repository
github
Last release
7 years ago

ngx-md-render

Angular 2+ module for converting Markdown to HTML with Highlight.js for code snippets.

demo

Install

npm install @nvxme/ngx-md-render --save

Import module

...
import { MdRenderModule } from '@nvxme/ngx-md-render';

@NgModule({
  imports: [
    ...
    MdRenderModule,
  ],
  ...
})

Use the service

...
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);

Output in template

<div [innerHtml]="rendered"></div>

Code styling

Import style in .angular-cli.json:

{
...
  "styles": [
    "styles.css",
    "../node_modules/highlight.js/styles/dracula.css"
  ],