html2txt converts HTML to markdown.
Import the module.
from html2txt import convertersCall the Html2Markdown converter on HTML text to convert it to markdown.
markdown = converters.Html2Markdown().convert(html)> cd html2txt/converters
> python3 -B html2markdown.py --path path-to-html-directory> cd html2txt
> python3 -m venv venv
> source ./venv/bin/activateThe 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 .> pytest -vv