Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9f88cf9

Browse files
committed
added some example code into the readme examples
1 parentdc5ecb8 commit9f88cf9

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

‎README.md‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,46 @@ These two outputs are generated using this java-diff-utils. The source code can
3030

3131
**Producing a one liner including all difference information.**
3232

33+
```Java
34+
//create a configured DiffRowGenerator
35+
DiffRowGenerator generator=DiffRowGenerator.create()
36+
.showInlineDiffs(true)
37+
.mergeOriginalRevised(true)
38+
.inlineDiffByWord(true)
39+
.oldTag(f->"~")//introduce markdown style for strikethrough
40+
.newTag(f->"**")//introduce markdown style for bold
41+
.build();
42+
43+
//compute the differences for two test texts.
44+
List<DiffRow> rows= generator.generateDiffRows(
45+
Arrays.asList("This is a test senctence."),
46+
Arrays.asList("This is a test for diffutils."));
47+
48+
System.out.println(rows.get(0).getOldLine());
49+
```
50+
3351
This is a test~senctence~**for diffutils**.
3452

3553
**Producing a side by side view of computed differences.**
3654

55+
```Java
56+
DiffRowGenerator generator=DiffRowGenerator.create()
57+
.showInlineDiffs(true)
58+
.inlineDiffByWord(true)
59+
.oldTag(f->"~")
60+
.newTag(f->"**")
61+
.build();
62+
List<DiffRow> rows= generator.generateDiffRows(
63+
Arrays.asList("This is a test senctence.","This is the second line.","And here is the finish."),
64+
Arrays.asList("This is a test for diffutils.","This is the second line."));
65+
66+
System.out.println("|original|new|");
67+
System.out.println("|--------|---|");
68+
for (DiffRow row: rows) {
69+
System.out.println("|"+ row.getOldLine()+"|"+ row.getNewLine()+"|");
70+
}
71+
```
72+
3773
|original|new|
3874
|--------|---|
3975
|This is a test~senctence~.|This is a test**for diffutils**.|

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp