Convert basic HTML into DraftJS JSON format.
Project description
Installation
pip install html-to-draftjs
Usage
from html_to_draftjs import html_to_json
json = html_to_json("""
<h1>My Page</h1>
<h2>Introduction</h2>
<p>Some <em>content</em> that is pretty <strong>interesting</strong></p>
<p>Don't forget to <a href="https://example.com">follow me!</a></p>
<h2>Illustration</h2>
<p><img src="https://example.com/image.png" alt="image" /></p>
""")
API
html_to_json(raw_html_content: str) -> dict
Converts a given HTML input into JSON.
html_to_json(bs_object: BeautifulSoup) -> dict
Converts a given beautiful soup into JSON. Useful if you have to select a given part of the HTML content to convert it (e.g. #content
).
Supported Tags and Attributes
Blocks
<div>
,<p>
<h1>
...<h6>
<blockquote>
<li>
and<ol>
(doesn't support<ul>
grouping)- Doesn't support the
align
attribute.
Inline Styling
<strong>
,<b>
<em>
,<i>
Entities
<img src="url" [alt="alt"] [height="123"] [width="123"]>
<a href="url">
- Doesn't support the
title
andalign
attributes.
Development
./setup.py develop
pip install -r requirements_dev.txt
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
Close
Hashes for html-to-draftjs-0.0.0.dev0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 053c2f5fdb6e15a69ca3bef12566f2c195deeb611bc40a2ea73e162cf1e92c7f |
|
MD5 | 817f21c3e57b43e1c743270e4c3513f3 |
|
BLAKE2b-256 | 2b877cf4a3e3de9391a74503c1f8f0b3b14751f1c0b67d498a9592c9113aeed9 |