@ekiras/markdown-it
To install this library, configure and run:
Last updated 2 years ago by ekiras .
MIT · Repository · Original npm · Tarball · package.json
$ cnpm install @ekiras/markdown-it 
SYNC missed versions from official npm registry.

ekiras-markdown-it

Installation

To install this library, configure and run:

  1. Install Plugin
$ npm install @ekiras/markdown-it --save
  1. Install Dependencies Install Dependencies for this dependency
npm install highlightjs markdown-it markdown-it-block-embed markdown-it-block-image markdown-it-container markdown-it-highlightjs --save
  1. Configure scripts and css Open .angular-cli.json and add the following

In scripts : [] add the following

        "../node_modules/highlightjs/highlight.pack.js",
        "assets/js/markdown-bundle.js",
        "assets/js/markdownit.js"

In styles: [] add the following

        "./assets/css/highlighter.css",
        "./assets/css/markdown.css",
        "../node_modules/bootstrap/dist/css/bootstrap.min.css"

Consuming Markdown library

You can configure the library by including the module in the main module as shown in the example below.

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';

import { AppComponent } from './app.component';

// Import Ekiras Markdown Module
import { EkirasMarkdownItModule } from '@ekiras/markdown-it';

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,

    // Import Markdown Module and enable everything
    EkirasMarkdownItModule.forRoot({
      html: true,
      linkify: true,
      breaks: true,
      typographer: true,
      containers: [
        // define your containers here.
        {
          name: 'note',
          showHeading: true,
          class: 'note'
        },
        {
          name: 'warning'
        }
      ]
    }),    
    // Import Markdown Module with default configurations
    EkirasMarkdownItModule.forRoot({})

  ],
  providers: [],
  bootstrap: []
});
export class AppModule { }

Adding Custom Containers Markdown Containers You can add any number of markdown containers as you want by just adding them to the containers array[]

Once the Module is imported, you can use the MarkdownItService to convert the markdown to html.

import { Component, OnInit } from '@angular/core';

import { MarkdownItService } from '@ekiras/markdown-it';

@Component({
  selector: 'app-sample-selector',
  template: '<textarea cols="75" rows="15" [(ngModel)]="md" (keyup)="convertToHtml();"></textarea>'
})

export class SampleComponent implements OnInit {
  
  md: string = null;

  constructor(private markdownItService: MarkdownItService) { }

  ngOnInit() { }

  
  convertToHtml(): string {
    return this.markdownItService.render(this.md);
  }
}

License

MIT © Ekansh Rastogi

Current Tags

  • 3.0.0                                ...           latest (2 years ago)

2 Versions

  • 3.0.0                                ...           2 years ago
  • 2.0.0                                ...           3 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dev Dependencies (0)
None
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |