Context renderer
<?php
require_once 'Text/Diff.php';
require_once 'Text/Diff/Renderer/context.php';
$lines1 = file('1.htm');
$lines2 = file('2.htm');
$diff = new Text_Diff('auto', array($lines1, $lines2));
$renderer = new Text_Diff_Renderer_context();
echo $renderer->render($diff);
?>
generates the following output:
***************
*** 3,13 ****
<head>
! <title>PEAR Bug Tracking</title>
</head>
<body>
<h1>PEAR Bug Tracking System</h1>
! <div class="bug-box">
! <h2>Report new Bug</h2>
! <p>Got a test case?</p>
!
! <p>Reproducable steps?</p>
</div>
</body>
</html>
--- 3,13 ----
<head>
! <title>PEAR Bug Tracker</title>
</head>
<body>
<h1>PEAR Bug Tracking System</h1>
! <div class="bug-box bug-box-first">
! <h2>Report New Bug</h2>
! <p>
! Got a test case or reproducible steps?
! </p>
</div>
</body>
</html>
Inline renderer
<?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();
echo $renderer->render($diff);
?>
generates the following output:
<?xml version="1.0" encoding="utf-8"?>
<html>
<head>
<title>PEAR Bug <del>Tracking</title></del><ins>Tracker</title></ins>
</head>
<body>
<h1>PEAR Bug Tracking System</h1>
<div <del>class="bug-box"></del><ins>class="bug-box bug-box-first"></ins>
<h2>Report <del>new</del><ins>New</ins> Bug</h2><del>
<p>Got</del><ins>
<p>
Got</ins> a test <del>case?</p>
<p>Reproducable steps?</p></del><ins>case or reproducible steps?
</p></ins>
</div>
</body>
</html>
Unified renderer
<?php
require_once 'Text/Diff.php';
require_once 'Text/Diff/Renderer/unified.php';
$lines1 = file('1.htm');
$lines2 = file('2.htm');
$diff = new Text_Diff('auto', array($lines1, $lines2));
$renderer = new Text_Diff_Renderer_unified();
echo $renderer->render($diff);
?>
generates the following output:
@@ -3,13 +3,13 @@ <head> - <title>PEAR Bug Tracking</title> + <title>PEAR Bug Tracker</title> </head> <body> <h1>PEAR Bug Tracking System</h1> - <div class="bug-box"> - <h2>Report new Bug</h2> - <p>Got a test case?</p> - - <p>Reproducable steps?</p> + <div class="bug-box bug-box-first"> + <h2>Report New Bug</h2> + <p> + Got a test case or reproducible steps? + </p> </div> </body> </html>