Skip to content

Commit f52675f

Browse files
authored
Update README.md
1 parent c844b90 commit f52675f

File tree

1 file changed

+5
-137
lines changed

1 file changed

+5
-137
lines changed

README.md

Lines changed: 5 additions & 137 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,11 @@
1-
# ABAP Differ
1+
# ABAP Diff3
22

3-
Collection of diff libraries to highlight the content difference between two HTML strings (htmldiff) or between two or three string-tables (diff3).
3+
Library to highlight the content difference between two or three string-tables (diff3).
44

55
Made by [Marc Bernard Tools](https://marcbernardtools.com/) giving back to the [SAP Community](https://community.sap.com/)
66

77
NO WARRANTIES, [MIT License](LICENSE)
88

9-
## HTML Diff
10-
11-
This is a diffing library that understands HTML. Best suited for cases when you want to show a diff of user-generated HTML.
12-
13-
- The implementation is a port of JavaScript (https://github.com/alaorneto/htmldiffer, no license defined)
14-
- which is a port of CoffeeScript (https://github.com/tnwinc/htmldiff.js, MIT license)
15-
- which is a port of the original Ruby (https://github.com/myobie/htmldiff, MIT license)
16-
17-
An enhancement was made so the code can also produce the diff of two texts (tags are treated like text).
18-
199
## Diff3 Utils
2010

2111
This is a library to find differences between two string tables, generate and apply patches, and perform 3-way merging between an original and two changed string tables. It contains similar functionality to the [GNU Diffutils](https://www.gnu.org/software/diffutils/manual/diffutils.html) tools.
@@ -28,133 +18,11 @@ SAP Basis 7.4 or higher
2818

2919
## Installation
3020

31-
You can install ABAP Differ using [abapGit](https://github.com/abapGit/abapGit) either creating a new online repository for https://github.com/Marc-Bernard-Tools/ABAP-Differ or downloading the repository [ZIP file](https://github.com/Marc-Bernard-Tools/ABAP-Differ/archive/main.zip) and creating a new offline repository.
32-
33-
We recommend using package `$ABAPDIFF`.
34-
35-
## Usage: HTML Diff
36-
37-
**Diffing HTML**
38-
39-
The following produces the diff of two example HTML snippets:
40-
41-
```abap
42-
DATA:
43-
lv_original TYPE string,
44-
lv_modified TYPE string,
45-
lv_diff TYPE string,
46-
li_htmldiff TYPE REF TO zif_htmldiff.
47-
48-
lv_original = '\n'
49-
&& ' <p>First paragraph.</p>\n'
50-
&& ' <ul>\n'
51-
&& ' <li>Item A</li>\n'
52-
&& ' <li>Item B</li>\n'
53-
&& ' <li>Item C</li>\n'
54-
&& ' </ul>\n'
55-
&& ' <img src="previous.jpg">\n'
56-
&& ' <span>This is some interesting text.</span>\n'.
57-
58-
lv_modified = '\n'
59-
&& ' <p>First paragraph.</p>\n'
60-
&& ' <ul>\n'
61-
&& ' <li>Item A</li>\n'
62-
&& ' <li>Item B</li>\n'
63-
&& ' <li>Item D</li>\n'
64-
&& ' </ul>\n'
65-
&& ' <img src="next.jpg">\n'
66-
&& ' <span>This is some new text.</span>\n'.
67-
68-
REPLACE ALL OCCURRENCES OF '\n' IN lv_original WITH cl_abap_char_utilities=>newline.
69-
REPLACE ALL OCCURRENCES OF '\n' IN lv_modified WITH cl_abap_char_utilities=>newline.
70-
71-
CREATE OBJECT li_differ TYPE zcl_htmldiff.
72-
73-
lv_diff = li_htmldiff->htmldiff(
74-
iv_before = lv_original
75-
iv_after = lv_modified
76-
iv_with_img = abap_false ).
77-
```
78-
79-
Result:
80-
81-
```html
82-
<p>First paragraph.</p>
83-
<ul>
84-
<li>Item A</li>
85-
<li>Item B</li>
86-
<li>Item <del>C</del><ins>D</ins></li>
87-
</ul>
88-
<img src='previous.jpg'><img src='next.jpg'>
89-
<span>This is some <del>interesting</del><ins>new</ins> text.</span>
90-
```
91-
92-
By setting the image parameter to true, you can also mark changed images as deletions or insertions:
93-
94-
```abap
95-
lv_diff = li_htmldiff->htmldiff(
96-
iv_before = lv_original
97-
iv_after = lv_modified
98-
iv_with_img = abap_true ).
99-
```
100-
101-
Result:
102-
103-
```html
104-
<p>First paragraph.</p>
105-
<ul>
106-
<li>Item A</li>
107-
<li>Item B</li>
108-
<li>Item <del>C</del><ins>D</ins></li>
109-
</ul>
110-
<del><img src='previous.jpg'></del><ins><img src='next.jpg'></ins>
111-
<span>This is some <del>interesting</del><ins>new</ins> text.</span>
112-
```
113-
114-
There are a few other options you can set in the `constructor`:
115-
116-
- `iv_inserts`: Show `<ins>` tags (default: on)
117-
- `iv_deletes`: Show `<del>` tags (default: on)
118-
- `iv_css_classes`: Add CSS classes to `<ins>` and `<del>` tags (default: off)
119-
- `iv_support_chinese`: Treat Chinese characters as individual words (default: off)
120-
121-
Using CSS classes, the result will distinguish between inserts (class `diffins`), deletes (class `diffdel`), and updates (class `diffmod`).
122-
123-
See the [test classes](https://github.com/Marc-Bernard-Tools/ABAP-Differ/blob/main/src/zcl_htmldiff.clas.testclasses.abap) for more examples.
124-
125-
**Diffing Text**
126-
127-
todo
128-
129-
```abap
130-
lv_diff = li_htmldiff->textdiff(
131-
iv_before = lv_original
132-
iv_after = lv_modified ).
133-
```
134-
135-
**Styling**
136-
137-
Here's an examle for styling the insertions and deletions using CSS.
138-
139-
```css
140-
/* CSS for <ins> and <del> tags */
141-
ins { background-color: #ddffdd; }
142-
ins img { border-color: #ddffdd; }
143-
144-
del { background-color: #ffdddd; }
145-
del img { border-color: #ffdddd; }
146-
```
147-
148-
With the CSS class option, use the following:
21+
You can install ABAP Diff3 using [abapGit](https://github.com/abapGit/abapGit) either creating a new online repository for https://github.com/Marc-Bernard-Tools/ABAP-Diff3 or downloading the repository [ZIP file](https://github.com/Marc-Bernard-Tools/ABAP-Diff3/archive/main.zip) and creating a new offline repository.
14922

150-
```css
151-
/* CSS for insert, delete, and modify classes */
152-
.diffins { background-color: #ddffdd; }
153-
.diffdel { background-color: #ffdddd; }
154-
.diffmod { background-color: #ffffdd; }
155-
```
23+
We recommend using package `$ABAPDIFF3`.
15624

157-
## Usage: Diff3
25+
## Usage
15826

15927
todo
16028

0 commit comments

Comments
 (0)