pyEditorJS
Project description
edwh-editorjs
A minimal, fast Python 3.10+ package for parsing Editor.js content. This package is a fork of pyEditorJS by SKevo with additional capabilities.
New Features
- Expanded support for additional block types: Quote, Table, Code, Warning, and Raw blocks
- Issues a warning if an unknown block type is encountered, rather than ignoring it
- Adds a
strict
mode, raising anEditorJSUnsupportedBlock
exception for unknown block types whenstrict=True
- Allows adding new blocks by decorating a subclass of
EditorJsParser
with@block("name")
Installation
pip install edwh-editorjs
Usage
Quickstart
from edwh_editorjs import EditorJsParser
editor_js_data = ... # your Editor.js JSON data
parser = EditorJsParser(editor_js_data) # initialize the parser
html = parser.html(sanitize=True) # `sanitize=True` uses the included `bleach` dependency
print(html) # your clean HTML
Enforcing Strict Block Types
from edwh_editorjs import EditorJsParser, EditorJSUnsupportedBlock
try:
parser = EditorJsParser(editor_js_data, strict=True)
html = parser.html()
except EditorJSUnsupportedBlock as e:
print(f"Unsupported block type encountered: {e}")
Disclaimer
This is a community-provided project and is not affiliated with the Editor.js team. Contributions, bug reports, and suggestions are welcome!
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
edwh_editorjs-1.0.1.tar.gz
(32.8 kB
view details)
Built Distribution
File details
Details for the file edwh_editorjs-1.0.1.tar.gz
.
File metadata
- Download URL: edwh_editorjs-1.0.1.tar.gz
- Upload date:
- Size: 32.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.27.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4fcf1e2f9c994eea551049e67259243c94f1b1d2b7e74db3a687237f05673646 |
|
MD5 | dde0ad9ac8a742bd622795a2e038c9e0 |
|
BLAKE2b-256 | b8739dd55be7c4d60d4efaa80a4eea2385639cfe3679e0cd96b00836b4ad4db9 |
File details
Details for the file edwh_editorjs-1.0.1-py3-none-any.whl
.
File metadata
- Download URL: edwh_editorjs-1.0.1-py3-none-any.whl
- Upload date:
- Size: 7.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.27.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a3fd6d3359611f9b9f77eb9a8e6e95b69928dc2a080e0fa9ca1dc48b50601001 |
|
MD5 | 99763af860d670aaa6762dd699194e66 |
|
BLAKE2b-256 | 0c3f518b748cac2b67ac005f6e05eda95497a96e7a8c3fef464bd93c5e969246 |