Giter Site home page Giter Site logo

jsdifflib's Issues

Feature add: Line numbers from git diff

If you have something like
@@ -130,18 +130,22 @@ class PostModel:

It would be great in view you can get real line numbers. Otherwise this is working great.

WHY THE FOLLOWING CODEING COULDN'T PASS THE EXAM ON https://oj.bnuz.edu.cn/problemset/7/problem/592,BUT OK ON dev c++

WHAT IS WRONG? I KNOW THE PROGRAM IS FROM HERE, SO I MUST GET THE ANSWER FROM HERE. THIS KIND OF THING IS ALWAYS HAPPENED ON ME.

#include<stdio.h>
int main(){
int n;
scanf("%d",&n);
for(int i = 1;i <= n+1;i ++){
for(int j = 1;j <=2 * n+1;j ++){
if(j == n + i || j == n -i + 2){
printf("");
}
else{
printf(".");
}
}
printf("\n");
}
for(int i = n;i >= 1;i --){
for(int j = 2 * n+1;j >=1;j--){
if(j == n + i || j == n -i + 2){
printf("
");
}
else{
printf(".");
}
}
printf("\n");
}
}

Indentation problem

$$div.appendChild(diffview.buildView({
baseTextLines: base,
newTextLines: newtxt,
opcodes: opcodes,
// set the display titles for each resource
baseTextName: "Old version",
newTextName: "New version",
contextSize: 12,
viewType: 0
}));

baseTextLines and newTextLines has white spaces and well indented. But when it prints the value of base text and new text to the screen, they are not indented. What can be the problem?

README incorrect - "latter" should be "former"

The Python Interoperability section says:

So, you have the choice of doing everything in Javascript on the browser, or falling back to server-side diff...

and then goes on to say:

Most of the time, we do the latter, simply because while jsdifflib is pretty fast all by itself, and is totally usable for diffing "normal" files....

This doesn't make sense. "latter" in that second quote should be "former".

Feature - knockoutjs customBindingHandler

This is a simple binding handlers for knockout js.

    ko.bindingHandlers['jsDiffLib'] = {
            update: function (element, valueAccessor) {
                function getHtml(table){
                    var elems = [];
                    $(table).find("tbody>tr>td").each(function (item, elem) {
                        if(elem.className === "equal"){
                            elems.push("<span>" + elem.innerHTML + "</span>");
                        }
                        if(elem.className === "insert"){
                            elems.push("<ins>" + elem.innerHTML + "</ins>");
                        }
                        if(elem.className === "delete"){
                            elems.push("<del>" + elem.innerHTML + "</del>");
                        }
                    });
                    elems.splice(0, 1);
                    return elems.join("<br/>");
                }

                var options = valueAccessor();

                var base = difflib.stringAsLines("\n" + options.old()),
                    newtxt = difflib.stringAsLines("\n" + options.new()),
                    sm = new difflib.SequenceMatcher(base, newtxt),
                    opcodes = sm.get_opcodes();

                var currentTable = diffview.buildView({
                    baseTextLines: base,
                    newTextLines: newtxt,
                    opcodes: opcodes,
                    baseTextName: "Base Text",
                    newTextName: "New Text",
                    contextSize: null,
                    viewType: 1
                });
                var html = getHtml(currentTable);

                $(element).html(html);
            }
        }

Some information

@cemerick :
Hi congratulations on the module,
in Python there is: difflib.SequenceMatcher (None, str1, str2) .ratio ()
in the module you created there is a similar thing, does the same thing?

Example if I have:

  1. murder on the orient express
  2. murder on the express express 2017

The value of ratio, which value should you give according to your module?
Exceeds in this example the value of: 0.90?

P.ล .
Would it be possible to use it on React-native?

I thank you in advance.

Highlight diff in an "updated line"

There seem to be 4 results: unchanged, added, removed, and updated.

For updated, it would be really cool if the library could highlight what exactly is different in an updated line like git's highlight-diff does.

question: fixing difview's width

I have text that contains some very long rows of data.

At the moment, the diffview table is expanding to the whole width of the data. Ideally, I would like the long lines of data to wrap - is this possible? Any tips?

Btw - I had looked into the CSS, but didn't get very far. I was hoping for an insider tip-off ;)

Many thanks!

babel error - diffview.js

ReferenceError: Strict mode forbids implicit creation of global property 'diffview'

Can you please add a 'var' declaration on line 30 of diffview.js?

var diffview = {

Please merge PR #22

Diff by group of lines

difflib works line by line. But, First I wanted to group set of lines and check diff in that group.
I have tried this way, But this was not helpful. Instead of getting get_opcodes.
var opcodes = sm.get_grouped_opcodes();

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.