Skip to content

Commit 6e97b8a

Browse files
committed
Update output example in readme
Signed-off-by: Jack Cherng <[email protected]>
1 parent 80db0a0 commit 6e97b8a

File tree

5 files changed

+267
-115
lines changed

5 files changed

+267
-115
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ vendor/
1111
# tmp files
1212
/var/*
1313
!/var/.gitkeep
14+
/branch-*

README.md

Lines changed: 184 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,6 @@ $result = $diff->render($renderer);
9090
# Rendered Results
9191

9292

93-
## UTF-8 Ready
94-
95-
![UTF-8 Ready](https://raw.githubusercontent.com/jfcherng/php-diff/gh-pages/images/utf-8-ready.png)
96-
97-
9893
## HTML Diff In-line Detail Rendering
9994

10095
<table>
@@ -130,62 +125,200 @@ $result = $diff->render($renderer);
130125
## Unified
131126

132127
```diff
133-
@@ -1,13 +1,14 @@
134-
<html>
135-
<head>
136-
<meta http-equiv="Content-type" content="text/html; charset=utf-8"/>
137-
- <title>Hello World!</title>
138-
+ <title>Goodbye Cruel World!</title>
139-
</head>
140-
<body>
141-
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
142-
143-
- <h2>A heading we'll be removing</h2>
144-
145-
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
146-
+
147-
+ <p>Just a small amount of new text...</p>
148-
</body>
149-
</html>
128+
@@ -1,3 +1,4 @@
129+
-<p>Hello World!</p>
130+
+<div>Hello World!</div>
131+
~~~~~~~~~~~~~~~~~~~
132+
+Let's add a new line here.
133+
X
134+
@@ -7,6 +8,5 @@
135+
N
136+
-Do you know in Chinese, "金槍魚罐頭" means tuna can.
137+
+Do you know in Japanese, "魚の缶詰" means fish can.
138+
This is just a useless line.
139+
G
140+
-// @todo Remember to delete this line
141+
Say hello to my neighbors.
150142
```
151143

152144

153145
## Context
154146

155147
```
156148
***************
157-
*** 1,13 ****
158-
<html>
159-
<head>
160-
<meta http-equiv="Content-type" content="text/html; charset=utf-8"/>
161-
! <title>Hello World!</title>
162-
</head>
163-
<body>
164-
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
165-
166-
- <h2>A heading we'll be removing</h2>
167-
168-
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
169-
</body>
170-
</html>
171-
--- 1,14 ----
172-
<html>
173-
<head>
174-
<meta http-equiv="Content-type" content="text/html; charset=utf-8"/>
175-
! <title>Goodbye Cruel World!</title>
176-
</head>
177-
<body>
178-
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
179-
180-
181-
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
182-
+
183-
+ <p>Just a small amount of new text...</p>
184-
</body>
185-
</html>
149+
*** 1,3 ****
150+
! <p>Hello World!</p>
151+
~~~~~~~~~~~~~~~~~~~
152+
X
153+
--- 1,4 ----
154+
! <div>Hello World!</div>
155+
~~~~~~~~~~~~~~~~~~~
156+
+ Let's add a new line here.
157+
X
158+
***************
159+
*** 7,12 ****
160+
N
161+
! Do you know in Chinese, "金槍魚罐頭" means tuna can.
162+
This is just a useless line.
163+
G
164+
- // @todo Remember to delete this line
165+
Say hello to my neighbors.
166+
--- 8,12 ----
167+
N
168+
! Do you know in Japanese, "魚の缶詰" means fish can.
169+
This is just a useless line.
170+
G
171+
Say hello to my neighbors.
186172
```
187173

188174

175+
## JSON
176+
177+
<details><summary>Click to expand the result</summary>
178+
179+
```javascript
180+
[
181+
[
182+
{
183+
"tag": "rep",
184+
"base": {
185+
"offset": 0,
186+
"lines": [
187+
"&lt;<del>p&gt;Hello World!&lt;/p</del>&gt;"
188+
]
189+
},
190+
"changed": {
191+
"offset": 0,
192+
"lines": [
193+
"&lt;<ins>div&gt;Hello World!&lt;/div</ins>&gt;"
194+
]
195+
}
196+
},
197+
{
198+
"tag": "eq",
199+
"base": {
200+
"offset": 1,
201+
"lines": [
202+
"~~~~~~~~~~~~~~~~~~~"
203+
]
204+
},
205+
"changed": {
206+
"offset": 1,
207+
"lines": [
208+
"~~~~~~~~~~~~~~~~~~~"
209+
]
210+
}
211+
},
212+
{
213+
"tag": "ins",
214+
"base": {
215+
"offset": 2,
216+
"lines": []
217+
},
218+
"changed": {
219+
"offset": 2,
220+
"lines": [
221+
"Let's add a new line here."
222+
]
223+
}
224+
},
225+
{
226+
"tag": "eq",
227+
"base": {
228+
"offset": 2,
229+
"lines": [
230+
"X"
231+
]
232+
},
233+
"changed": {
234+
"offset": 3,
235+
"lines": [
236+
"X"
237+
]
238+
}
239+
}
240+
],
241+
[
242+
{
243+
"tag": "eq",
244+
"base": {
245+
"offset": 6,
246+
"lines": [
247+
"N"
248+
]
249+
},
250+
"changed": {
251+
"offset": 7,
252+
"lines": [
253+
"N"
254+
]
255+
}
256+
},
257+
{
258+
"tag": "rep",
259+
"base": {
260+
"offset": 7,
261+
"lines": [
262+
"Do you know in <del>Chinese, \"金槍魚罐頭\" means tuna</del> can."
263+
]
264+
},
265+
"changed": {
266+
"offset": 8,
267+
"lines": [
268+
"Do you know in <ins>Japanese, \"魚の缶詰\" means fish</ins> can."
269+
]
270+
}
271+
},
272+
{
273+
"tag": "eq",
274+
"base": {
275+
"offset": 8,
276+
"lines": [
277+
"This is just a useless line.",
278+
"G"
279+
]
280+
},
281+
"changed": {
282+
"offset": 9,
283+
"lines": [
284+
"This is just a useless line.",
285+
"G"
286+
]
287+
}
288+
},
289+
{
290+
"tag": "del",
291+
"base": {
292+
"offset": 10,
293+
"lines": [
294+
"// @todo Remember to delete this line"
295+
]
296+
},
297+
"changed": {
298+
"offset": 11,
299+
"lines": []
300+
}
301+
},
302+
{
303+
"tag": "eq",
304+
"base": {
305+
"offset": 11,
306+
"lines": [
307+
"Say hello to my neighbors."
308+
]
309+
},
310+
"changed": {
311+
"offset": 11,
312+
"lines": [
313+
"Say hello to my neighbors."
314+
]
315+
}
316+
}
317+
]
318+
]
319+
```
320+
</details>
321+
189322
# Upgrading
190323

191324

0 commit comments

Comments
 (0)