A HTML to Kirbytext converter
Project description
This is a html to Kirbytext converter for python.
It is currently in heavy development.
Installation
HTML2Kirby is tested and suported from Python 3.4 upwards
Install via pip:
pip install html2kirby
Usage
To use this package, simply import the package and feed it some html:
from html2kirby import HTML2Kirby formatter = HTML2Kirby() formatter.feed("""<img src="https://placekitten.com/200/300" alt="kittens are cute" />""")
You can then access the result via .kirbytext attribute:
print(formatter.kirbytext) # prints (image: https://placekitten.com/200/300 alt: kittesn are cute)
Testing
Make sure you have Pytest installed (pip install pytest). Then just invoke it:
pytest
Supported Markup
As of now, following tags are supported:
Simple formatting (<b>, <strong>, <i>, <em>)
Headings (<h1>, <h2>, …)
Images (<img>)
line breaks (<br>)
Paragraphs (<p>)
Blocks (<pre>, <code>, <blockquote>, <pre><code>)
Links (<a>)
Horizontal rulers (<hr>)
Lists (<ul>, <ol>, <li>)
Passed markup
Markup tags that aren’t implemented are just dropped except for following tags:
table
tr
td
th
tbody
thead
strike
u
abbr
del
svg
They will just be kept in the Kirbytext which should result in a valid output.
Issues
In python3.4, the doesn’t quite convert all of the html 5 escaped characters such as – (en dash).
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
File details
Details for the file html2kirby-0.2.tar.gz
.
File metadata
- Download URL: html2kirby-0.2.tar.gz
- Upload date:
- Size: 5.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 482a3d969f6fa65b7c4cb19d2458bac880f84a2962e3043be1501cd550e1f3fb |
|
MD5 | d0e9bce71f68b1a0c23151491255c2c7 |
|
BLAKE2b-256 | 88c82b5e5f24a51f52d2292c9d182d53d4c1606d8929ca26fdb62b3b6d9a5a30 |