Ready to take your JavaScript development to the next level? Meet npm Enterprise - the ultimate in enterprise JavaScript. Learn more »

@molecule/markdown

1.0.1 • Public • Published

Molecule Markdown

CircleCI Codecov npm (scoped)

Molecule Markdown provides you an Angular directive '# Title'|md and a corresponding service, MarkdownService, which allows you to provide any markdown parser you wish. On the other hand, you need to provide a subclass for it in order to MarkdownPipe.

Example

@NgModule({
  import: [MarkdownModule],
  declarations: [MyComponent],
  providers: [{
    provide: MarkdownService,
    useClass: YourMarkdownService
  }]
})
export class MyModule {}
 
@Component({
  template: '{{myMarkdownText|md}}'
})
export class MyComponent {
  @Input() public myMarkdownText: string;
}

Using Marked

@Injectable()
export class MarkdedService extends MarkdownService {
  constructor() {
    marked.setOptions({ /* configuration options */ });
  }
  public markdownToHtml(markdown: string, ...args: any[]): string {
    return marked(markdown, options);
  }
}

Using Markdown It

@Injectable()
export class MarkdownItService extends MarkdownService {
  private readonly markdownIt: MarkdownIt;
  constructor() {
    this.markdownIt = new MarkdownIt();
  }
  public markdownToHtml(markdown: string, ...args: any[]): string {
    return this.markdownIt.render(markdown);
  }
}

Installation

$ npm install --save @molecule/markdown

Author

Valentin Knabel, @vknabel, dev@vknabel.com

License

@molecule/markdown is available under the MIT license.

install

npm i @molecule/markdown

Downloadsweekly downloads

0

version

1.0.1

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability