bem / html-differ

Сompares two HTML
http://bem.info/tools/testing/html-differ/
MIT License
212 stars 45 forks source link

Change the algorithm of comparison #95

Closed eGavr closed 10 years ago

eGavr commented 10 years ago

@phrazer proposed the following:

I had another idea, what if we first check line by line, and then if lines are the same go on, if not we also check word by word that line. Maybe then you get best from both worlds - speed and great diff tool. Just an idea, dont know if its possible to make it.

eGavr commented 10 years ago

It seems can't be implemented. Consider the following situation:

<span class="a
    b"></span>

and

<span class="a b"></span>

How can we compare them line by line?

eGavr commented 10 years ago

// cc @phrazer

phrazer commented 10 years ago

I will think about it, and get back to you...

We can make switch to enable this only on big files, so smaller ones stays the same. Then we could first process both htmls with tidy -w 1000 option (it makes html 100% correct and gets every tag in separate line) and eliminate this problem. Then you just make line by line, then word by word, like we said on the beggining.

phrazer commented 10 years ago

I used tidy on a lot of projects and it is really fast and never had problems with it... Its stable, been around long time.

eGavr commented 10 years ago

tidy is a nodejs module? Give me a link, please?

eGavr commented 10 years ago

I can not understand, why do you need differ in tasks when you can find diffs without any tools? I tried to implement the idea of comparison by lines, but there are still so many diffs that jsdiff fails.

phrazer commented 10 years ago

https://www.npmjs.org/package/htmltidy

eGavr commented 10 years ago

The problem discussed in #94