• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

andris9/node-markdown: Parse Markdown syntax with Node.JS

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

andris9/node-markdown

开源软件地址(OpenSource Url):

https://github.com/andris9/node-markdown

开源编程语言(OpenSource Language):

JavaScript 100.0%

开源软件介绍(OpenSource Introduction):

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



鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap