Library to convert rich text from Draft.js raw ContentState to HTML
Project description
Draft.js exporter
Library to convert rich text from Draft.js raw ContentState to HTML.
Features
This project adheres to Semantic Versioning, and measures performance and code coverage. Code is checked with mypy.
- Extensive configuration of the generated HTML.
- Default, extensible block & inline style maps for common HTML elements.
- Convert line breaks to
<br>elements with decorators. - Define any attribute in the block map – custom class names for elements.
- React-like API to create custom components.
- Automatic conversion of entity data to HTML attributes (int & boolean to string, style object to style string).
- Nested lists (
<li>elements go inside<ul>or<ol>, with multiple levels). - Output inline styles as inline elements (
<em>,<strong>, pick and choose, with any attribute). - Overlapping inline style and entity ranges.
- Static type annotations.
It is developed alongside the Draftail rich text editor, for Wagtail. Check out the online demo, and our introductory blog post.
When to use the exporter
Draft.js is a rich text editor framework for React. Its approach is different from most rich text editors because it does not store data as HTML, but rather in its own representation called ContentState. This exporter is useful when the ContentState to HTML conversion has to be done in a Python ecosystem.
The initial use case was to gain more control over the content managed by rich text editors in a Wagtail/Django site. If you want to read the full story, have a look at our blog post: Rethinking rich text pipelines with Draft.js.
Documentation
The full documentation is available at on the docs website. For LLM-assisted tooling, there is also a concise llms.txt and a complete llms-full.txt.
Contributing
See anything you like in here? Anything missing? We welcome all support, whether on bug reports, feature requests, code, design, reviews, tests, documentation, and more. Please have a look at our contribution guidelines.
Credits
Draftail was created by Springload, and is now maintained by Wagtail contributors. View the full list of contributors. MIT licensed.
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file draftjs_exporter-6.0.0.tar.gz.
File metadata
- Download URL: draftjs_exporter-6.0.0.tar.gz
- Upload date:
- Size: 27.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
09d0249f7342f41d58854840e72251c7485223a8351ac02675a920ae0d6991c0
|
|
| MD5 |
71312f215ad9b1e81b757095d427b3fc
|
|
| BLAKE2b-256 |
a31193626518e3e9747cca66a2e5136689f1347d03c3eeb05eaafaffac9e3c6a
|
File details
Details for the file draftjs_exporter-6.0.0-py3-none-any.whl.
File metadata
- Download URL: draftjs_exporter-6.0.0-py3-none-any.whl
- Upload date:
- Size: 39.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1f1bd07a0f7f1a2107a1c449d6d5a6889f4c29ca0192169d56c732ca58498c8e
|
|
| MD5 |
cadb4ae703d7718a269f616843aa556c
|
|
| BLAKE2b-256 |
5a7d7c2e275b83a8347026a3f5f278dd26805a474fb36af2ffb75fc086b953f0
|