Coder Social home page Coder Social logo

A new state "replace" about jsdiff HOT 4 CLOSED

jactive avatar jactive commented on August 17, 2024
A new state "replace"

from jsdiff.

Comments (4)

kpdecker avatar kpdecker commented on August 17, 2024

Could you provide some details on what this would do? I'm not sure how this concept to integrate with unified diffs, etc.

from jsdiff.

jactive avatar jactive commented on August 17, 2024

Thanks for your concern.
The output of jsdiff includes removed, added and unchanged state to describe the kinds of change in the text. For example, original text: aab, new text: aac. In diffChars mode, jsdiff will return [{value: "aa"}, {value: "b", remove: true}, {value: "c", added: true}]. In general purpose, it is good enough. But I want the result to be more useful. I want to know that the b in the original text "aab" is replaced with c in the new text "aac".

If it is not clear enough, the output of myersdiff.py maybe helpful. Take the previous example. The outputs of myersdiff.py are [('equal', 0, 2, 0, 2), ('replace', 2, 3, 2, 3)]. To print this result, please download the python file by the link in my first post. Paste the two line codes below at the bottom of the file myersdiff.py. Please make sure there is no leading space in the two additional line.

differ = MyersDiffer("aab", "aac")
print list(differ.get_opcodes())

from jsdiff.

vmariano avatar vmariano commented on August 17, 2024

👍
I'm looking for something like that.
A working example of this could be: http://cemerick.github.io/jsdifflib/demo.html

from jsdiff.

giorgio79 avatar giorgio79 commented on August 17, 2024

Wonder why closed? :)

from jsdiff.

Related Issues (20)

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.