michalskoula/remove-formatting
Composer 安装命令:
composer require michalskoula/remove-formatting
包简介
Simple tool to remove (some) HTML formatting, for example for text copied from Word or Google Docs.
README 文档
README
Simple tool to remove (some) HTML formatting, for example for text copied from Microsoft Word or Google Docs. It removes unwanted styles, classes, elements etc.
Features:
- removes unwanted elements (default: keep ['a', 'img', 'p', 'strong'])
- removes unwanted attributes (default: keep ['href', 'src'])
- removes unwanted whitespaces (default: false)
Installation
composer require michalskoula/remove-formatting
Requires PHP 7.4+
Usage
use MichalSkoula\RemoveFormatting\Remover; use MichalSkoula\RemoveFormatting\RemoverOptions; // create options object (optional) $options = new RemoverOptions(); // add <u> to the default list of allowed elements $options->addAllowedElement('u'); // add class to the default list of allowed attributes $options->addAllowedAttribute('class'); // create Remover object $remover = new Remover($options); $dirtyHtml = 'some dirty <span>spans</span> ...'; // run it and get clean html with only allowed elements and attributes $cleanHtml = $remover->remove($dirtyHtml);
See example.php
HTML Before
<p style="margin-bottom:11px"><span style="font-size:11pt"><span style="line-height:107%"><span style="font-family:"Calibri",sans-serif">Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Phasellus rhoncus. Quisque porta. Maecenas libero. Sed vel lectus. Donec odio tempus molestie, porttitor ut, iaculis quis, sem. <u>Integer tempor</u>. Fusce wisi. </span></span></span></p> <p style="margin-bottom:11px"><span style="font-size:11pt"><span style="line-height:107%"><span style="font-family:"Calibri",sans-serif"> <img height="1280" src="https://skoula.cz/nazdar/screens/nazdar1.png" width="1277" /></span></span></span></p> <p style="margin-bottom:11px"><span style="font-size:11pt"><span style="line-height:107%"><span style="font-family:"Calibri",sans-serif">Nullam at arcu a <b>est sollicitudin euismod</b>. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos hymenaeos. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos hymenaeos. </span></span></span></p> <p style="margin-bottom:11px"><span style="font-size:11pt"><span style="line-height:107%"><span style="font-family:"Calibri",sans-serif">Sed ac dolor sit <a href="https://skoula.cz/nazdar" style="color:#0563c1; text-decoration:underline">amet purus malesuada</a> congue. Etiam dictum tincidunt diam. Aenean vel massa quis mauris vehicula lacinia.</span></span></span></p>
HTML After
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Phasellus rhoncus. Quisque porta. Maecenas libero. Sed vel lectus. Donec odio tempus molestie, porttitor ut, iaculis quis, sem. <u>Integer tempor</u>. Fusce wisi. </p> <p><img src="https://skoula.cz/nazdar/screens/nazdar1.png"></p> <p>Nullam at arcu a est sollicitudin euismod.Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos hymenaeos. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos hymenaeos.</p> <p>Sed ac dolor sit <a href="https://skoula.cz/nazdar">amet purus malesuada</a> congue. Etiam dictum tincidunt diam. Aenean vel massa quis mauris vehicula lacinia.</p>
About
- MIT Licence
- https://skoula.cz
michalskoula/remove-formatting 适用场景与选型建议
michalskoula/remove-formatting 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 6 次下载、GitHub Stars 达 1, 最近一次更新时间为 2023 年 07 月 15 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 michalskoula/remove-formatting 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 michalskoula/remove-formatting 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 6
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 9
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-07-15