Skip to main content

Convert HTML to markdown

Project description

html2txt

html2txt converts HTML to markdown.

Usage

Import the module.

from html2txt import converters

Call the Html2Markdown converter on HTML text to convert it to markdown.

markdown = converters.Html2Markdown().convert(html)

Run converter for unit testing

> cd html2txt/converters
> python3 -B html2markdown.py --path path-to-html-directory

Tests

Create Virtual Environment

> cd html2txt

> python3 -m venv venv

> source ./venv/bin/activate

Making Tests

The Commonmark and Breakdance tests were written for converting markdown to HTML so many tests fail with differences of whitespace and choices of markdown representation.

Breakdance is used by Dillinger, a markdown editor.

> cd html2txt/tests

> python3 -B ./config/mkhtml2txt.py --path .

> python3 -B ./config/mkcommonmark.py --path .

> python3 -B ./config/mkbreakdance.py --path .

> python3 -B ./config/mksvgweb.py --path .

> python3 -B ./config/mkmathml.py --path .

Running Tests

> pytest -vv

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

html2txt-0.6.0.tar.gz (1.1 MB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page