@calle/ng2-markdown-viewer

Angular 2 Markdown viewer

Usage no npm install needed!

<script type="module">
  import calleNg2MarkdownViewer from 'https://cdn.skypack.dev/@calle/ng2-markdown-viewer';
</script>

README

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>