Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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

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