Skip to content

pawel-up/html.md

Repository files navigation

HTML.md

No-dependency, ESM based, in browser HTML to markdown converter.

A library that takes an HTML string or a reference to an Element and translates it to a Markdown code.

Note, this library works in a browser environment only. This won't work in Node.js.

Published on NPM

Tests and publishing

Usage

Installation

npm install --save @pawel-up/html.md

Basic example

import HtmlMd from '@pawel-up/html.md';

const parser = new HtmlMd();
const markdown = parser.generate(`<p>This is a <code>markdown</code> output</p>`);
// This is a `markdown` output\n\n

Processing HTML element

import HtmlMd from '@pawel-up/html.md';

const parser = new HtmlMd();
const markdown = parser.generate(document.body);

Note, when passing an element, the most outer element is ignored and treated as a container. The generated markdown only contains child nodes.

Development

git clone https://github.com/jarrodek/html.md
cd html.md
npm install

Running the demo locally

npm start

Running the tests

npm test

License

HTML.md by Pawel Uchida-Psztyc is licensed under CC BY 4.0