1. Colorized diff output
    on the shell

Colorized diff output on the shell

Together with Console_Color, it is possible to use Text_Diff to generate colored diffs on an ANSI terminal.

<?php
require_once 'Console/Color.php';
require_once 
'Text/Diff.php';
require_once 
'Text/Diff/Renderer/inline.php';

$lines1 file('1.htm');
$lines2 file('2.htm');

$diff     = new Text_Diff('auto', array($lines1$lines2));
$renderer = new Text_Diff_Renderer_inline(
    array(
        
'ins_prefix' => '%g',
        
'ins_suffix' => '%n',
        
'del_prefix' => '%r',
        
'del_suffix' => '%n',
    )
);
echo 
Console_Color::convert(
    
htmlspecialchars_decode(
        
$renderer->render($diff)
    )
);
?>

is displayed like that on a shell:

Screenshot
Usage examples (Previous) Text_Figlet (Next)
Last updated: Sat, 16 Feb 2019 — Download Documentation
Do you think that something on this page is wrong? Please file a bug report.
View this page in:
  • English

User Notes:

There are no user contributed notes for this page.