Cleanup shifts edits to word boundaries: the raw diff on the left splits words, the cleaned up diff on the right edits whole words.
()
| 119 | // Cleanup shifts edits to word boundaries: the raw diff on the left |
| 120 | // splits words, the cleaned up diff on the right edits whole words. |
| 121 | func ExampleDiffMatchPatch_DiffCleanupSemantic() { |
| 122 | dmp := diffmatchpatch.New() |
| 123 | |
| 124 | diffs := dmp.DiffMain("and one two.", "and one one.", false) |
| 125 | |
| 126 | for _, diff := range diffs { |
| 127 | fmt.Printf("%s %q\n", diff.Type, diff.Text) |
| 128 | } |
| 129 | fmt.Println("---") |
| 130 | for _, diff := range dmp.DiffCleanupSemantic(diffs) { |
| 131 | fmt.Printf("%s %q\n", diff.Type, diff.Text) |
| 132 | } |
| 133 | |
| 134 | // Output: |
| 135 | // Equal "and one " |
| 136 | // Delete "tw" |
| 137 | // Equal "o" |
| 138 | // Insert "ne" |
| 139 | // Equal "." |
| 140 | // --- |
| 141 | // Equal "and one " |
| 142 | // Delete "two" |
| 143 | // Insert "one" |
| 144 | // Equal "." |
| 145 | } |
nothing calls this directly
no test coverage detected