• Stars
    star
    275
  • Rank 149,796 (Top 3 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 10 years ago
  • Updated over 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

HTML to Markdown javascript converter

upndown

Javascript HTML to Markdown converter, for Node.js and the browser.

Live demo here.

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:

<script type="text/javascript" src="/assets/upndown/lib/upndown.bundle.min.js"></script>
<script type="text/javascript">

    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 !
    });

</script>

Using RequireJS

Download the zip archive on github, unzip, copy in your web folder, and in your HTML:

<script type="text/javascript" src="http://requirejs.org/docs/release/2.1.11/minified/require.js"></script>
<script type="text/javascript">

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 !
    });
});
</script>

Nodejs

Install

npm install upndown

Use

var upndown = require('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 !
});

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:

<p>I'm an escaped &lt;em&gt;code sample&lt;/em&gt;.</p>

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:

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:

npm test

Nodejs tests are executed using mocha.

Maintainer

upndown is produced by Net Gusto. Drop us a line at [email protected]

More Repositories

1

nodebook

Nodebook - Multi-Lang Web REPL + CLI Code runner
Go
1,627
star
2

IdiomaticReact

Idiomatic React - Flux - REST app
JavaScript
327
star
3

bowser

⭐ Bowser - Dynamic Default Browser Switch for MacOS
Go
44
star
4

ember-cli-cal

Calendar component for ember-cli
JavaScript
43
star
5

Geiger

Tiny (<100 SLOC), no-dependencies Flux implementation with store synchronization (waitFor) and Dependency Injection features.
JavaScript
37
star
6

Pulpy

Juicy full featured web calendar
JavaScript
14
star
7

tax

CLI Task List Manager
Rust
14
star
8

Symfony-DynamicSubdomainBundle

Symfony2 Dynamic subdomain handler Bundle
PHP
13
star
9

ecs-typescript

Port of bytearena/ecs from Golang to TypeScript
TypeScript
11
star
10

imagejam.net

JavaScript
10
star
11

hackervid.io

Hacker video source code
PHP
7
star
12

ember-cli-cal-demoapp

Demo app for ember-cli-cal
JavaScript
5
star
13

realtime-reactive

Realtime reactive experimental data synchronization between a server and multiple clients
TypeScript
4
star
14

Symfony-AdminLTEBundle

PHP
3
star
15

docker-rust

Rust in a container
3
star
16

Symfony-BaseProject

A pre-configured project template using Symfony2, Less, Bootstrap3, FontAwesome, jQuery, Modernizr, CoffeeScript and RequireJS
PHP
2
star
17

PP-Theme-Dropplets

Dropplets theme for PP
CSS
2
star
18

baikal.codr.fr

The source code for http://baikal-server.com
PHP
2
star
19

BaikalModelBundle

PHP
2
star
20

co

PHP implementation of tj/co
PHP
2
star
21

Symfony-BootcampBundle

Symfony bundle boilerplate for easy PAAS integration.
PHP
2
star
22

scope

JS Oscilloscope for webaudio
TypeScript
1
star
23

void

Simplest webpack setup for dev + dist
JavaScript
1
star
24

car-model-prototype

Car model prototype repo (temporary)
Go
1
star
25

compose.js

JavaScript
1
star
26

PP-Theme-Medium

A Medium-Like theme for PP
CSS
1
star
27

BretzelDefense

JavaScript
1
star
28

BaikalDavServicesBundle

PHP
1
star
29

minifig

Lego minifig builder
CSS
1
star
30

phreak

PHP to ES6 abomination
PHP
1
star
31

youtube-graphql

JavaScript
1
star
32

palettes

Some palettes I ❀️.
1
star
33

audioviz

Hacking together a webgl audio viz
JavaScript
1
star
34

docker-compose-symfony3

docker-compose Symfony 3 + php7 fpm + mysql + nginx
PHP
1
star
35

webpack-frontend-startpack

Start pack for webpack frontend projects, based on Webpack with Babel and controlled by Gulp
JavaScript
1
star
36

ecs

C++ Entity Component System
C++
1
star
37

BaikalCore

1
star
38

rust-bmfont

Bitmap font parser for rustlang
Rust
1
star
39

taptapclap

Remote Clapping Apparatus
TypeScript
1
star
40

n-behaviour

Finite State Machine / Behaviour management for nodejs and the browser
JavaScript
1
star
41

Symfony-AutorouteBundle

Autoroute bundle for Symfony
PHP
1
star
42

PPSilex

Deliciously simple Markdown blog system, based on Silex.
PHP
1
star
43

airline

Land every request to it's destination. Works great with koa.
JavaScript
1
star