Skip to content

Commit 206a41e

Browse files
authored
Merge pull request #81 from JBlond/php-diff-77
php-diff-77
2 parents 532bd4a + b13ff84 commit 206a41e

File tree

17 files changed

+340
-699
lines changed

17 files changed

+340
-699
lines changed

README.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ standard formats including:
1212

1313
* Unified
1414
* Context
15-
* Inline HTML
1615
* Side by Side HTML
1716
* Unified HTML
1817
* Unified Commandline colored output
@@ -94,10 +93,6 @@ directory. Included is a light and a dark theme.
9493

9594
<details><summary>More Example Pictures</summary><br>
9695

97-
#### HTML Inline Example
98-
99-
![HTML Inline Example](assets/htmlInline.png "HTML Inline Example")
100-
10196
#### HTML Unified Example
10297

10398
![HTML Unified Example](assets/htmlUnified.png "HTML Unified Example")

assets/htmlInline.png

-190 KB
Binary file not shown.

assets/htmlUnified.png

32.1 KB
Loading

example/dark-theme.css

Lines changed: 8 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -98,29 +98,29 @@ a, a:visited {
9898
}
9999

100100
/*
101-
* HTML Inline Diff
101+
* HTML Unified Diff
102102
*/
103103

104-
.DifferencesInline .ChangeReplace {
104+
.DifferencesUnified .ChangeReplace {
105105
color: #272822;
106106
}
107107

108-
.DifferencesInline .ChangeReplace .Left,
109-
.DifferencesInline .ChangeDelete .Left {
108+
.DifferencesUnified .ChangeReplace .Left,
109+
.DifferencesUnified .ChangeDelete .Left {
110110
background: #FFDDDD;
111111
color: #272822;
112112
}
113113

114-
.DifferencesInline .ChangeReplace .Right,
115-
.DifferencesInline .ChangeInsert .Right {
114+
.DifferencesUnified .ChangeReplace .Right,
115+
.DifferencesUnified .ChangeInsert .Right {
116116
background: #DDFFDD;
117117
}
118118

119-
.DifferencesInline .ChangeReplace ins {
119+
.DifferencesUnified .ChangeReplace ins {
120120
background: #008000;
121121
}
122122

123-
.DifferencesInline .ChangeReplace del {
123+
.DifferencesUnified .ChangeReplace del {
124124
background: #EE9999;
125125
color: #272822;
126126
}
@@ -153,65 +153,3 @@ a, a:visited {
153153
.DifferencesMerged th.ChangeDelete {
154154
background-image: linear-gradient(-45deg, #AAAAAA 0%, #EE9999 100%);
155155
}
156-
157-
/*
158-
* HTML Unified Diff
159-
*/
160-
161-
/* Line removed in new */
162-
.DifferencesUnified .ChangeDelete .Left::before {
163-
content: "- \00a0";
164-
}
165-
166-
.DifferencesUnified .ChangeDelete .Left {
167-
background: #EE9999;
168-
color: #272822;
169-
}
170-
171-
/* Line modified in old and new */
172-
.DifferencesUnified .ChangeReplace {
173-
background: #FFEE99;
174-
color: #272822;
175-
display: table;
176-
}
177-
178-
/* Line in old replaced by line in new */
179-
.DifferencesUnified .ChangeReplace .Left:first-child:before {
180-
content: "\250C \00a0";
181-
}
182-
183-
.DifferencesUnified .ChangeReplace .Left:before {
184-
content: "\251C \00a0";
185-
}
186-
187-
.DifferencesUnified .ChangeReplace .Left {
188-
background: #FFEE99;
189-
}
190-
191-
/* Line in new replaced line in old */
192-
.DifferencesUnified .ChangeReplace .Right:last-of-type:before {
193-
content: "\2514 \00a0";
194-
}
195-
196-
.DifferencesUnified .ChangeReplace .Right:before {
197-
content: "\251C \00a0";
198-
}
199-
200-
.DifferencesUnified .ChangeReplace .Right {
201-
background: #FFEE99;
202-
}
203-
204-
/* Line inserted in new */
205-
.DifferencesUnified .ChangeInsert .Right:before {
206-
content: "+ \00A0";
207-
}
208-
209-
/* Character inserted in line of new */
210-
.DifferencesUnified .ChangeReplace ins {
211-
background: #99EE99;
212-
}
213-
214-
/* Character removed from line in old */
215-
.DifferencesUnified .ChangeReplace del {
216-
background: #EE9999;
217-
}

example/example.php

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
<?php
22

33
use jblond\Diff;
4-
use jblond\Diff\Renderer\Html\Inline;
54
use jblond\Diff\Renderer\Html\Merged;
65
use jblond\Diff\Renderer\Html\SideBySide;
7-
use jblond\Diff\Renderer\Html\Unified as HtmlUnified;
6+
use jblond\Diff\Renderer\Html\Unified;
87
use jblond\Diff\Renderer\Text\Context;
9-
use jblond\Diff\Renderer\Text\Unified;
8+
use jblond\Diff\Renderer\Text\Unified as TextUnified;
109

1110
// Include and instantiate autoloader.
1211
require '../vendor/autoload.php';
@@ -85,31 +84,24 @@ function changeCSS(cssFile, cssLinkIndex) {
8584
echo $diff->isIdentical() ? 'No differences found.' : $diff->Render($renderer);
8685
?>
8786

88-
<h2>HTML Inline Diff</h2>
87+
<h2>HTML Unified Diff</h2>
8988
<?php
90-
// Generate an inline diff.
91-
$renderer = new Inline($rendererOptions);
89+
// Generate an unified diff.
90+
$renderer = new Unified($rendererOptions);
9291
echo $diff->isIdentical() ? 'No differences found.' : $diff->Render($renderer);
9392
?>
9493

9594
<h2>HTML Merged Diff</h2>
9695
<?php
97-
// Generate an inline diff.
96+
// Generate an merged diff.
9897
$renderer = new Merged();
9998
echo $diff->isIdentical() ? 'No differences found.' : $diff->Render($renderer);
10099
?>
101100

102-
<h2>HTML Unified Diff</h2>
103-
<?php
104-
// Generate a unified diff.
105-
$renderer = new HtmlUnified($rendererOptions);
106-
echo $diff->isIdentical() ? 'No differences found.' : '<pre>' . $diff->Render($renderer) . '</pre>';
107-
?>
108-
109101
<h2>Text Unified Diff</h2>
110102
<?php
111103
// Generate a unified diff.
112-
$renderer = new Unified();
104+
$renderer = new TextUnified();
113105
echo $diff->isIdentical() ?
114106
'No differences found.' : '<pre>' . htmlspecialchars($diff->render($renderer)) . '</pre>';
115107
?>

example/styles.css

Lines changed: 7 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -88,23 +88,23 @@ pre {
8888
}
8989

9090
/*
91-
* HTML Inline Diff
91+
* HTML Unified Diff
9292
*/
93-
.DifferencesInline .ChangeReplace .Left,
94-
.DifferencesInline .ChangeDelete .Left {
93+
.DifferencesUnified .ChangeReplace .Left,
94+
.DifferencesUnified .ChangeDelete .Left {
9595
background: #FFDDDD;
9696
}
9797

98-
.DifferencesInline .ChangeReplace .Right,
99-
.DifferencesInline .ChangeInsert .Right {
98+
.DifferencesUnified .ChangeReplace .Right,
99+
.DifferencesUnified .ChangeInsert .Right {
100100
background: #DDFFDD;
101101
}
102102

103-
.DifferencesInline .ChangeReplace ins {
103+
.DifferencesUnified .ChangeReplace ins {
104104
background: #99EE99;
105105
}
106106

107-
.DifferencesInline .ChangeReplace del {
107+
.DifferencesUnified .ChangeReplace del {
108108
background: #EE9999;
109109
}
110110

@@ -132,63 +132,3 @@ pre {
132132
.DifferencesMerged th.ChangeDelete {
133133
background-image: linear-gradient(-45deg, #CCCCCC 0%, #EE9999 100%);
134134
}
135-
136-
/*
137-
* HTML Unified Diff
138-
*/
139-
140-
/* Line removed in new */
141-
.DifferencesUnified .ChangeDelete .Left::before {
142-
content: "- \00a0";
143-
}
144-
145-
.DifferencesUnified .ChangeDelete .Left {
146-
background: #CCCCCC;
147-
}
148-
149-
/* Line modified in old and new */
150-
.DifferencesUnified .ChangeReplace {
151-
display: table;
152-
background: #FFEE99;
153-
}
154-
155-
/* Line in old replaced by line in new */
156-
.DifferencesUnified .ChangeReplace .Left:first-child:before {
157-
content: "\250C \00a0";
158-
}
159-
160-
.DifferencesUnified .ChangeReplace .Left:before {
161-
content: "\251C \00a0";
162-
}
163-
164-
.DifferencesUnified .ChangeReplace .Left {
165-
background: #FFEE99;
166-
}
167-
168-
/* Line in new replaced line in old */
169-
.DifferencesUnified .ChangeReplace .Right:last-of-type:before {
170-
content: "\2514 \00a0";
171-
}
172-
173-
.DifferencesUnified .ChangeReplace .Right:before {
174-
content: "\251C \00a0";
175-
}
176-
177-
.DifferencesUnified .ChangeReplace .Right {
178-
background: #FFEE99;
179-
}
180-
181-
/* Line inserted in new */
182-
.DifferencesUnified .ChangeInsert .Right:before {
183-
content: "+ \00A0";
184-
}
185-
186-
/* Character inserted in line of new */
187-
.DifferencesUnified .ChangeReplace ins {
188-
background: #99EE99;
189-
}
190-
191-
/* Character removed from line in old */
192-
.DifferencesUnified .ChangeReplace del {
193-
background: #EE9999;
194-
}

lib/jblond/Diff.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,6 @@
55
namespace jblond;
66

77
use InvalidArgumentException;
8-
use jblond\Diff\Renderer\Html\Inline;
9-
use jblond\Diff\Renderer\Html\SideBySide;
10-
use jblond\Diff\Renderer\Html\Unified as UnifiedHtml;
11-
use jblond\Diff\Renderer\Text\Context;
12-
use jblond\Diff\Renderer\Text\Unified;
138
use jblond\Diff\SequenceMatcher;
149
use jblond\Diff\Similarity;
1510
use OutOfRangeException;
@@ -179,8 +174,7 @@ public function getVersion2(): array
179174
/**
180175
* Render a diff-view using a rendering class and get its results.
181176
*
182-
* @param object|Context|Unified|UnifiedHtml|Inline|SideBySide $renderer An instance of the rendering object,
183-
* used for generating the diff-view.
177+
* @param object $renderer An instance of the rendering object, used for generating the diff-view.
184178
*
185179
* @return mixed The generated diff-view. The type of the return value depends on the applied renderer.
186180
*/

0 commit comments

Comments
 (0)