node-markdown

Parse Markdown syntax with node.js

highlight is deprecated in favor of "highliht.js"
Last updated 12 years ago by andris .
BSD · Repository · Original npm · Tarball · package.json
$ npm install node-markdown 
SYNC missed versions from official npm registry.

node-markdown

node-markdown is based on Showdown parser and is meant to parse Markdown syntax into HTML code.

Installation

Use npm package manager

npm install node-markdown

Usage

Include Markdown parser

var md = require("node-markdown").Markdown;

Parse Markdown syntax into HTML

var html = md("**markdown** string");

Allow only default set of HTML tags to be used

var html = md("**markdown** string", true);

Allow only specified HTML tags to be used (default set of allowed attributes is used)

var html = md("**markdown** string", true, "p|strong|span");

Allow specified HTML tags and specified attributes

var html = md("**markdown** string", true, "p|strong|span", {
    "a":"href",        // 'href' for links
    "*":"title|style"  // 'title' and 'style' for all
});

Complete example

var md_text = "**bold** *italic* [link](http://www.neti.ee) `code block`",
    md_parser = require("node-markdown").Markdown;

// simple
console.log(md_parser(md_text));

// limit HTML tags and attributes
console.log(md_parser(md_text, true, 'h1|p|span'));

// limit HTML tags and keep attributes for allowed tags
var allowedTags = 'a|img';
    allowedAttributes = {
        'a':'href|style',
        'img': 'src',
        '*': 'title'
    }
console.log(md_parser(md_text, true, allowedTags, allowedAttributes));

Current Tags

  • 0.1.1                                ...           latest (12 years ago)

2 Versions

  • 0.1.1 [deprecated]           ...           12 years ago
  • 0.1.0 [deprecated]           ...           12 years ago
Maintainers (1)
Downloads
Total 0
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
None
Dev Dependencies (0)
None
Dependents (0)
None

© 2010 - cnpmjs.org x YWFE | Home | YWFE