diff --git a/lib/Diff/Renderer/Html/Array.php b/lib/Diff/Renderer/Html/Array.php
index b012fb6b..542b63d4 100644
--- a/lib/Diff/Renderer/Html/Array.php
+++ b/lib/Diff/Renderer/Html/Array.php
@@ -177,7 +177,8 @@ protected function formatLines($lines)
$lines = array_map(array($this, 'ExpandTabs'), $lines);
$lines = array_map(array($this, 'HtmlSafe'), $lines);
foreach($lines as &$line) {
- $line = preg_replace('# ( +)|^ #e', "\$this->fixSpaces('\\1')", $line);
+ $line = str_replace(' ', ' ', $line);
+// $line = preg_replace_callback('# ( +)|^ #', array($this, 'fixSpaces'), $line);
}
return $lines;
}
@@ -188,16 +189,19 @@ protected function formatLines($lines)
* @param string $spaces The string of spaces.
* @return string The HTML representation of the string.
*/
- function fixSpaces($spaces='')
+ function fixSpaces($matches)
{
- $count = strlen($spaces);
- if($count == 0) {
- return '';
+ $buffer = '';
+ foreach($matches as $spaces){
+ $count = strlen($spaces);
+ if($count == 0) {
+ continue;
+ }
+ $div = floor($count / 2);
+ $mod = $count % 2;
+ $buffer .= str_repeat(' ', $div).str_repeat(' ', $mod);
}
-
- $div = floor($count / 2);
- $mod = $count % 2;
- return str_repeat(' ', $div).str_repeat(' ', $mod);
+ return $buffer;
}
/**
@@ -208,7 +212,16 @@ function fixSpaces($spaces='')
*/
private function expandTabs($line)
{
- return str_replace("\t", str_repeat(' ', $this->options['tabSize']), $line);
+ $tabSize = $this->options['tabSize'];
+ while(($pos = strpos($line, "\t")) !== FALSE){
+ $left = substr($line, 0, $pos);
+ $right = substr($line, $pos + 1);
+ $length = $tabSize - ($pos % $tabSize);
+ $spaces = str_repeat(' ', $length);
+ $line = $left.$spaces.$right;
+ }
+ return $line;
+// return str_replace("\t", str_repeat(' ', $this->options['tabSize']), $line);
}
/**