Skip to content

Commit 137274a

Browse files
authored
Merge pull request #67 from JBlond/ignoreCase
Fix: Html SideBySide renders equal lines of version 1 at both sides.
2 parents 491d539 + ccfc465 commit 137274a

File tree

2 files changed

+56
-52
lines changed

2 files changed

+56
-52
lines changed

changelog.md

Lines changed: 36 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2,116 +2,117 @@
22

33
## next
44

5-
- Fix: Unified Cli renderer options incompatible with Main renderer options
6-
- Fix: Calculation of maxLineMarkerWidth independent of input format.
5+
- Add: Change log.
6+
- Fix: Html SideBySide renders equal lines of version 1 at both sides (Option ignoreCase).
77
- Fix: Second parameter of string repeat function minimizes to 0.
8-
- added change log
8+
- Fix: #60 - Unified Cli renderer options incompatible with Main renderer options
9+
- Fix: #64 - Calculation of maxLineMarkerWidth independent of input format.
910

1011
## 2.2.1 (2020-08-06)
1112

12-
- This release fixed #58 - Side by side diff shows empty diff
13+
- Fix: #58 - Side by side diff shows empty diff
1314

1415
## 2.2.0 (2020-07-23)
1516

16-
- adds an option for a custom override renderer. #53
17-
- add the feature to not have an output when there are not changes between the compared strings / files. #52 #54
17+
- Add: Option for a custom override renderer. #53
18+
- Add: No output when there are no differences between the compared strings / files. #52 #54
1819

1920
## 2.1.1 (2020-07-17)
2021

21-
- This release fixes #50 that equal text files produced an output, but shouldn't.
22+
- Fix: #50 - Renderers produce output with equal texts, while they shouldn't.
2223

2324
## 2.1.0 (2020-07-13)
2425

25-
- This release adds cli non colored output. This allows it to be piped.
26+
- Add: Cli uncolored output. This allows it to be piped.
2627

2728
## 2.0.0 (2020-07-09)
2829

29-
- This version mainly adds Unified Commandline colored output
30-
- using semantic versioning
30+
- Add: Unified Commandline colored output.
31+
- Change: switch to semantic versioning.
3132

3233
## 1.18 (2020-07-01)
3334

34-
- Added a dark theme to the example
35-
- Fix: Avoid variables with short names (some)
35+
- Add: A dark theme to the example.
36+
- Fix: Avoid variables with short names (some).
3637

3738
## 1.17 (2020-06-08)
3839

39-
- Bugfix release for #32
40+
- Fix #32 - Side by side diff shows only partially all deleted lines.
4041

4142
## 1.16 (2020-03-02)
4243

4344
- Features
44-
- Add trimEqual option
45+
- Add: option trimEqual.
4546

4647
- Fixes
4748
- Fix PHPMD Violation.
4849
- Code Optimization, cleanup, refactoring and commenting.
4950

5051
## 1.15 (2020-01-24)
5152

52-
- Added new Unified HTML
53-
- code clean up
53+
- Add: New Unified HTML.
54+
- Fix: Code clean up.
5455

5556
## 1.14 (2019-12-03)
5657

57-
- Removed some old dead code
58+
- Fix: Remove some old dead code.
5859

5960
## 1.13 (2019-10-08)
6061

61-
- switched to PSR12
62+
- Change: Switch to PSR12.
6263

6364
## 1.12 (2019-03-18)
6465

65-
- Update composer
66-
- PSR2 fixes
66+
- Change: Update Composer Configuration.
67+
- Fix: PSR-2 conventions.
6768

6869
## 1.11 (2019-02-22)
6970

70-
- code clean up
71-
- Corrected composer autoloader for unit tests
71+
- Fix: Code clean up.
72+
- Fix: Composer autoloader for unit tests.
7273

7374
## 1.10 (2019-02-20)
7475

75-
- code clean up
76+
- Fix: Code clean up.
7677

7778
## 1.9 (2019-02-19)
7879

79-
- code cleaning
80+
- Fix: Code clean up.
8081

8182
## 1.8
8283

83-
- Readme updates
84-
- unit test fixes
84+
- Change: Update Readme and bumping versions.
85+
- Fix: Moved include of Autoloader from the constructor to global space for HtmlArray unit test.
8586

8687
## 1.7
8788

88-
- PSR2 code alignment
89+
- Fix: PSR-2 code alignment.
8990

9091
## 1.6
9192

92-
- php-diff requires now PHP 7.1
93-
- Added return type hinting
93+
- Change: Bump required version of PHP to v7.1.
94+
- Add: Return type hinting.
9495

9596
## 1.5 (2019-01-15)
9697

97-
- Fixed some autoloader naming issues
98+
- Fix: Autoloader naming issues.
9899

99100
## 1.4 (2019-01-14)
100101

101-
- PSR4 namespace support added
102+
- Add: PSR-4 namespace support.
102103

103104
## 1.3 (2019-01-11)
104105

105-
- PHP methods contained too much logic. That has been simplified.
106+
- Fix: PHP methods contained too much logic. That has been simplified.
106107

107108
## 1.2 (2018-01-23)
108109

109-
- Added support for custom titles
110+
- Add: Support for custom titles.
110111

111112
## 1.1 (2017-05-06)
112113

113-
- Some fixes with chinese characters
114+
- Fix: Wrong highlight area for chinese characters.
114115

115116
## 1.0
116117

117-
- initial version
118+
- Initial version.

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

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@
1212
*
1313
* PHP version 7.2 or greater
1414
*
15-
* @package jblond\Diff\Renderer\Html
16-
* @author Chris Boulton <[email protected]>
17-
* @author Mario Brandt <[email protected]>
18-
* @author Ferry Cools <[email protected]>
15+
* @package jblond\Diff\Renderer\Html
16+
* @author Chris Boulton <[email protected]>
17+
* @author Mario Brandt <[email protected]>
18+
* @author Ferry Cools <[email protected]>
1919
* @copyright (c) 2009 Chris Boulton
20-
* @license New BSD License http://www.opensource.org/licenses/bsd-license.php
21-
* @version 2.2.1
22-
* @link https://github.com/JBlond/php-diff
20+
* @license New BSD License http://www.opensource.org/licenses/bsd-license.php
21+
* @version 2.2.1
22+
* @link https://github.com/JBlond/php-diff
2323
*/
2424
class SideBySide extends MainRenderer implements SubRendererInterface
2525
{
@@ -43,7 +43,7 @@ class SideBySide extends MainRenderer implements SubRendererInterface
4343
/**
4444
* SideBySide constructor.
4545
*
46-
* @param array $options Custom defined options for the inline diff renderer.
46+
* @param array $options Custom defined options for the inline diff renderer.
4747
*
4848
* @see Inline::$subOptions
4949
*/
@@ -103,27 +103,30 @@ public function generateSkippedLines(): string
103103
/**
104104
* Generate a string representation of table rows with lines without differences between both versions.
105105
*
106-
* @param array $changes Contains the op-codes about the changes between two blocks.
106+
* Note: Depending on the options, lines can be marked as being equal, while the contents actually differ.
107+
* (E.g. ignoreWhitespace and ignoreCase)
108+
*
109+
* @param array $changes Contains the op-codes about the changes between two blocks.
107110
*
108111
* @return string HTML code representing table rows showing text with no difference.
109112
*/
110113
public function generateLinesEqual(array $changes): string
111114
{
112115
$html = '';
113116

114-
foreach ($changes['base']['lines'] as $lineNo => $line) {
117+
foreach ($changes['base']['lines'] as $lineNo => $baseLine) {
115118
$fromLine = $changes['base']['offset'] + $lineNo + 1;
116119
$toLine = $changes['changed']['offset'] + $lineNo + 1;
117120

118121
$html .= <<<HTML
119122
<tr>
120123
<th>$fromLine</th>
121124
<td class="Left">
122-
<span>$line</span>
125+
<span>$baseLine</span>
123126
</td>
124127
<th>$toLine</th>
125128
<td class="Right">
126-
<span>$line</span>
129+
<span>{$changes['changed']['lines'][$lineNo]}</span>
127130
</td>
128131
</tr>
129132
HTML;
@@ -135,7 +138,7 @@ public function generateLinesEqual(array $changes): string
135138
/**
136139
* Generates a string representation of table rows with lines that are added to the 2nd version.
137140
*
138-
* @param array $changes Contains the op-codes about the changes between two blocks of text.
141+
* @param array $changes Contains the op-codes about the changes between two blocks of text.
139142
*
140143
* @return string HTML code representing table rows showing with added text.
141144
*/
@@ -164,7 +167,7 @@ public function generateLinesInsert(array $changes): string
164167
/**
165168
* Generates a string representation of table rows with lines that are removed from the 2nd version.
166169
*
167-
* @param array $changes Contains the op-codes about the changes between two blocks of text.
170+
* @param array $changes Contains the op-codes about the changes between two blocks of text.
168171
*
169172
* @return string HTML code representing table rows showing removed text.
170173
*/
@@ -193,7 +196,7 @@ public function generateLinesDelete(array $changes): string
193196
/**
194197
* Generates a string representation of table rows with lines that are partially modified.
195198
*
196-
* @param array $changes Contains the op-codes about the changes between two blocks of text.
199+
* @param array $changes Contains the op-codes about the changes between two blocks of text.
197200
*
198201
* @return string Html code representing table rows showing modified text.
199202
*/
@@ -264,7 +267,7 @@ public function generateLinesReplace(array $changes): string
264267
/**
265268
* Generate a string representation of the start of a block.
266269
*
267-
* @param array $changes Contains the op-codes about the changes between two blocks of text.
270+
* @param array $changes Contains the op-codes about the changes between two blocks of text.
268271
*
269272
* @return string Start of the diff view.
270273
*/
@@ -276,7 +279,7 @@ public function generateBlockHeader(array $changes): string
276279
/**
277280
* Generate a string representation of the end of a block.
278281
*
279-
* @param array $changes Contains the op-codes about the changes between two blocks of text.
282+
* @param array $changes Contains the op-codes about the changes between two blocks of text.
280283
*
281284
* @return string End of the block.
282285
*/

0 commit comments

Comments
 (0)