Enhancement: identify when attributes have changed
Mr0grog opened this issue · 1 comments
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.
HTMLDiffer now has two ways of tackling changes:
Any text-level changes are surrounded by
<span class="htmldiffer_[insert|delete]>Some text change</span>
Tag level changes are different — if a tag has been added, or an attribute inside it has been added/deleted/changed, HTMLDiffer will now insert classes (class="htmldiffer-tag-change_[insert|delete]
)
So the above will now be:
d = diff.HTMLDiffer('<a href="/somwhere">Some link text</a>', '<a href="/somwhere-new">Some link text</a>')
d.combined_diff
# '<a class="htmldiffer-tag-change_delete" href="/somwhere"><a class="htmldiffer-tag-change_insert" href="/somwhere-new">Some link text</a></a>'
and the deleted and inserted will look like this:
d.deleted_diff
# '<a href="/somwhere" class="htmldiffer-tag-change_delete">Some link text</a>'
d.inserted_diff
# '<a href="/somwhere-new" class="htmldiffer-tag-change_insert">Some link text</a>'
Let me know if you have thoughts @Mr0grog! I'll close this issue for now.