}
} else {
$self->end(\$tag, 'table'); #'
}
# Hmm, I guess this is right. To work it out:
# tr closes any open tr (limited at a table)
# thead closes any open thead (limited at a table)
# tbody closes any open tbody (limited at a table)
# tfoot closes any open tfoot (limited at a table)
# colgroup closes any open colgroup (limited at a table)
# col can try, but will always fail, at the enclosing table,
# as col is empty, and therefore never open!
# But!
# td closes any open td OR th (limited at a table)
# th closes any open th OR td (limited at a table)
# ...implementable as "close to a tr, or make a tr"
} elsif ($HTML::TreeBuilder::isPhraseMarkup{$tag}) {
if($ptag eq 'body' and $self->{'_implicit_body_p_tag'}) {
print
" * Phrasal \U$tag\E right under BODY makes an implicit P\n"
if DEBUG > 1;
$pos = $self->insert_element('p', 1);
# is $pos's value used after this?
}
}
# End of implicit endings logic
# End of "elsif ($HTML::TreeBuilder::isBodyElement{$tag}"
#----------------------------------------------------------------------
} elsif ($HTML::TreeBuilder::isHeadElement{$tag}) {
if ($pos->is_inside('body')) {
print $indent, " * head element \U$tag\E found inside BODY!\n"
if DEBUG;
$self->warning("Header element <$tag> in body"); # [sic]
} elsif (!$pos->is_inside('head')) {
print $indent, " * head element \U$tag\E makes an implicit HEAD.\n"
if DEBUG > 1;
} else {
print $indent,
" * head element \U$tag\E goes inside existing HEAD.\n"
if DEBUG > 1;
}
$self->{'_pos'} = $self->{'_head'} || die "Where'd my head go?";
#----------------------------------------------------------------------
} elsif ($tag eq 'html') {
if(delete $self->{'_implicit'}) { # first time here
print $indent, " * good! found the real HTML element!\n"
if DEBUG > 1;
} else {
print $indent, " * Found a second HTML element\n"
if DEBUG;
$self->warning("Found a nested <html> element");
}
# in either case, migrate attributes to the real element
for (keys %$attr) {
$self->attr($_, $attr->{$_});
}
$self->{'_pos'} = undef;
return $self; # bypass tweaking.
#----------------------------------------------------------------------
} elsif ($tag eq 'head') {
my $head = $self->{'_head'} || die "Where'd my head go?";
if(delete $head->{'_implicit'}) { # first time here
print $indent, " * good! found the real HEAD element!\n"
if DEBUG > 1;
} else { # been here before
print $indent, " * Found a second HEAD element\n"
if DEBUG;
$self->warning("Found a second <head> element");
}
# in either case, migrate attributes to the real element
for (keys %$attr) {
$head->attr($_, $attr->{$_});
}
return $self->{'_pos'} = $head; # bypass tweaking.
#----------------------------------------------------------------------
} elsif ($tag eq 'body') {
my $body = $self->{'_body'} || die "Where'd my body go?";
if(delete $body->{'_implicit'}) { # first time here
print $indent, " * good! found the real BODY element!\n"
if DEBUG > 1;
} else { # been here before
print $indent, " * Found a second BODY element\n"
if DEBUG;
$self->warning("Found a second <body> element");
}
# in either case, migrate attributes to the real element
for (keys %$attr) {
$body->attr($_, $attr->{$_});
}
return $self->{'_pos'} = $body; # bypass tweaking.
=6= |