Skip to content

Commit 369b146

Browse files
committed
Fix #58 - Side by side diff shows empty diff
1 parent 02695d5 commit 369b146

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

example/example.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
require '../vendor/autoload.php';
1212

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

1717
// Options for generating the diff.
1818
$customOptions = [

lib/jblond/Diff/Renderer/Html/SideBySide.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,9 @@ public function generateLinesReplace(array $changes): string
213213
$changedLine = $changes['changed']['lines'][$lineNo];
214214
}
215215

216+
$line = str_replace(["\0", "\1"], $this->options['deleteMarkers'], $line);
217+
$changedLine = str_replace(["\0", "\1"], $this->options['insertMarkers'], $changedLine);
218+
216219
$html .= <<<HTML
217220
<tr>
218221
<th>$fromLine</th>
@@ -239,6 +242,9 @@ public function generateLinesReplace(array $changes): string
239242
$line = $changes['base']['lines'][$lineNo];
240243
}
241244

245+
$line = str_replace(["\0", "\1"], $this->options['deleteMarkers'], $line);
246+
$changedLine = str_replace(["\0", "\1"], $this->options['insertMarkers'], $changedLine);
247+
242248
$html .= <<<HTML
243249
<tr>
244250
<th>$fromLine</th>

0 commit comments

Comments
 (0)