This release is a pre-release and may not be stable for production use.
pyEditorJS
A minimal, fast, Python 3.6+ package for parsing Editor.js content.
Features
- Handles all out-of-the-box Editor.js elements;
- Optional sanitization via the
bleachlibrary; - Checks whether the data is valid (e. g.: a header can't have more than 6 levels), and raises
EditorJsParseErrorif data is malformed; - Uses Editor.js's class names for styles, so the output will be consistent with WYSIWYG (see Editor.js's example style and styles documentation)
Installation
pip install pyeditorjs
Optional: install bleach for clean HTML:
pip install bleach
Usage
Quickstart
from pyeditorjs 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` requires `bleach` to be installed
print(html) # your clean HTML
Obtain texts only (for creating audio-only version, for example)
WARNING: This does not sanitize the texts! Please, call
bleach.clean(...)directly. This also doesn't obtain text from bold texts, markers, etc... - you should use BeautifulSoup for this.
#import bleach
from pyeditorjs import EditorJsParser
editor_js_data = ... # your Editor.js JSON data
parser = EditorJsParser(editor_js_data) # initialize the parser
all_texts = []
for block in parser:
text = getattr(block, 'text', None)
if text:
all_texts.append(text) # all_texts.append(bleach.clean(text))
print(all_texts)
Disclaimer
This is a community-provided project, and is not affiliated with the Editor.js team. It was created in my spare time. I cannot make sure that it will receive consistent updates.
Because of this, PRs, bug reports and suggestions are welcome!
Metadata
Release files for pyeditorjs 1.0.0b0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pyeditorjs-1.0.0b0.tar.gz | 5.7 kB | Without provenance | Details for pyeditorjs-1.0.0b0.tar.gz |
Release files / pyeditorjs-1.0.0b0.tar.gz
| Download URL | pyeditorjs-1.0.0b0.tar.gz |
|---|---|
| Size | 5.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a777a952dd84fc5efb623f7fe20bb3eafdda086e9996441294238a5d8a651a8e
|
|
BLAKE2b-256 checksum How to use checksums |
02a3d0cdc265d9cc8c55abfc3c518da1d0fd89205d28191a745aacc9a0551530
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.13
|
Security for pyeditorjs 1.0.0b0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.