foreach my $item (@{ $h->content_array_ref }) {
# deprecated!
next if ref $item;
$item =~ s/honour/honor/g;
}
...except that using the return value of C<< $h->content >> or
C<< $h->content_array_ref >> to do that is deprecated, and just might stop
working in the future.
=cut
sub content_refs_list {
return \( @{ shift->{'_content'} || return() } );
}
=head2 $h->implicit() or $h->implicit($bool)
Returns (optionally sets) the "_implicit" attribute. This attribute is
a flag that's used for indicating that the element was not originally
present in the source, but was added to the parse tree (by
HTML::TreeBuilder, for example) in order to conform to the rules of
HTML structure.
=cut
sub implicit {
return shift->attr('_implicit', @_);
}
=head2 $h->pos() or $h->pos($element)
Returns (and optionally sets) the "_pos" (for "current I<pos>ition")
pointer of C<$h>. This attribute is a pointer used during some
parsing operations, whose value is whatever HTML::Element element
at or under C<$h> is currently "open", where C<< $h->insert_element(NEW) >>
will actually insert a new element.
(This has nothing to do with the Perl function called "pos", for
controlling where regular expression matching starts.)
If you set C<< $h->pos($element) >>, be sure that C<$element> is
either C<$h>, or an element under C<$h>.
If you've been modifying the tree under C<$h> and are no longer
sure C<< $h->pos >> is valid, you can enforce validity with:
$h->pos(undef) unless $h->pos->is_inside($h);
=cut
sub pos {
my $self = shift;
my $pos = $self->{'_pos'};
if (@_) { # set
my $parm = shift;
if(defined $parm and $parm ne $self) {
$self->{'_pos'} = $parm; # means that element
}
else {
$self->{'_pos'} = undef; # means $self
}
}
return $pos if defined($pos);
return $self;
}
=head2 $h->all_attr()
Returns all this element's attributes and values, as key-value pairs.
This will include any "internal" attributes (i.e., ones not present
in the original element, and which will not be represented if/when you
call C<< $h->as_HTML >>). Internal attributes are distinguished by the fact
that the first character of their key (not value! key!) is an
underscore ("_").
Example output of C<< $h->all_attr() >> :
C<'_parent', >I<[object_value]>C< , '_tag', 'em', 'lang', 'en-US',
'_content', >I<[array-ref value]>.
=head2 $h->all_attr_names()
Like all_attr, but only returns the names of the attributes.
Example output of C<< $h->all_attr_names() >> :
C<'_parent', '_tag', 'lang', '_content', >.
=cut
sub all_attr {
return %{$_[0]};
# Yes, trivial. But no other way for the user to do the same
# without breaking encapsulation.
# And if our object representation changes, this method's behavior
# should stay the same.
}
=6= |