$self->{'_p_strict'}
and $HTML::TreeBuilder::isKnown{$tag}
and not $HTML::Tagset::is_Possible_Strict_P_Content{$tag}
) {
my $here = $pos;
my $here_tag = $ptag;
while(1) {
if($here_tag eq 'p') {
print $indent,
" * Inserting $tag closes strict P.\n" if DEBUG > 1;
$self->end(\q{p});
# NB: same as \'q', but less confusing to emacs cperl-mode
last;
}
#print("Lasting from $here_tag\n"),
last if
$HTML::TreeBuilder::isKnown{$here_tag}
and not $HTML::Tagset::is_Possible_Strict_P_Content{$here_tag};
# Don't keep looking up the tree if we see something that can't
# be strict-P content.
$here_tag = ($here = $here->{'_parent'} || last)->{'_tag'};
}# end while
$ptag = ($pos = $self->{'_pos'} || $self)->{'_tag'}; # better update!
}
# end of strict-p block.
}
# And now, get busy...
#----------------------------------------------------------------------
if (!$self->{'_implicit_tags'}) { # bimskalabim
# do nothing
print $indent, " * _implicit_tags is off. doing nothing\n"
if DEBUG > 1;
#----------------------------------------------------------------------
} elsif ($HTML::TreeBuilder::isHeadOrBodyElement{$tag}) {
if ($pos->is_inside('body')) { # all is well
print $indent,
" * ambilocal element \U$tag\E is fine under BODY.\n"
if DEBUG > 1;
} elsif ($pos->is_inside('head')) {
print $indent,
" * ambilocal element \U$tag\E is fine under HEAD.\n"
if DEBUG > 1;
} else {
# In neither head nor body! mmmmm... put under head?
if ($ptag eq 'html') { # expected case
# TODO?? : would there ever be a case where _head would be
# absent from a tree that would ever be accessed at this
# point?
die "Where'd my head go?" unless ref $self->{'_head'};
if ($self->{'_head'}{'_implicit'}) {
print $indent,
" * ambilocal element \U$tag\E makes an implicit HEAD.\n"
if DEBUG > 1;
# or rather, points us at it.
$self->{'_pos'} = $self->{'_head'}; # to insert under...
} else {
$self->warning(
"Ambilocal element <$tag> not under HEAD or BODY!?");
# Put it under HEAD by default, I guess
$self->{'_pos'} = $self->{'_head'}; # to insert under...
}
} else {
# Neither under head nor body, nor right under html... pass thru?
$self->warning(
"Ambilocal element <$tag> neither under head nor body, nor right under html!?");
}
}
#----------------------------------------------------------------------
} elsif ($HTML::TreeBuilder::isBodyElement{$tag}) {
# Ensure that we are within <body>
if($ptag eq 'body') {
# We're good.
} elsif($HTML::TreeBuilder::isBodyElement{$ptag} # glarg
and not $HTML::TreeBuilder::isHeadOrBodyElement{$ptag}
) {
# Special case: Save ourselves a call to is_inside further down.
# If our $ptag is an isBodyElement element (but not an
# isHeadOrBodyElement element), then we must be under body!
print $indent, " * Inferring that $ptag is under BODY.\n",
if DEBUG > 3;
# I think this and the test for 'body' trap everything
# bodyworthy, except the case where the parent element is
# under an unknown element that's a descendant of body.
} elsif ($pos->is_inside('head')) {
print $indent,
" * body-element \U$tag\E minimizes HEAD, makes implicit BODY.\n"
if DEBUG > 1;
$ptag = (
$pos = $self->{'_pos'} = $self->{'_body'} # yes, needs updating
|| die "Where'd my body go?"
)->{'_tag'}; # yes, needs updating
} elsif (! $pos->is_inside('body')) {
=4= |