Need help with node-markdown?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

andris9
193 Stars 18 Forks Other 14 Commits 0 Opened issues

Description

Parse Markdown syntax with Node.JS

Services available

!
?

Need anything else?

Contributors list

# 4,315
JavaScr...
Shell
nodemai...
email-s...
8 commits
# 41,360
HTML
JavaScr...
Shell
2 commits
# 6,970
JavaScr...
Shell
Three.j...
html5
1 commit

DEPRECATION NOTICE!

This project is deprecated in favor of chjj/marked. I never created the parser myself, the module was created in the early days of node as a wrapper for an existing browser based parser Showdown so if you are using this module and have problems with the parsing logic, I can't help you much as I'm not familiar with the inner details.

Pull requests are still welcomed - if you find a bug and fix it, then I'll pull the change in but I won't be fixing the bugs myself. Sorry for that.

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));

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.