Conservatively convert html to markdown
Project description
Experimental: I have only tested this with the Python markdown module, and under relatively limited circumstances.
Purpose: Converts html to markdown while preserving unsupported html markup. The goal is to generate markdown that can be converted back into html. This is the major difference between html2markdown and html2text. The latter doesn’t purport to necessarily be reversible.
Usage example
import html2markdown print html2markdown.convert('<h2>Test</h2><pre><code>Here is some code</code></pre>')
Output:
## Test Here is some code
Information and caveats
Attributes not supported by Markdown are kept
Example: <a href="http://myaddress" title="click me"><strong>link</strong></a>
Result: [__link__](http://myaddress "click me")
Example: <a onclick="javascript:dostuff()" href="http://myaddress" title="click me"><strong>link</strong></a>
Result: <a onclick="javascript:dostuff()" href="http://myaddress" title="click me">__link__</a> (the attribute onclick is not supported, so the tag is left alone)
Limitations
Currently, only underlines (_) and asterisks (*) are escaped.
Tables are kept as html.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.