Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/netgusto/upndown
HTML to Markdown javascript converter
https://github.com/netgusto/upndown
html javascript markdown-converter nodejs
Last synced: 3 days ago
JSON representation
HTML to Markdown javascript converter
- Host: GitHub
- URL: https://github.com/netgusto/upndown
- Owner: netgusto
- License: mit
- Created: 2014-03-27T16:23:37.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2024-01-02T17:09:29.000Z (12 months ago)
- Last Synced: 2024-12-21T05:07:06.426Z (10 days ago)
- Topics: html, javascript, markdown-converter, nodejs
- Language: JavaScript
- Homepage:
- Size: 759 KB
- Stars: 276
- Watchers: 4
- Forks: 32
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# upndown
Javascript HTML to Markdown converter, for Node.js and the browser.
[![](https://travis-ci.org/netgusto/upndown.svg?branch=master)](https://travis-ci.org/netgusto/upndown)
## About
**upndown** converts HTML documents to Markdown documents.
**upndown** is designed to offer a fast, reliable and whitespace perfect conversion for HTML documents.
## Install / Usage
### Browser
**Standard loading**
Download the zip archive on github, unzip, copy in your web folder, and in your HTML:
```html
var und = new upndown();
und.convert('<h1>Hello, World !</h1>', function(err, markdown) {
if(err) { console.err(err); }
else { console.log(markdown); } // Outputs: # Hello, World !
});```
**Using RequireJS**
Download the zip archive on github, unzip, copy in your web folder, and in your HTML:
```html
require.config({
paths: {
'upndown': '/assets/upndown/lib/upndown.bundle.min'
}
});require(['upndown'], function(upndown) {
var und = new upndown();
und.convert('<h1>Hello, World !</h1>', function(err, markdown) {
if(err) { console.err(err);
else { console.log(markdown); } // Outputs: # Hello, World !
});
});```
### Nodejs
**Install**
```bash
npm install upndown
```**Use**
```js
var upndown = require('upndown');var und = new upndown();
und.convert('Hello, World !
', function(err, markdown) {
if(err) { console.err(err);
else { console.log(markdown); } // Outputs: # Hello, World !
});
```
**Warning: With Node < 0.12.8, you'll have to require a polyfill for the `Promise` functionnality (like https://www.npmjs.com/package/bluebird); see #10 on how to do that.**## Options
### `decodeEntities`
By default Updown will decode all html entities, so source HTML like this:
```html
I'm an escaped <em>code sample</em>.
```Will become:
```
I'm an escaped *code sample*.
```If your use case does not call for that behavior and you wish HTML entities to
stay encoded, you can pass an option to the constructor:```js
var und = new upndown({decodeEntities: false})
```Then just use as normal.
## Test
### In the browser
Navigate to `test/browser/` inside the **upndown** folder. Browser tests are executed by QUnit.
### Nodejs
To run the tests, simply execute:
```sh
npm test
```Nodejs tests are executed using mocha.
## Maintainer
**upndown** is produced by [Net Gusto](http://netgusto.com). Drop us a line at