https://github.com/sftsrv/structured-html
A little library for converting HTML into a structured data format that is compatible with EditorJS
https://github.com/sftsrv/structured-html
editorjs html library typescript
Last synced: about 1 year ago
JSON representation
A little library for converting HTML into a structured data format that is compatible with EditorJS
- Host: GitHub
- URL: https://github.com/sftsrv/structured-html
- Owner: sftsrv
- License: gpl-3.0
- Created: 2023-01-25T20:23:46.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-03-26T17:48:50.000Z (about 2 years ago)
- Last Synced: 2025-04-14T18:54:12.274Z (about 1 year ago)
- Topics: editorjs, html, library, typescript
- Language: TypeScript
- Homepage: https://jsr.io/@sftsrv/structured-html
- Size: 70.3 KB
- Stars: 6
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Structured HTML
A little library for simplifying and transforming HTML into structured data
## Usage
While designed around the [EditorJS](https://github.com/codex-team/editor.js) API, the library may be used for just transforming HTML content into structured/block-based content for a variety of purposes
The conversion from HTML can be done as follows:
```ts
import { convertHtmlToStructuredContent } from "@sftsrv/structured-html";
// get some RAW HTML
const htmlText = "
hello world
";
// use the DOM to parse it from a string
const html = new DOMParser().parseFromString(htmlText, "text/html").body;
// the convertHtmlToStructuredContent function takes an HTML ELement and returns the structured HTML content
const blocks = convertHtmlToStructuredContent(html);
```