Skip to content

Latest commit

 

History

History
74 lines (46 loc) · 1.73 KB

README.md

File metadata and controls

74 lines (46 loc) · 1.73 KB

Editor.js Parser for PHP

This package allows you to easily parse Editor.js JSON output to HTML using PHP. This package is currently able to parse the blocks from these plugins:

Requirements

PHP >=7.4

Installation

composer require muhammadsiyab/editorjs-parser-php

Using

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

# 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

# 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