Skip to content

Commit 2cf8e84

Browse files
New Renderer (#22)
* new renderer * fix annotation * PSR2 Sniff * travis build * fix condition * Update example Signed-off-by: Jack Cherng <[email protected]> * Some coding style fixes Signed-off-by: Jack Cherng <[email protected]> Co-authored-by: Jack Cherng <[email protected]>
1 parent 2277a98 commit 2cf8e84

File tree

4 files changed

+380
-1
lines changed

4 files changed

+380
-1
lines changed

example/demo.php

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636

3737
// options for renderer class
3838
$rendererOptions = [
39-
// how detailed the rendered HTML is? (line, word, char)
39+
// how detailed the rendered HTML is? (none, line, word, char)
4040
'detailLevel' => 'line',
4141
// renderer language: eng, cht, chs, jpn, ...
4242
// or an array which has the same keys with a language file
@@ -158,6 +158,22 @@
158158

159159
?>
160160

161+
<h1>Combined Diff</h1>
162+
<?php
163+
164+
// generate a combined diff
165+
$sideBySideResult = DiffHelper::calculateFiles(
166+
$oldFilePath,
167+
$newFilePath,
168+
'Combined',
169+
$diffOptions,
170+
$rendererOptions
171+
);
172+
173+
echo $sideBySideResult;
174+
175+
?>
176+
161177
<h1>Unified Diff</h1>
162178
<pre><?php
163179

example/diff-table.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@
8686
.diff-wrapper.diff.diff-html .change .new {
8787
background: #e1fbe1;
8888
}
89+
.diff-wrapper.diff.diff-html .change .rep {
90+
background: #fef6d9;
91+
}
8992
.diff-wrapper.diff.diff-html .change ins,
9093
.diff-wrapper.diff.diff-html .change del {
9194
font-weight: 700;

example/diff-table.scss

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
$bg-color-insert-base: #8e8;
1212
$bg-color-delete-base: #e88;
13+
$bg-color-replace-base: #fbdb65;
1314

1415
$op-highlight-ratio: 90%;
1516
$op-normal-ratio: 25%;
@@ -21,6 +22,7 @@
2122
// colors for operation rows
2223
$bg-color-insert: mix($bg-color-insert-base, $bg-color, $op-normal-ratio);
2324
$bg-color-delete: mix($bg-color-delete-base, $bg-color, $op-normal-ratio);
25+
$bg-color-replace: mix($bg-color-replace-base, $bg-color, $op-normal-ratio);
2426

2527
$table-head-color: mix($bg-color, $text-color, 65%);
2628
$table-sidebar-color: mix($bg-color, $text-color, 80%);
@@ -141,6 +143,10 @@
141143
background: $bg-color-insert;
142144
}
143145

146+
.rep {
147+
background: $bg-color-replace;
148+
}
149+
144150
ins,
145151
del {
146152
font-weight: 700;

0 commit comments

Comments
 (0)