Giter VIP home page Giter VIP logo

diff-match-patch's Issues

patch_toText, unified diff like output

The docs says this method should create something that looks like a unified diff. When I try it I just get "[object ...]" blah blah output. Looking at the actual source code for the method, it doesn't do much, it simply tries to output some of the objects in the diff. Here's the actual source code:

/**
 * Take a list of patches and return a textual representation.
 * @param {!Array.<!diff_match_patch.patch_obj>} patches Array of Patch objects.
 * @return {string} Text representation of patches.
 */
diff_match_patch.prototype.patch_toText = function(patches) {
  var text = [];
  for (var x = 0; x < patches.length; x++) {
    text[x] = patches[x];
  }
  return text.join('');
};

So patches[x] is a javascript object, and the text.join method just creates these faulty "object" strings. I can't find any code that does anything like the comments in the source code mentions. So I guess either we need some more code or the docs should be updated and mark this method as faulty.

API messed up 1.0.0 -> 1.0.3

1.0.0 worked.
In 1.0.3, the API is somehow messed up. The test harness does not detect it.

// that's what it should be but is not:
var a = [[DIFF_EQUAL, 'ab'], [DIFF_INSERT, '123'], [DIFF_EQUAL, 'c']]
var b = dmp.diff_main('abc', 'ab123c', false)
// Instead it's a strange object
console.log(b)
[ { '0': 0, '1': 'ab' },
  { '0': 1, '1': '123' },
  { '0': 0, '1': 'c' } ]
console.log(Array.isArray(a[0])) // true
console.log(Array.isArray(b[0])) // false
console.log(b)
assertEquivalent(a, b); // yes, equivalent

And it breaks ES6 clients:

const [eq, str] = a[0]  // works
const [eq, str] = b[0]  // breaks

How to compare multi-line diff

demand:
I want to match based on the number of rows. According to the basis of each line, get the detailed information about deleting/adding/modifying each line

The data information view is as follows:
image

Can't instantiate DiffMatchPatch

Hello, I can't use the object DiffMatchPatch. Here is my code

import {Component, Input, OnInit} from '@angular/core';
import {ActService} from "../../../../services/act.service";
import {DialogService} from "../../../../dialog-service/dialog.service";
import {Router} from "@angular/router";
import { Observable } from 'rxjs/Observable';
import 'rxjs/add/observable/forkJoin';
import DiffMatchPatch from 'diff-match-patch';
const dmp = new DiffMatchPatch();

@component({
selector: 'act-step-content-validation',
templateUrl: './act-step-content-validation.component.html',
styleUrls: ['./act-step-content-validation.component.css']
})
export class ActStepContentValidationComponent implements OnInit {

@input() metadata;
public loading: boolean = false;
public previewModifications;
public previewImport;

constructor(private actService: ActService,
private dialogService: DialogService) {
}

ngOnInit() {

this.loading = true;
this.actId = this.metadata.id;

Observable.forkJoin([
  this.actService.getWorkingActPreview(this.metadata.id.value, "10-10-2018"),
  this.actService.getImportedActPreview(this.metadata.id.value)
])
  .subscribe(([wP, iP]) => {
  this.previewModifications = wP;
  this.previewImport = iP;
    dmp.Diff_Timeout = 0;
    let diffOutput = dmp.diff_main(this.previewModifications, this.previewImport, false);
    console.log(diffOutput);
  });

}

Here is the error : image

What's wrong ? thank you

Documentation/Examples

Hi, when I try to access to https://code.google.com/p/google-diff-match-patch/wiki/API I get this:

SVN hosting has been permanently disabled.

Where can I find the documentation?

Thanks

Uncaught ReferenceError: module is not defined

We have been receiving the following error:
index.js:2214 Uncaught ReferenceError: module is not defined at index.js:2214:1

Steps to replicate:

  • run npm install diff-match-patch
  • import index.js in the main app '/node_modules/diff-match-patch/index.js', which is added to the plain <script type="text/javascript" charset="UTF-8" src="http://localhost:1962/node_modules/diff-match-patch/index.js"></script>

Wrong license on npm

The version released on npm as 1.0.0 has http://www.apache.org/licenses/LICENSE-2.0 in the license field, which has been fixed in master ("Apache-2.0")

This means that tools for automated license verification of dependencies fail on this package, as they can't recognise the exact license used.

Could you release a new version in npm with the contents of master?

Library throws "URI malformed" error when creating patch with emojis

The following code:

const DiffMatchPatch = require('diff-match-patch');
const dmp = new DiffMatchPatch();

const patchText = dmp.patch_toText(dmp.patch_make('', 'πŸ‘¨β€πŸ¦° πŸ‘¨πŸΏβ€πŸ¦° πŸ‘¨β€πŸ¦± πŸ‘¨πŸΏβ€πŸ¦± πŸ¦ΉπŸΏβ€β™‚οΈ'));
const patchObj = dmp.patch_fromText(patchText);
const [patchedText] = dmp.patch_apply(patchObj, '');
dmp.patch_toText(dmp.patch_make(patchedText, 'πŸ‘Ύ πŸ™‡ πŸ’ πŸ™… πŸ™† πŸ™‹ πŸ™Ž πŸ™'));

Will throw an error "URI Malformed" at this line. That's often the problem when using encodeURI on arbitrary data (the md5 package has the same problem) but in that case as far as I can see the inputs are valid UTF-8.

I think either patch_make or patch_apply generates invalid text.

But also I'm wondering why is encodeURI needed in this lib? Wouldn't a simple escape/unescape of specific reserved characters be enough?

Update to newest Google version

Thanks for packaging for node.
It appears that Google has migrated their repo to github and have been making updates. Can you please update this to match the latest version?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.