https://github.com/muhammadsiyab/editorjs-parser-php
Parses Editor.js JSON output to HTML
https://github.com/muhammadsiyab/editorjs-parser-php
editorjs parser php
Last synced: 11 months ago
JSON representation
Parses Editor.js JSON output to HTML
- Host: GitHub
- URL: https://github.com/muhammadsiyab/editorjs-parser-php
- Owner: MUHAMMADSiyab
- License: mit
- Created: 2024-03-31T21:48:31.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-04-02T11:33:30.000Z (about 2 years ago)
- Last Synced: 2025-03-25T17:49:25.459Z (about 1 year ago)
- Topics: editorjs, parser, php
- Language: PHP
- Homepage:
- Size: 36.1 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## Editor.js Parser for PHP
This package allows you to easily parse [Editor.js](https://editorjs.io/) JSON output to HTML using PHP. This package is currently able to parse the blocks from these plugins:
- [Paragraph](https://github.com/editor-js/paragraph)
- [Header](https://github.com/editor-js/header)
- [Image](https://github.com/editor-js/image)
- [Quote](https://github.com/editor-js/quote)
- [List](https://github.com/editor-js/list)
- [Nested List](https://github.com/editor-js/nested-list)
- [Code](https://github.com/editor-js/code)
- [Embed](https://github.com/editor-js/embed) _(Currently, the following embed blocks are supported)_
- Youtube
- Facebook
- Twitter/X
- Instagram
- Codepen
- Github (gist)
## Requirements
PHP `>=7.4`
## Installation
composer require muhammadsiyab/editorjs-parser-php
## Using
```php
require "vendor/autoload.php";
use MuhammadSiyab\EditorjsParserPhp\Parser;
# The json output generated by Editor.js
$content = '{"time": 1711232666978,"blocks": [{...}]}' ;
$parser = new Parser();
$parsed = $parser->parse($content);
echo $parsed; // outputs the generated HTML
```
### Allow only specific blocks for parsing
```php
# Only parses the `headings` and `paragraphs`
$parsed = $parser
->only('header', 'paragraph') // can be parsed using the array syntax ['header', 'paragraph']
->parse($content);
```
### Disable specific blocks from being parsed
```php
# Parses all the blocks except `list` and `code`
$parsed = $parser
->except('list', 'code') // can be parsed using the array syntax ['list', 'code']
->parse($content);
```
### License
This Package is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT)