From b84330f780221d7324ec719b39b3d2ad1717c833 Mon Sep 17 00:00:00 2001 From: Fabian Bircher Date: Tue, 2 Dec 2014 12:27:29 +0100 Subject: [PATCH] Merge pull request #25 --- lib/Diff/Renderer/Html/Array.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/Diff/Renderer/Html/Array.php b/lib/Diff/Renderer/Html/Array.php index 0b3f1d50..958c5f6d 100644 --- a/lib/Diff/Renderer/Html/Array.php +++ b/lib/Diff/Renderer/Html/Array.php @@ -177,7 +177,7 @@ private 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 = preg_replace_callback('# ( +)|^ #', array($this, 'fixSpaces'), $line); } return $lines; } @@ -185,12 +185,12 @@ private function formatLines($lines) /** * Replace a string containing spaces with a HTML representation using  . * - * @param string $spaces The string of spaces. + * @param array $matches The string of spaces. * @return string The HTML representation of the string. */ - function fixSpaces($spaces='') + function fixSpaces($matches) { - $count = strlen($spaces); + $count = strlen($matches[0]); if($count == 0) { return ''; } @@ -221,4 +221,5 @@ private function htmlSafe($string) { return htmlspecialchars($string, ENT_NOQUOTES, 'UTF-8'); } -} \ No newline at end of file +} +