承接 michalskoula/remove-formatting 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

michalskoula/remove-formatting

最新稳定版本:1.0.1

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:&quot;Calibri&quot;,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:&quot;Calibri&quot;,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:&quot;Calibri&quot;,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:&quot;Calibri&quot;,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

统计信息

  • 总下载量: 6
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-07-15

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固