gathercontent/htmldiff 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

gathercontent/htmldiff

最新稳定版本:0.2.1

Composer 安装命令:

composer require gathercontent/htmldiff

包简介

Compare two HTML strings

README 文档

README

Build Status

Compare two HTML strings. This library converts HTML into a form that can be diffed using the algorithm found in Git or Linux (comparing entire lines of code) to achieve greater accuracy, then decodes it back into a valid HTML.

Requirements

  • PHP 5.3.0 or later
  • Tidy extension for PHP

Installation

Add Htmldiff to your composer.json file:

"require": { "gathercontent/htmldiff": "0.2.*" }

Get composer to install the package:

$ composer update gathercontent/htmldiff

Usage

The input is going to be parsed by Tidy before diffing. Here's a few examples:

$old = '<span>This is a string</span>'; $new = '<span>This is a text</span>'; $htmldiff = new Htmldiff; $result = $htmldiff->diff($old, $new); // result: <span>This is a <del>string</del><ins>text</ins></span>
$old = '<p>Hello world, how do you do</p>'; $new = '<p>Hello world, how do <strong>you</strong> do</p>'; $htmldiff = new Htmldiff; $result = $htmldiff->diff($old, $new); // result: <p>Hello world, how do <del>you</del><strong><ins>you</ins></strong> do</p>
$old = '<p>Hello world</p><p>How do you do</p>'; $new = '<p>Hello world</p><ul><li>first point</li><li>second point</li></ul><p>How do you do</p>'; $htmldiff = new Htmldiff; $result = $htmldiff->diff($old, $new); // result: <p>Hello world</p><ul><li><ins>first point</ins></li><li><ins>second point</ins></li></ul><p>How do you do</p>

Testing

Run unit tests:

$ ./vendor/bin/phpunit

Test compliance with PSR2 coding style guide:

$ ./vendor/bin/phpcs --standard=PSR2 ./src

Licence

The MIT License (MIT) - see README.md

统计信息

  • 总下载量: 284.81k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 11
  • 点击次数: 2
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 11
  • Watchers: 9
  • Forks: 6
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固