Skip to content

Commit

Permalink
Merge pull request #59 from JBlond/php-diff-58
Browse files Browse the repository at this point in the history
Php diff 58
  • Loading branch information
JBlond authored Aug 6, 2020
2 parents acd12cb + 0946d59 commit 5289ea3
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion lib/jblond/Diff/Renderer/Html/SideBySide.php
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,6 @@ public function generateLinesReplace(array $changes): string
$fromLine = $changes['base']['offset'] + $lineNo + 1;
$toLine = " ";
$changedLine = " ";

if (isset($changes['changed']['lines'][$lineNo])) {
$toLine = $changes['changed']['offset'] + $lineNo + 1;
$changedLine = $changes['changed']['lines'][$lineNo];
Expand All @@ -230,6 +229,34 @@ public function generateLinesReplace(array $changes): string
</tr>
HTML;
}

return $html;
}

foreach ($changes['changed']['lines'] as $lineNo => $changedLine) {
$toLine = $changes['changed']['offset'] + $lineNo + 1;
$fromLine = "&nbsp;";
$line = "&nbsp;";
if (isset($changes['base']['lines'][$lineNo])) {
$fromLine = $changes['base']['offset'] + $lineNo + 1;
$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>
<td class="Left">
<span>$line</span>
</td>
<th>$toLine</th>
<td class="Right">
<span>$changedLine</span>
</td>
</tr>
HTML;
}

return $html;
Expand Down

0 comments on commit 5289ea3

Please sign in to comment.