and $HTML::TreeBuilder::canTighten{$sibs->[-2]{'_tag'}}
)
)
)
and !$par->is_inside('pre', 'xmp', 'textarea', 'plaintext')
# we're clear
) {
pop @$sibs;
print $indent, "Popping a preceding all-WS node\n" if DEBUG;
}
}
$self->insert_element($e) unless $already_inserted;
if(DEBUG) {
if($self->{'_pos'}) {
print
$indent, "(Current lineage of pos: \U$tag\E under ",
join('/',
reverse(
# $self->{'_pos'}{'_tag'}, # don't list myself!
$self->{'_pos'}->lineage_tag_names
)
),
".)\n";
} else {
print $indent, "(Pos points nowhere!?)\n";
}
}
unless(($self->{'_pos'} || '') eq $e) {
# if it's an empty element -- i.e., if it didn't change the _pos
&{ $self->{"_tweak_$tag"}
|| $self->{'_tweak_*'}
|| return $e
}(map $_, $e, $tag, $self); # make a list so the user can't clobber
}
return $e;
}
}
#==========================================================================
{
my $indent;
sub end {
return if $_[0]{'_stunted'};
# Either: Acccept an end-tag signal from HTML::Parser
# Or: Method for closing currently open elements in some fairly complex
# way, as used by other methods in this class.
my($self, $tag, @stop) = @_;
if($tag eq 'x-html') {
print "Ignoring close-x-html tag.\n" if DEBUG;
# inserted by some lame code-generators.
return;
}
unless(ref($tag) or $tag =~ m/^[-_a-zA-Z0-9:%]+$/s) {
DEBUG and print "End-tag name $tag is no good. Skipping.\n";
return;
# This avoids having Element's new() throw an exception.
}
# This method accepts two calling formats:
# 1) from Parser: $self->end('tag_name', 'origtext')
# in which case we shouldn't mistake origtext as a blocker tag
# 2) from myself: $self->end(\q{tagname1}, 'blk1', ... )
# from myself: $self->end(['tagname1', 'tagname2'], 'blk1', ... )
# End the specified tag, but don't move above any of the blocker tags.
# The tag can also be a reference to an array. Terminate the first
# tag found.
my $ptag = ( my $p = $self->{'_pos'} || $self )->{'_tag'};
# $p and $ptag are sort-of stratch
if(ref($tag)) {
# First param is a ref of one sort or another --
# THE CALL IS COMING FROM INSIDE THE HOUSE!
$tag = $$tag if ref($tag) eq 'SCALAR';
# otherwise it's an arrayref.
} else {
# the call came from Parser -- just ignore origtext
@stop = ();
}
#my($indent);
if(DEBUG) {
# optimization -- don't figure out depth unless we're in debug mode
my @lineage_tags = $p->lineage_tag_names;
$indent = ' ' x (1 + @lineage_tags);
# now announce ourselves
print $indent, "Ending ",
ref($tag) ? ('[', join(' ', @$tag ), ']') : "\U$tag\E",
scalar(@stop) ? (" no higher than [", join(' ', @stop), "]" )
=8= |