Socket
Socket
Sign inDemoInstall

node-markdown

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-markdown

Parse Markdown syntax with node.js


Version published
Weekly downloads
2.5K
decreased by-10%
Maintainers
1
Weekly downloads
 
Created
Source

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

FAQs

Package last updated on 22 Jul 2012

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc