精华
做了一个 html 转 markdown 的工具 h2m
在线试用: http://island205.github.io/h2m/
安装
$npm install h2m
使用
var h2m = require('h2m')
var md = h2m('<h1>Hello World</h1>')
// md = '# Hello World'
支持
h2m
现在支持 Markdown 标准 : CommonMark。
20 回复

@i5ting v0.5.0 已经更新,现在如果图片没有 alt 或者 title,就让 [] 为空,不在取 src 值了。也可以自定义转换了:
h2m('<a href="http://island205.github.io/h2m/">h2m</a>', {
overides: {
a: function(node) {
/**
node is an object as the a tag:
{
name: "a",
attrs: {
href: 'http://island205.github.io/h2m/'
},
md: 'h2m'
}
*/
return `[This is an link element](${node.attrs.href})`
}
}
}
// output [This is an link element](http://island205.github.io/h2m/)