Convert HTML to markdown.
Project description
Installation
pip install markdownify
Usage
Convert some HTML to Markdown:
from markdownify import markdownify as md
md('<b>Yay</b> <a href="http://github.com">GitHub</a>') # > '**Yay** [GitHub](http://github.com)'
Specify tags to exclude (blacklist):
from markdownify import markdownify as md
md('<b>Yay</b> <a href="http://github.com">GitHub</a>', strip=['a']) # > '**Yay** GitHub'
...or specify the tags you want to include (whitelist):
from markdownify import markdownify as md
md('<b>Yay</b> <a href="http://github.com">GitHub</a>', convert=['b']) # > '**Yay** GitHub'
Options
Markdownify supports the following options:
- strip
A list of tags to strip (blacklist). This option can’t be used with the convert option.
- convert
A list of tags to convert (whitelist). This option can’t be used with the strip option.
- autolinks
A boolean indicating whether the “automatic link” style should be used when a a tag’s contents match its href. Defaults to True
- heading_style
Defines how headings should be converted. Accepted values are ATX, ATX_CLOSED, SETEXT, and UNDERLINED (which is an alias for SETEXT). Defaults to UNDERLINED.
- bullets
An iterable (string, list, or tuple) of bullet styles to be used. If the iterable only contains one item, it will be used regardless of how deeply lists are nested. Otherwise, the bullet will alternate based on nesting level. Defaults to '*+-'.
Options may be specified as kwargs to the markdownify function, or as a nested Options class in MarkdownConverter subclasses.
Development
To run tests:
python setup.py test
To lint:
python setup.py lint
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.
Source Distribution
Built Distribution
File details
Details for the file markdownify-0.6.1.tar.gz
.
File metadata
- Download URL: markdownify-0.6.1.tar.gz
- Upload date:
- Size: 7.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.55.1 CPython/3.9.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 31d7c13ac2ada8bfc7535a25fee6622ca720e1b5f2d4a9cbc429d167c21f886d |
|
MD5 | 6da80f4cfa76e96833e35522c69de2b9 |
|
BLAKE2b-256 | cc3ba208b46c7f765345d659d33d7417be73a4c416900f606fb48590b5712f10 |
Provenance
File details
Details for the file markdownify-0.6.1-py3-none-any.whl
.
File metadata
- Download URL: markdownify-0.6.1-py3-none-any.whl
- Upload date:
- Size: 8.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.55.1 CPython/3.9.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7489fd5c601536996a376c4afbcd1dd034db7690af807120681461e82fbc0acc |
|
MD5 | 54a152778d86d2f6ab20be0cc6761b7d |
|
BLAKE2b-256 | f738869de205dc46b23239f8219a530b23c17d0b348fbc97072c7e0565b437a4 |