All Projects → dimpu → Ngx Md

dimpu / Ngx Md

Angular(ngx) directive for parsing markdown content in your web application.

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to Ngx Md

ngx-echarts
Apache ECharts component for Angular(基于 Angular 的 Apache ECharts 组件)
Stars: ✭ 82 (-68.22%)
Mutual labels:  ng2, ng
ng2-go-top-button
A simple customizable go-top-button component for Angular projects.
Stars: ✭ 18 (-93.02%)
Mutual labels:  ng2, ng
angular2-signature-pad
Signature pad component for Angular 2.x and above.
Stars: ✭ 17 (-93.41%)
Mutual labels:  ng2, ng
ng2-fontawesome
An easy-to-use directive for font awesome icons.
Stars: ✭ 20 (-92.25%)
Mutual labels:  ng2
ngx-echarts-starter
A starter demo project for ngx-echarts
Stars: ✭ 29 (-88.76%)
Mutual labels:  ng
ng-elm
Write Angular components in Elm.
Stars: ✭ 41 (-84.11%)
Mutual labels:  ng2
Zonote
Cross-platform desktop note-taking app. Sticky notes with Markdown and Tabs. All in one .txt file.
Stars: ✭ 255 (-1.16%)
Mutual labels:  markdown
ic-datepicker
Angular (2+) datepicker component
Stars: ✭ 27 (-89.53%)
Mutual labels:  ng2
ng2-fused
FuseBox plugins and utilities for building Angular2 applications.
Stars: ✭ 13 (-94.96%)
Mutual labels:  ng2
ng2-STOMP-Over-WebSocket
STOMP Over WebSocket service for angular2
Stars: ✭ 35 (-86.43%)
Mutual labels:  ng2
microframeworks-showcase
A simple grocery list webapplication implemented with the Microframeworks Spark Java, Jodd, Ninja, Javalite, Pippo and Ratpack
Stars: ✭ 29 (-88.76%)
Mutual labels:  ng
ng-leaflet
Angular 2 component for Leaflet 1.x (WIP - Help Wanted)
Stars: ✭ 16 (-93.8%)
Mutual labels:  ng2
ng2-dialog-window
Modal/dialog windows and popups module for Angular applications.
Stars: ✭ 17 (-93.41%)
Mutual labels:  ng2
ng-monaco-editor
Angular wrapper for monaco-editor.
Stars: ✭ 22 (-91.47%)
Mutual labels:  ng
ng2-storage
A local and session storage wrapper for angular 2.
Stars: ✭ 14 (-94.57%)
Mutual labels:  ng2
angular2-cookie-law
Angular2+ component that provides a banner to inform users about cookie law
Stars: ✭ 38 (-85.27%)
Mutual labels:  ng2
ngx-ui-switch
Angular UI Switch component
Stars: ✭ 109 (-57.75%)
Mutual labels:  ng
awesome-angular
💖 A list of awesome Angular (2️⃣➕) resources
Stars: ✭ 61 (-76.36%)
Mutual labels:  ng2
ng-seed
Simple Angular seed project with commonly used features.
Stars: ✭ 12 (-95.35%)
Mutual labels:  ng2
Tipi
Thinking In PHP Internals, An open book on PHP Internals
Stars: ✭ 2,760 (+969.77%)
Mutual labels:  markdown

Angular Markdown (NgxMd)

Build Status Build Status npm version npm npm npm FOSSA Status

Supports Angular2,4,5,6,7

Source @ https://github.com/dimpu/ngx-md

Table of contents

  1. Getting Started
  2. Installation instructions
  3. Usage & Demo
  4. Contributing
  5. License

Getting Started

ngx-md contains NgxMdModule for Angular.

Additionally we use marked.js and prismjs for this component.

Installation instructions

Install ngx-md from npm:

npm install ngx-md --save

or using yarn:

yarn add ngx-md

How to use it with:

Usage & Demo

Main source of API documentation and usage scenarios is available at https://dimpu.github.io/ngx-md/.

Contribution

Is very welcome! And remember, contribution is not only PRs and code, but any help with docs or helping other developers to solve issues are very appreciated! Thanks in advance!

Quick Guide

app.module.ts

This library has dependency on HttpClientModule. It should be always provided in your application.

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

import { NgxMdModule } from 'ngx-md';
import { HttpClientModule } from '@angular/common'
import { AppComponent } from '../src/app.component';

@NgModule({
  imports: [
    BrowserModule,
    HttpClientModule,
    NgxMdModule.forRoot(),
  ],
  declarations: [AppComponent],
  bootstrap: [AppComponent],
})

index.html

If you want syntax highlighting you need to import the prism css file.

Alternative 1: Import from cdn

<head>
    <meta charset="utf-8">
    <base href="/">

    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="icon" type="image/x-icon" href="favicon.ico">
    <link href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.6.0/themes/prism.min.css" rel="stylesheet" />
  </head>

Alternative 2: Download the css file (or copy it from node_modules/prismjs/themes/, place it somewhere in your src folder and import

<link href="/css/prism.min.css" rel="stylesheet" />

Alternative 3: Include the prism css file in your sass style file

@import 'prismjs/themes/prism.css';

To support sytnax helight for other langugage you need to include

// import 'prismjs/prism';
import 'prismjs/components/prism-c';
import 'prismjs/components/prism-cpp';
import 'prismjs/components/prism-csharp';
import 'prismjs/components/prism-css';
import 'prismjs/components/prism-diff';
import 'prismjs/components/prism-java';
import 'prismjs/components/prism-javascript';
import 'prismjs/components/prism-perl';
...
...
...

app.component.html

<div Markdown>
    ### your markdown code
</div>

<!-- or use angular component -->

<ngx-md>
    ### your markdown code
</ngx-md>

<!-- to load from remote URL -->

<div NgxMd [path]="'/path/to/readme.md'" (error)="errorHandler($event)" (loaded)="loadedHandler($event)"></div>

<!-- load remote source code with auto syntax highlighting -->

<ngx-md [path]="'/path/to/code.cpp'"></ngx-md>

<ngx-md [path]="'/path/to/code.java'"></ngx-md>

<!-- load remote source code from url stored in variable
(see additional details about variable binding in the next section) -->

<ngx-md [path]="urlVariable"></ngx-md>

<ngx-md [path]="urlVariable" (loaded)="onLoad($event)" (error)="onError($event)"></ngx-md>

Variable binding

Now, with >1.4.x you can bind a variable to the markdown component. To do so:

@Component({
    selector: 'app-root',
    template: `
    <textarea [(ngModel)]="textData"></textarea>
    <ngx-md [data]="textData"></ngx-md>
    `,
})
export class MyComp {
  public textData = `## Markdown content data`;
}

Marked customization

Marked can be customized/extended by accessing the renderer from the MarkdownService:

import { NgxMdService } from 'ngx-md';
@Component({
    selector='my-comp',
    template: `
    <ngx-md>
     > Block
     > quote
     > here
    </ngx-md>
    `,
})
export class MyComp {
  constructor(private _markdown: NgxMdService) {}

  ngOnInit() {
    this._markdown.renderer.blockquote = (quote: string) => {
      return `<blockquote class="king-quote">${quote}</blockquote>`;
    }
  }

See marked documentation for all renderer extension points.

Example

You can find a working example inside the demo directory.

To serve it locally, run:

git clone https://github.com/dimpu/ngx-md.git

npm i

npm run demo.serve

Todo

  • [x] Variable binding
  • [x] Code refactor
  • [x] Write more unit tests
  • [x] Angular 5,6,7 support
  • [ ] Angular schemantics support
  • [ ] Module configuration for markdown settings
  • [ ] Module configuration for prismjs settings

FOSSA Status

Contributors

The following is a list of all the people that have helped build this project. Thanks for your contributions!

glenngr glenngr paullryan

License

FOSSA Status

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].