Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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.

Awesome Lists containing this project

README

        


HTML to DraftJS


Convert HTML into DraftJS JSON format.




Requirement Status


Coverage Status


Version




Commits since latest release


Supported versions


Supported implementations


## Installation
```
pip install html-to-draftjs
```

## Usage

```python
from html_to_draftjs import html_to_draftjs

json = html_to_draftjs("""

My Page

Introduction

Some content that is pretty interesting


Don't forget to follow me!

Illustration


image


""")
```

## 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 `