sergi / go-diff

Diff, match and patch text in Go
MIT License
1.81k stars 207 forks source link

how to only show different part? #118

Open LoRexxar opened 3 years ago

LoRexxar commented 3 years ago

just like

image

chenyahui commented 3 years ago

just like

image

You can filter out the DiffEqual items of item before pass the diffs to DiffPrettyHtml or DiffPrettyText. just like this:

    var newDiffs []diffmatchpatch.Diff
    for _, item := range diffs {
        if item.Type != diffmatchpatch.DiffEqual {
            newDiffs = append(newDiffs, item)
        }
    }
LoRexxar commented 3 years ago

I think it’s best to select the display content by adding parameters, this can only be a temporary solution