0.1.1 • Published 9 years ago

html2md v0.1.1

Weekly downloads
10
License
-
Repository
github
Last release
9 years ago

HTML2MD: A JavaScript HTML-to-Markdown converter

HTML2MD attempts to convert HTML into Markdown by reducing an HTML document into simple, Markdown-compatible parts. This library is compatible with both browsers and Node.js.

HTML2MD does its best job to convert any HTML given to it and it is by no means perfect. Heavily formatted documents, for example, will likely fail to convert properly. A few assumptions are made about the HTML which outline it's limitations:

* Inline elements do not contain block elements.
* Standard HTML block elements are used to define and separate content.

Install

Download the latest version from our release page and use via a script tag. The variable html2md will be attached to window.

<script type="text/javascript" src="html2md.js"></script>

If using Browserify or Node.js, you can install via NPM and use via require("html2md").

$ npm install html2md

Basic Usage

Using HTML2MD is really easy; it's just a function!

var markdown = html2md("<h1>Hello World</h1>");
console.log(markdown); // -> # Hello World

Please see the documentation for specifics.

Building from Scratch

HTML2MD uses Grunt to build a Browserify bundle from the original source found in lib/. When the command below completes, the compiled source will be saved to dist/ directory.

npm install && grunt

If you don't the Grunt cli tools installed globally, run npm install -g grunt-cli before running that command.

Running the Unit Tests

HTML2MD has several unit tests written for Node.js and the browser. Before running tests, install all test dependencies:

npm install

To get tests running on Node.js, run:

npm test

To run tests in the browser, start a test server with this command. When the server is running, navigate your browser to http://localhost:8000.

npm run dev