Commit d2d620eb authored by Tim Steiner's avatar Tim Steiner
Browse files

Add some comments to the HtmlDiff view helper.

parent af5d2111
......@@ -6,6 +6,9 @@ class Unl_View_Helper_HtmlDiff extends Zend_View_Helper_Abstract
public function htmlDiff($from, $to, $delimiter = " \r\n")
{
/* First we need to do a bit of filtering to be sure that HTML Tags are
* treated as atomic elements (and aren't split up or grouped with other text)
*/
do {
$from = preg_replace('/(<[^> ]*) ([^>]*>)/', '$1#TAG_SPACE#$2', $from, -1, $count);
} while ($count > 0);
......@@ -17,6 +20,8 @@ class Unl_View_Helper_HtmlDiff extends Zend_View_Helper_Abstract
$from = strtr($from, array('<' => ' <', '>' => '> '));
$to = strtr($to, array('<' => ' <', '>' => '> '));
// Now the real work.
if (!self::$_diffRenderer) {
require_once 'Text/Diff/Renderer/inline.php';
self::$_diffRenderer = new Text_Diff_Renderer_inline();
......@@ -36,6 +41,7 @@ class Unl_View_Helper_HtmlDiff extends Zend_View_Helper_Abstract
$diff = new Text_Diff('auto', array($currentArray, $proposedArray));
$diffHtml = ($diff->isEmpty() ? $from : self::$_diffRenderer->render($diff));
// Undo the filtering.
$diffHtml = strtr($diffHtml, array('#TAG_SPACE#' => ' '));
$tidyConfig = array('show-body-only' => true);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment