Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nyankiyoshi/html-to-draftjs
Convert basic HTML into DraftJS JSON format.
https://github.com/nyankiyoshi/html-to-draftjs
converter draft-js exporter python
Last synced: about 1 month ago
JSON representation
Convert basic HTML into DraftJS JSON format.
- Host: GitHub
- URL: https://github.com/nyankiyoshi/html-to-draftjs
- Owner: NyanKiyoshi
- License: mit
- Created: 2019-07-10T10:28:53.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-10-27T21:00:46.000Z (about 4 years ago)
- Last Synced: 2024-10-07T08:07:47.989Z (3 months ago)
- Topics: converter, draft-js, exporter, python
- Language: Python
- Size: 44.9 KB
- Stars: 3
- Watchers: 2
- Forks: 9
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.rst
- Contributing: CONTRIBUTING.md
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
## Installation
```
pip install html-to-draftjs
```## Usage
```python
from html_to_draftjs import html_to_draftjsjson = html_to_draftjs("""
My Page
Introduction
Some content that is pretty interesting
Don't forget to follow me!
Illustration
""")
```## API
### `html_to_draftjs(raw_html_content: str[, features="lxml", strict=False]) -> dict`
Converts a given HTML input into JSON.- `features` the features for the HTML tree-builder. By default it is set to `lxml` which is fast and powerful.
- `strict` (boolean), if false, it will only warn on invalid operations. If true, it will raise errors.### `soup_to_draftjs(bs_object: BeautifulSoup[, strict=False]) -> 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`).- `strict` (boolean), if false, it will only warn on invalid operations. If true, it will raise errors.
## Supported Tags and Attributes
### Blocks
- ``, ``
- `` ... `
`
- ``
- `` and ` ` (doesn't support `
` grouping)
- Doesn't support the `align` attribute.### Inline Styling
- ``, ``
- ``, ``### Entities
- ``
- ``
- `
`
- Doesn't support the `title` and `align` attributes.## Development
```
./setup.py develop
pip install -r requirements_dev.txt
```