Markdown 解析和编译器:marked

jopen 12年前

marked 是一个 JavaScript 编写的全功能 Markdown 解析和编译器。

marked 的目的是快速的编译超大块的Markdown文本而不必担心结果会出乎意料或者花费很长时间。

marked 最初是为 Node.JS编写,现在已完全兼容客户端浏览器。

新版本号称速度比C语言写的Markdown转换工具Discount 还要快。

Benchmarks:

node v0.4.x:

$ node test --bench  marked completed in 12071ms.  showdown (reuse converter) completed in 27387ms.  showdown (new converter) completed in 75617ms.  markdown-js completed in 70069ms.

node v0.6.x:

$ node test --bench  marked completed in 6448ms.  marked (gfm) completed in 7357ms.  marked (pedantic) completed in 6092ms.  discount completed in 7314ms.  showdown (reuse converter) completed in 16018ms.  showdown (new converter) completed in 18234ms.  markdown-js completed in 24270ms.
用法:
// Set default options  marked.setOptions({    gfm: true,    pedantic: false,    sanitize: true,    // callback for code highlighter    highlight: function(code, lang) {      if (lang === 'js') {        return javascriptHighlighter(code);      }      return code;    }  });  console.log(marked('i am using __markdown__.'));


项目主页:http://www.open-open.com/lib/view/home/1351498941957