muhammadsiyab / editorjs-parser-php
editorjs库的PHP解析器
v1.0.1
2024-04-01 22:44 UTC
Requires
- php: >=7.4
Requires (Dev)
README
本包允许您使用PHP轻松地将Editor.js JSON输出解析为HTML。此包目前可以解析以下插件的块
要求
PHP >=7.4
安装
composer require muhammadsiyab/editorjs-parser-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
仅允许解析特定块
# Only parses the `headings` and `paragraphs` $parsed = $parser ->only('header', 'paragraph') // can be parsed using the array syntax ['header', 'paragraph'] ->parse($content);
禁用解析特定块
# Parses all the blocks except `list` and `code` $parsed = $parser ->except('list', 'code') // can be parsed using the array syntax ['list', 'code'] ->parse($content);
许可
本包是开源软件,许可协议为MIT许可