GithubHelp home page GithubHelp logo

htmldiffer's People

Contributors

aaronsw avatar anastasia avatar ddohler avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

htmldiffer's Issues

add explicit classes that denote tag-level changes

d = HTMLDiffer('<h1>whatever</h1>', '<div>whatever</div>')
d.diff()'s combined_diff should potentially look like
'<div class="htmldiffer-tag-change">whatever</div>'
and attribute-level changes could look like:
d = HTMLDiffer('<div class="something">whatever</h1>', '<div class="something_else">whatever</div>')
d.diff()'s combined_diff should potentially look like
'<div class="htmldiffer-attribute-change">whatever</div>'
or
'<div class="htmldiffer-class-change">whatever</div>'

On top of current wip enhancement, would deal with #27, #28, #29

`combined_diff` appears to mix up open/close tags

I just tried this scenario where the text is the same, but the element containing it is different:

d = diff.HTMLDiffer('<h1>whatever</h1>', '<div>whatever</div>')
d.combined_diff
# <h1><div>whatever</h1></div>

Iโ€™m not totally sure what the ideal output here would be, but it would at least be good if elements properly contained each other, so the <h1> contained the <div> or vice-versa.

combined_diff outputs two opening tags but only one closing tag when attributes are changed

If the same element name was used but had different attributes, the opening tag of the element is repeated in the combined_diff (one for each side of the diff), but the closing tag is only output once (ostensibly because it is the same):

d = diff.HTMLDiffer('<a href="somewhere">Yeah</a>', '<a href="elsewhere">Yeah</a>')
d.combined_diff
# '<a href="somewhere"><a href="elsewhere">Yeah</a>'
# ^ Note two `<a...>`, but only one `</a>`

Or:

d = diff.HTMLDiffer('<div title="somewhere">Yeah and!</div>', '<div title="elsewhere">Yeah and.</div>')
d.combined_diff
# '<div title="somewhere"><div title="elsewhere">Yeah <span class="diff_delete">and!</span><span class="diff_insert">and.</span></div>'

Enhancement: identify when attributes have changed

It would be nice if there were a way to highlight the change in href attributes here:

<a href="/somwhere">Some link text</a>
<a href="/somwhere-new">Some link text</a>

That could be generic for any kind of attribute, but it would at least be really helpful for particular ones like href, src, title, alt on images, etc.

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.