miaababikir / snow
该包最新版本(dev-master)没有提供许可证信息。
dev-master
2019-10-10 20:54 UTC
Requires (Dev)
- ext-json: *
- orchestra/testbench: ^4.0
This package is auto-updated.
Last update: 2024-09-30 01:31:05 UTC
README
安装
要安装库,请使用composer
composer require miaababikir/snow
指南
在您的PHP脚本顶部添加此行
use Miaababikir\Snow\Parser;
基本用法
您可以通过传递JSON对象来解析编辑器js json,并将获取纯HTML内容。
例如
编辑器js的json看起来像这样
{
"time": 1570726916129,
"blocks": [
{
"type": "header",
"data": {
"text": "Editor.js",
"level": 2
}
},
{
"type": "list",
"data": {
"style": "unordered",
"items": [
"It is a block-styled editor",
"It returns clean data output in JSON",
"Designed to be extendable and pluggable with a simple API"
]
}
},
{
"type": "paragraph",
"data": {
"text": "We have been working."
}
}
],
"version": "2.15.0"
}
您将上面的json传递给解析器
Parser::parse($editorJson);
然后输出将类似于这样
"<h2>Editor.js</h2><ul><li>It is a block-styled editor</li><li>It returns clean data output in JSON</li><li>Designed to be extendable and pluggable with a simple API</li></ul><p>We have been working.</p>"