Skip to content

calleboketoft/ng2-markdown-viewer

Repository files navigation

ng2-markdown

Based on info in this link:

http://stackoverflow.com/questions/34784778/equivalent-of-compile-in-angular-2

Runtime compilation of markdown to Angular 2 HTML template

  • npm install --save-dev @calle/ng2-markdown-viewer commonmark highlight.js
  • If you're using webpack you also need to use json-loader since commonmark loads JSON files
  • typings install dt~commonmark dt~highlightjs --global --save
  • Add the MarkdownViewerModule to your app:
import { MarkdownViewerModule } from '@calle/ng2-markdown-viewer'
  • The component is currently rendered only on ngAfterViewInit so you need to have the markdownText available before instantiating.
  • Put the markdown-viewer component in your template:
<markdown-viewer
  *ngIf="markdownText"
  [markdown]="markdownText"
  [styles]="[markdownStyles]">
</markdown-viewer>

About

Angular 2: Compile Angular 2 HTML template from Markdown

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published