https://github.com/imcuttle/html-markdown
Convert from Html to Markdown isomorphically By Javascript.
https://github.com/imcuttle/html-markdown
Last synced: about 1 year ago
JSON representation
Convert from Html to Markdown isomorphically By Javascript.
- Host: GitHub
- URL: https://github.com/imcuttle/html-markdown
- Owner: imcuttle
- Created: 2017-02-06T19:06:08.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2022-01-07T14:35:01.000Z (over 4 years ago)
- Last Synced: 2025-03-23T02:34:01.656Z (about 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 2.03 MB
- Stars: 6
- Watchers: 1
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# html-markdown
Convert from Html to Markdown isomorphically By Javascript.
Branches: master => jsdom (isomorphic); cheerio => cheerio;
Requirements: [Cheerio](https://github.com/cheeriojs/cheerio) Or [jsDom](https://github.com/tmpvar/jsdom)
Cheerio is Fast HTML parser using like jquery for server.
jsDom is has better performance on browser, don't need import jsdom.
So we can `html-markdown` browser and server(nodejs), that is to say, it's **isomorphic**.
**cheerio version in npm. (Fast)**
- Bash
```bash
npm i -g html-markdown
html2md -h
html2md https://www.npmjs.com/package/html-markdown -s "#readme" > html-markdown-readme.md
# with image
html2md https://www.npmjs.com/package/song-robot -s "#readme" > song-robot-readme.md
html2md https://www.npmjs.com/package/moka-cli -s "#readme" > moka-cli-readme.md
html2md path/to/html/file -s "#markdown"
html2md --eval "
Hello!
"
html2md - # get string from stdin
html2md # get string from stdin, better REPL
{
echo "
HEAD1
";
echo "HEAD2
";
} | html2md -
```
- Package
```
npm i --save html-markdown
```
```javascript
var html2md = require('html-markdown');
var md1 = html2md.html2mdFromString("
Hello!
");
// https or http, not isomorphic
html2md.html2mdFromURL("https://www.npmjs.com/package/song-robot", "#readme").then(console.log);
// not isomorphic
html2md.html2mdFromPath("path/to/html/file", "#markdown").then(console.log);
```