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;