You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+5-137Lines changed: 5 additions & 137 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,21 +1,11 @@
1
-
# ABAP Differ
1
+
# ABAP Diff3
2
2
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).
4
4
5
5
Made by [Marc Bernard Tools](https://marcbernardtools.com/) giving back to the [SAP Community](https://community.sap.com/)
6
6
7
7
NO WARRANTIES, [MIT License](LICENSE)
8
8
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
-
19
9
## Diff3 Utils
20
10
21
11
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
28
18
29
19
## Installation
30
20
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
-
<imgsrc='previous.jpg'><imgsrc='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:
<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
-
insimg { border-color: #ddffdd; }
143
-
144
-
del { background-color: #ffdddd; }
145
-
delimg { 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.
0 commit comments