# HTML2Markdown
本项目是基于 https://github.com/island205/h2m 升级版,增加了table的解析,以及更正了pre标签
## 安装
```bash
npm install h2m
注意:将本git下的converters文件夹覆盖node_modules/h2m 的converters文件夹
```
## 如何使用
**h2m(html[, options])**
### 例子
```javascript
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:
```javascript
h2m('<a href="http://www.baidu.com">h2m</a>', {
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](http://www.baidu.com)
```
## Support
`h2m` supports standard Markdown sytax: [CommonMark](http://commonmark.org/help/) now and [Markdown Extra](https://michelf.ca/projects/php-markdown/extra/).
### CommonMark
- :white_check_mark: br
- :white_check_mark: em
- :white_check_mark: strong
- :white_check_mark: code
- :white_check_mark: a
- :white_check_mark: img
- :white_check_mark: hr
- :white_check_mark: ul, ol
- :white_check_mark: pre
- :white_check_mark: div
- :white_check_mark: p
- :white_check_mark: blockquote
- :white_check_mark: h1 ~ h6
- :white_check_mark: iframe
### Markdown Extra
- :white_check_mark: Special Attributes for headers link and image
- :white_check_mark: Fenced Code Blocks
- :white_check_mark: dl, dt, dd Definition Lists
- :white_check_mark: abbr Abbreviations
- :white_check_mark: table