Questions tagged [google-diff-match-patch]

Diff, Match and Patch libraries for Plain Text

The Diff Match and Patch libraries offer robust algorithms to perform the operations required for synchronizing plain text.

  1. Diff:
    • Compare two blocks of plain text and efficiently return a list of differences.
    • Diff Demo
  2. Match:
    • Given a search string, find its best fuzzy match in a block of plain text. Weighted for both accuracy and location.
    • Match Demo
  3. Patch:
    • Apply a list of patches onto plain text. Use best-effort to apply patch even when the underlying text doesn't match.
    • Patch Demo

Currently available in Java, JavaScript, Dart, C++, C#, Objective C, Lua and Python. Regardless of language, each library features the same API and the same functionality. All versions also have comprehensive test harnesses.

40 questions
16
votes
1 answer

How to make Google Diff Match Patch prefer changes at the end of a string?

I am using the diff_main method of Google's DiffMatchPatch library to get diffs which I then use in my app. Consider this case: Old string: Tracker.Dependency.prototype.changed = function () { for (var id in this._dependentsById) …
Jakub Hampl
  • 39,863
  • 10
  • 77
  • 106
5
votes
0 answers

Google's diff-match-patch for concurrent update

So, I've got a google docs type feature in my app which can be edited by multiple users concurrently. Diff-match-patch works fine for me when only one user updates the doc. But it generates wrong data when let's say the doc is already updated by…
Rahul
  • 863
  • 6
  • 23
4
votes
2 answers

Using google-diff-match-patch in angular

I'd like to use the google diff/match/patch lib in an angular app to show the difference between two texts. My usage would be something like this: public ContentHtml: SafeHtml; compare(text1: string, text2: string):void { var dmp = new…
Sam
  • 28,421
  • 49
  • 167
  • 247
4
votes
0 answers

Can diff_match_patch create unified diff string for diff2html?

Can diff_match_patch be used to create a unified diff string that can be used in diff2html?
MaxP
  • 325
  • 2
  • 14
4
votes
0 answers

Parsing DiffPlex Result

I want to use DiffPlex library to find the difference between 2 strings. I've tried Google Diff Match Patch but the result is a it difficult to parse and requires me to look at characters at a time. I got it working but was wondering if it could be…
3
votes
1 answer

Java : Getting effected sentence in Google-diff-match-patch

I am working on a Java application in which I would like to compare 2 paragraphs and get the sentences which are different in the 2 Strings to be compared. Now I am able to get what is inserted and what is deleted. The problem I am facing is, I…
We are Borg
  • 5,117
  • 17
  • 102
  • 225
2
votes
1 answer

Google DiffMatchPatch to NodeView

I been struggling for some time with a XmlComparsion functionality. I have to compare two Xml for differences and then display them in a TreeView way. I've done some research and found out Google Diff Match Patch library that looks exactly what I…
CiucaS
  • 2,010
  • 5
  • 36
  • 63
2
votes
0 answers

How to merge two texts given the common base version of both texts?

Similar to how git merge two branches but: using python instead of two branches we have text1 and text2 instead of common commit we have text0 - previous version of both text1 and text2 diff-match-patch probably can be used to accomplish this…
aiven
  • 3,775
  • 3
  • 27
  • 52
2
votes
1 answer

diff text documents but ignore single character differences? Set a minimum edit distance filter?

I have two versions of a large book in txt format and I'd like to compare them to find significant changes between the versions, ignoring small single character differences. There are lots of diffing tools that can ignore whitespace differences, but…
2
votes
0 answers

Java : Word Diff in sentences using Google-diff-match-patch

Am using google-diff-match-patch for comparing 2 strings for Difference. It works fine for most part, except if the first Character in a word is the same. For Ex: Text1 = CHICAGO IL Text2 = COLUMBUS OH Output: deltas: [Diff(EQUAL,"C"),…
Ben
  • 195
  • 2
  • 10
2
votes
1 answer

Google diff-match-patch : How to unpatch to get Original String?

I am using Google diff-match-patch JAVA plugin to create patch between two JSON strings and storing the patch to database. diff_match_patch dmp = new diff_match_patch(); LinkedList diffs = dmp.patch_make(latestString,…
VishwaKumar
  • 3,433
  • 8
  • 44
  • 72
2
votes
1 answer

Compile errors with one project only after adding a second project

I have a solution in VS2012 that compiles fine. I wanted to write some unit tests for it and found WinUnit. For ease, I pulled the WinUnit test project into my solution. I stripped out their sample file, and began to reference my copy of Google's…
1
vote
1 answer

How to Implement Word Level in google / diff-match-patch C#

I am trying to implement word level matches in Google Diff Match Patch, but it is beating me up. The result I get is: =I've never been =|-a-|=t=|= th=|-e-|=se places=| =I've never been =|=t=|+o+|= th=|+o+|=se places=| The result I want is: …
Alex Russell
  • 189
  • 1
  • 10
1
vote
0 answers

Uncaught TypeError: Cannot set property 'diff_match_patch' of undefined, vue.js, diff-match-patch, veu-diff-match-patch

this my first post. I'm pretty desperate. I'm trying to build an app based von vuejs, vuetify and vue-diff-patch-match. vue-diff-match-patch. I'm not a coder but a MD. I'm trying to build a text generating tool for ER patients so we can speed up our…
1
vote
1 answer

Get first row and column of diff using Google Diff Match Patch?

I'm following the example at https://github.com/google/diff-match-patch and var text = "
\nHello world\n
"; var text2 = "
\nHello whirld\n
"; var dmp = new diff_match_patch(); var result =…
1.21 gigawatts
  • 16,517
  • 32
  • 123
  • 231
1
2 3