amweiss / angular-diff-match-patch

An AngularJS wrapper for google-diff-match-patch
https://amweiss.github.io/angular-diff-match-patch/
MIT License
138 stars 34 forks source link

compare whole word instead of letter #45

Open gonbad opened 7 years ago

gonbad commented 7 years ago

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 commented 7 years ago

I mean word-by-word comparison

amweiss commented 7 years ago

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.

Tagman commented 3 years ago

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.