| Crates.io | editorjs2html |
| lib.rs | editorjs2html |
| version | 0.1.12 |
| created_at | 2025-02-09 16:44:26.533845+00 |
| updated_at | 2025-07-12 08:34:04.99725+00 |
| description | editorjs2html converts Editor.js output into clean HTML, supporting multiple block types efficiently. |
| homepage | |
| repository | https://github.com/MKJS57/editorjs2html |
| max_upload_size | |
| id | 1549098 |
| size | 3,481,530 |
A Rust library that converts Editor.js output into clean HTML with semantic CSS classes.
cargo add editorjs2html
use editorjs2html::string_to_html;
fn main() {
let content = r#"{
"blocks": [{
"type": "header",
"data": {
"text": "Hello World",
"level": 2
}
}]
}"#;
let html = string_to_html(content).unwrap();
println!("{}", html);
}
| Block Type | Class Name | Additional Classes/Notes |
|---|---|---|
| Header / Heading | js-head |
Supports alignment |
| Paragraph | js-para |
Supports alignment |
| List / Nested List | js-list |
Supports ordered/unordered |
| Checklist | js-checklist |
js-checkbox for items |
| Table | js-table |
Supports headers |
| Quote | js-quote |
Supports alignment |
| Code | js-code |
Supports language highlighting |
| Link | js-link |
Opens in new tab |
| Inline Text | js-inline |
Multiple formatting options |
| Warning | warning |
Title + message format |
| Image | js-image |
Multiple display options |
| Embed | js-embed |
Supports various platforms |
| Raw HTML | js-raw |
Direct HTML insertion |
| Alert | js-alert |
Multiple types (see below) |
| Title | js-title |
Custom styling options |
| Attaches | js-attaches |
File attachments |
| Toggle | js-toggle |
Expandable content |
| Delimiter | js-delimiter |
Multiple styles |
| Button | js-button |
Interactive elements |
Available classes for alerts:
js-alert-primaryjs-alert-secondaryjs-alert-infojs-alert-successjs-alert-warningjs-alert-dangerjs-alert-lightjs-alert-darkAdditional classes for images:
js-image--stretched - Full widthjs-image--bordered - With borderjs-image--background - With backgroundApplied in this order:
bold → <b>italic → <i>underline → <u>marker → <mark>inline_code → <code>The library generates semantic HTML with consistent class names for styling. Example:
/* Headers */
.js-head h2 {
color: #2c3e50;
margin: 1.5em 0 1em;
}
/* Lists */
.js-list {
padding-left: 1.5em;
}
/* Code blocks */
.js-code {
background: #f8f9fa;
padding: 1em;
border-radius: 4px;
}
cargo install just
just setup
<type>: <description>
Types:
- feat: New features
- fix: Bug fixes
- docs: Documentation
- style: Code style changes
- ref: Refactoring
- test: Testing
- perf: Performance
Licensed under either:
at your option.