HTML-DOM
view release on metacpan or search on metacpan
lib/HTML/DOM.pm view on Meta::CPAN
# sidering what # dler's view
# _tweak_~text does # of the tree
# Web browsers preserve whitespace, at least from the point
# of view of the DOM; but the main reason we are using this
# option is that a parser for innerHTML doesnât know
# whether the nodes will be inserted in a <pre>.
no_space_compacting $tb 1;
$tb->handler(text => "text", # so we can get line
"self, text, is_cdata, offset"); # numbers for scripts
$tb->handler(start => "start",
"self, tagname, attr, attrseq, offset, tokenpos");
$tb->handler((declaration=>)x2,'self,tagname,tokens,text');
$tb->{_HTML_DOM_tweakall} = $tb->{'_tweak_*'};
my %opts = @_;
$tb->{_HTML_DOM_no_mg} = delete $opts{no_magic_forms};
# used by an elementâs innerHTML
lib/HTML/DOM.pm view on Meta::CPAN
start_h => [
sub { $doc_elem->start(@_) },
'tagname, attr, attrseq'
],
end_h => [
sub { $doc_elem->end(@_) },
'tagname, text'
],
text_h => [
sub { $doc_elem->text(@_) },
'text, is_cdata'
],
);
$p->unbroken_text(1); # push_content, which is called by
# H:TB:text, won't concatenate two
# text portions if the first one
# is a node.
$p->parse(shift);
lib/HTML/DOM/_TreeBuilder.pm view on Meta::CPAN
}
#==========================================================================
{
my ( $indent, $nugget );
sub text {
return if $_[0]{'_stunted'};
# Accept a "here's a text token" signal from HTML::Parser.
my ( $self, $text, $is_cdata ) = @_;
# the >3.0 versions of Parser may pass a cdata node.
# Thanks to Gisle Aas for pointing this out.
return unless length $text; # I guess that's always right
my $ignore_text = $self->{'_ignore_text'};
my $no_space_compacting = $self->{'_no_space_compacting'};
my $no_expand_entities = $self->{'_no_expand_entities'};
my $pos = $self->{'_pos'} || $self;
HTML::Entities::decode($text)
unless $ignore_text
|| $is_cdata
|| $HTML::Tagset::isCDATA_Parent{ $pos->{'_tag'} }
|| $no_expand_entities;
#my($indent, $nugget);
if (DEBUG) {
# optimization -- don't figure out depth unless we're in debug mode
my @lineage_tags = $pos->lineage_tag_names;
$indent = ' ' x ( 1 + @lineage_tags );
( run in 0.657 second using v1.01-cache-2.11-cpan-454fe037f31 )