angular-diff-match-patch icon indicating copy to clipboard operation
angular-diff-match-patch copied to clipboard

compare whole word instead of letter

Open gonbad opened this issue 8 years ago • 3 comments

Is there any configuration so that if two word differ in a single letter or more, red the whole old one and green the whole new one? for example: hey dad! how are you? hey lad! how are you? diff: hey dad lad! how are you?

gonbad avatar Jul 19 '17 11:07 gonbad

I mean word-by-word comparison

gonbad avatar Jul 19 '17 12:07 gonbad

It should be possible as https://code.google.com/archive/p/google-diff-match-patch/wikis/LineOrWordDiffs.wiki describes an approach, however, currently there's not a way to do that with the library.

amweiss avatar Jul 19 '17 20:07 amweiss

As the google diff algorithm is character based, so is there output. IMO you have 2 options. One is to reconfigure the google diff library to get a word based diff output (like @amweiss said). Or you use a different diff library, that outputs the real unfied diff format (not googles variant). In both case you will need a different angular module, as this supports only the default google-diff-match-patch output.

Sorry for necroing the thread, but I am currently looking for angular modules to view the google-diff-match-patch output and thought I could pitch in.

Tagman avatar Apr 12 '21 12:04 Tagman