Skip to content

Commit

Permalink
Fix #58 - Side by side diff shows empty diff
Browse files Browse the repository at this point in the history
  • Loading branch information
DigiLive committed Aug 5, 2020
1 parent 02695d5 commit 369b146
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions example/example.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
require '../vendor/autoload.php';

// Include two sample files for comparison.
$sampleA = file_get_contents(dirname(__FILE__) . '/a.txt');
$sampleB = file_get_contents(dirname(__FILE__) . '/b.txt');
$sampleA = file_get_contents(dirname(__FILE__) . '/c.txt');
$sampleB = file_get_contents(dirname(__FILE__) . '/d.txt');

// Options for generating the diff.
$customOptions = [
Expand Down
6 changes: 6 additions & 0 deletions lib/jblond/Diff/Renderer/Html/SideBySide.php
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,9 @@ public function generateLinesReplace(array $changes): string
$changedLine = $changes['changed']['lines'][$lineNo];
}

$line = str_replace(["\0", "\1"], $this->options['deleteMarkers'], $line);
$changedLine = str_replace(["\0", "\1"], $this->options['insertMarkers'], $changedLine);

$html .= <<<HTML
<tr>
<th>$fromLine</th>
Expand All @@ -239,6 +242,9 @@ public function generateLinesReplace(array $changes): string
$line = $changes['base']['lines'][$lineNo];
}

$line = str_replace(["\0", "\1"], $this->options['deleteMarkers'], $line);
$changedLine = str_replace(["\0", "\1"], $this->options['insertMarkers'], $changedLine);

$html .= <<<HTML
<tr>
<th>$fromLine</th>
Expand Down

0 comments on commit 369b146

Please sign in to comment.