h2m
![logo](https://github.com/island205/h2m/raw/HEAD/./design/logo@0.5.png)
![Coverage Status](https://coveralls.io/repos/island205/h2m/badge.svg?branch=master)
Tool for converting HTML to Markdown, like html2markdown.
online converter: http://island205.github.io/h2m/
![online converter](https://github.com/island205/h2m/raw/HEAD/./images/online-converter.png)
Install
$npm install h2m
How to use
h2m(html[, options])
example
var h2m = require('h2m')
var md = h2m('<h1>Hello World</h1>')
options
converter
: the converter you can choose. now support CommonMark
(default) and MarkdownExtra
overides
: custom converter behavior:
h2m('<a href="http://island205.github.io/h2m/">h2m</a>', {
overides: {
a: function(node) {
return `[This is an link element](${node.attrs.href})`
}
}
}
Command Line Tool
install
$ npm install h2m -g
![h2m downloads](https://nodei.co/npm-dl/h2m.png?months=1)
usage
$h2m -h
Options:
-V, --version output the version number
-f, --file <file> HTML file path or an url adress (default: )
-c, --clipboard read HTML from clipboard
-h, --help output usage information
Convert a local file:
$ h2m -f index.html
converting HTML to Markdown
made by [@island205](https://github.com/island205)
Can't be convert? welcome to submit an [issue](https://github.com/island205/h2m/issues/new).
Convert an online url:
$ h2m -f https://baidu.com
Convert from clipboard:
$ h2m -c
Save result:
$ h2m -f https://google.com > google.md
Support
h2m
supports standard Markdown sytax: CommonMark now and 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: 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 (tks @天凉's PR')
Contribution
PRs are welcome to implement other extend Markdown language, like Markdown Extra, GFM and so on.