Skip Menu |

This queue is for tickets about the HTML-Diff CPAN distribution.

Report information
The Basics
Id: 7385
Status: open
Priority: 0/
Queue: HTML-Diff

People
Owner: Nobody in particular
Requestors: SREZIC [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 0.55
Fixed in: (no value)



Tag changes seem to be only handled correctly if the tag name changes, but not if the tag name stays the same but only tag attributes change. Consider the following two files and the resulting diff produced by htmldiff. 1.html: <body> <font color="red">bla foo bar</font> </body> 2.html: <body> <font color="blue">bla foo bar</font> </body> diff as produced with htmldiff: <style type="text/css"><!-- ins{color: green} del{color:red}--></style> <body> <del><font color="red"></del><ins><font color="blue"></ins>bla foo bar</font> </body> The resulting html code has now unbalanced tags. If I replace the both <font> tags with, say <b> and <i>, then everything works as expected. Regards, Slaven
Subject: weak bandaid
From: kev [...] brantaero.com
On Tue Aug 17 16:00:04 2004, SREZIC wrote: Show quoted text
> Tag changes seem to be only handled correctly if the tag name changes, > but not if the tag name stays the same but only tag attributes change. > Consider the following two files and the resulting diff produced > by htmldiff. > > The resulting html code has now unbalanced tags. If I replace the both > <font> tags with, say <b> and <i>, then everything works as expected.
If it's not the unbalanced nature of the resulting tags that you're worried about, you can change the script to get the following result (which will display correctly, but isn't technically valid): <del><font color="red">bla foo bar</del><ins><font color="blue">bla foo bar</ins></font> This is not a great solution, since if you, e.g., append ' yar' to each of your inputs, the 'yar' in the output will be coloured red instead of the default. Here it is anyway: # If we found the closer for the tag on top # of the stack, pop it off. if ((scalar @$tagstack) > 0 && $$tagstack[-1] =~ m/$tag\s*/) { pop @$tagstack; } return [$_, $tag]; } else { my ($tag) = m|^<\s*([^\s>]*)|; my ($whole_tag) = m|^<\s*([^>]*)|; $tag = lc $tag; # print STDERR "Found opener of $tag with " . (scalar @$tagstack) . " stack items\n"; if (member($tag, @UNBALANCED_TAGS) || $tag =~ m#/\s*>$#) { # (tags without correspond closer tags) return [$_, $whole_tag]; } else { push @$tagstack, $whole_tag;
From: kev [...] brantaero.com
On Wed Oct 27 13:28:18 2010, Kevin_Field wrote: Show quoted text
> This is not a great solution, since if you, e.g., append ' yar' to each > of your inputs, the 'yar' in the output will be coloured red instead of > the default.
I forgot to mention, though, that if you're only concerned with unbalanced tags (IMG for instance) then this does actually seem to be a good fix. Kev