riki137/finediff
最新稳定版本:1.1.2
Composer 安装命令:
composer require riki137/finediff
包简介
PHP8 implementation of a Fine granularity Diff engine
README 文档
README
Originally written by Raymond Hill (https://github.com/gorhill/PHP-FineDiff)
Installation
composer require d4h/finediff
Usage
Render HTML
Render the difference between two strings as HTML:
$diff = new FineDiff\Diff(); echo $diff->render('string one', 'string two');
This would then output:
string <ins>tw</ins>o<del>ne</del>
You could change the granularity to CogPowered\FineDiff\Granularity\Word
$diff = new FineDiff\Diff(new FineDiff\Granularity\Word()); // Or via the setter method: $diff->setGranularity(new FineDiff\Granularity\Word());
so the output is:
string <del>one</del><ins>two</ins>
You do this by passing it into the Diff constructor:
Grab opcode instructions
Opcode instructions are what tell FineDiff how to change one string into another.
$diff = new FineDiff\Diff(); echo $diff->getOpcodes('string one', 'string two');
This would then output:
c7d3i3:two
Render text using the opcodes:
$renderer = new FineDiff\Render\Text(); echo $renderer->process('string one', 'c7d3i3:two');
Would output:
string two
Same with HTML:
$renderer = new FineDiff\Render\Html(); echo $renderer->process('string one', 'c7d3i3:two');
Credits
Sponsored by D4H.
统计信息
- 总下载量: 165.62k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-05-25