Skip to content

Commit 01884cd

Browse files
authored
README: Add rendering to HTML info.
1 parent 193585b commit 01884cd

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,31 @@ echo 'Changed lines: ';
4545
echo implode(', ', $diff->getChangedLines());
4646
```
4747

48+
Display the Diff in HTML
49+
------------------------
50+
51+
Very often we need to display the differences directly in the browser, for this the native method `renderDiff()` is suitable.
52+
53+
```php
54+
$left = 'First text';
55+
$right = 'Second text';
56+
57+
$simpleDiff = new \Baraja\DiffGenerator\SimpleDiff;
58+
$diff = $![image](https://user-images.githubusercontent.com/4738758/113039971-8eb1b700-9198-11eb-9960-544be342d9ff.png)
59+
![image](https://user-images.githubusercontent.com/4738758/113039973-8eb1b700-9198-11eb-895f-805ea0ec470e.png)
60+
![image](https://user-images.githubusercontent.com/4738758/113039976-8f4a4d80-9198-11eb-928a-4b5d2b4f4533.png)
61+
![image](https://user-images.githubusercontent.com/4738758/113039981-8fe2e400-9198-11eb-8d95-9bcd258fc81b.png)
62+
![image](https://user-images.githubusercontent.com/4738758/113039978-8f4a4d80-9198-11eb-96e7-695ade2fd592.png)
63+
![image](https://user-images.githubusercontent.com/4738758/113039983-8fe2e400-9198-11eb-8bcd-821aae346cb0.png)
64+
![image](https://user-images.githubusercontent.com/4738758/113039982-8fe2e400-9198-11eb-8c32-0fd1c57d97d8.png)
65+
![image](https://user-images.githubusercontent.com/4738758/113039987-92453e00-9198-11eb-8da0-3208d0fd6816.png)
66+
simpleDiff->compare($left, $right);
67+
68+
echo $simpleDiff->renderDiff($diff);
69+
```
70+
71+
The method accepts Diff and returns valid treated HTML that can be displayed directly to the user.
72+
4873
Comparison mode
4974
---------------
5075

0 commit comments

Comments
 (0)