html2markdown <a href="https://git.oschina.net/iThinker/html2markdown#%E4%BE%8B%E5%AD%90_4"></a>例子<a href="https://git.oschina.net/iThinker/html2markdown#%E9%80%89%E9%A1%B9_5"> 介绍
将HTML转化成Markdown的工具,增加了table的解析,以及更正了pre标签,此项目源于当时采集gitbook等类似平台的文章时使用!
安装
npm install h2m 注意:将项目的converters文件夹覆盖node_modules/h2m 的converters文件夹
如何使用
h2m(html[, options])
例子
var h2m = require('h2m') var md = h2m('<h1>Hello World</h1>') // md = '# Hello World'
选项
-
converter: the converter you can choose. now support CommonMark(default) and MarkdownExtra
-
overides: custom converter behavior:
h2m(‘href="http://www.baidu.com">h2m‘, { overides: { a: function(node) { /*
node is an object as the a tag:
{
name: “a”,
attrs: {
href: 'http://www.baidu.com‘
},
md: ‘h2m’
}
/ return [This is an link element](${node.attrs.href}) } } } // output This is an link element
Support
h2m supports standard Markdown sytax:
CommonMark now and Markdown
Extra.
CommonMark
-
br
-
em
-
strong
-
code
-
a
-
img
-
hr
-
ul, ol
-
pre
-
div
-
p
-
blockquote
-
h1 ~ h6
[](https://git.oschina.net/iThinker/html2markdown#markdown-
extra_8)Markdown Extra
-
Special Attributes for headers link and image
-
Fenced Code Blocks
-
dl, dt, dd Definition Lists
-
abbr Abbreviations
-
table
html2markdown <a href="https://git.oschina.net/iThinker/html2markdown#%E4%BE%8B%E5%AD%90_4"></a>例子<a href="https://git.oschina.net/iThinker/html2markdown#%E9%80%89%E9%A1%B9_5"> 官网
https://git.oschina.net/iThinker/html2markdown
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。