PROXY  WHOIS  RQUOTE  TEXTS  SOFT  FOREX  BBOARD
 Music  Philosophy  Code  Literature  Russian

= ROOT|Technical|Code_Examples|Perl|site_perl|HTML|TreeBuilder.pm =

page 5 of 19



            print $indent,
              " * body-element \U$tag\E 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
        }
         # else we ARE under body, so okay.
        
        
        # Handle implicit endings and insert based on <tag> and position
        # ... ALL HOPE ABANDON ALL YE WHO ENTER HERE ...
        if ($tag eq 'p'  or
            $tag eq 'h1' or $tag eq 'h2' or $tag eq 'h3' or 
            $tag eq 'h4' or $tag eq 'h5' or $tag eq 'h6' or
            $tag eq 'form'
            # Hm, should <form> really be here?!
        ) {
            # Can't have <p>, <h#> or <form> inside these
            $self->end($_Closed_by_structurals,
                       @HTML::TreeBuilder::p_closure_barriers
                        # used to be just li!
                      );
            
        } elsif ($tag eq 'ol' or $tag eq 'ul' or $tag eq 'dl') {
            # Can't have lists inside <h#> -- in the unlikely
            #  event anyone tries to put them there!
            if (
                $ptag eq 'h1' or $ptag eq 'h2' or $ptag eq 'h3' or 
                $ptag eq 'h4' or $ptag eq 'h5' or $ptag eq 'h6'
            ) {
                $self->end(\$ptag);
            }
            # TODO: Maybe keep closing up the tree until
            #  the ptag isn't any of the above?
            # But anyone that says <h1><h2><ul>...
            #  deserves what they get anyway.
            
        } elsif ($tag eq 'li') { # list item
            # Get under a list tag, one way or another
            unless(
              exists $HTML::TreeBuilder::isList{$ptag} or
              $self->end(\q{*}, keys %HTML::TreeBuilder::isList) #'
            ) { 
              print $indent,
                " * inserting implicit UL for lack of containing ",
                  join('|', keys %HTML::TreeBuilder::isList), ".\n"
               if DEBUG > 1;
              $self->insert_element('ul', 1); 
            }
            
        } elsif ($tag eq 'dt' or $tag eq 'dd') {
            # Get under a DL, one way or another
            unless($ptag eq 'dl' or $self->end(\q{*}, 'dl')) { #'
              print $indent,
                " * inserting implicit DL for lack of containing DL.\n"
               if DEBUG > 1;
              $self->insert_element('dl', 1);
            }
            
        } elsif ($HTML::TreeBuilder::isFormElement{$tag}) {
            if($self->{'_ignore_formies_outside_form'}  # TODO: document this
               and not $pos->is_inside('form')
            ) {
                print $indent,
                  " * ignoring \U$tag\E because not in a FORM.\n"
                  if DEBUG > 1;
                return;    # bypass tweaking.
            }
            if($tag eq 'option') {
                # return unless $ptag eq 'select';
                $self->end(\q{option});
                $ptag = ($self->{'_pos'} || $self)->{'_tag'};
                unless($ptag eq 'select' or $ptag eq 'optgroup') {
                    print $indent, " * \U$tag\E makes an implicit SELECT.\n"
                       if DEBUG > 1;
                    $pos = $self->insert_element('select', 1);
                    # but not a very useful select -- has no 'name' attribute!
                     # is $pos's value used after this?
                }
            }
        } elsif ($HTML::TreeBuilder::isTableElement{$tag}) {
            if(!$pos->is_inside('table')) {
                print $indent, " * \U$tag\E makes an implicit TABLE\n"
                  if DEBUG > 1;
                $self->insert_element('table', 1);
            }

            if($tag eq 'td' or $tag eq 'th') {
                # Get under a tr one way or another
                unless(
                  $ptag eq 'tr' # either under a tr
                  or $self->end(\q{*}, 'tr', 'table') #or we can get under one
                ) {
                    print $indent,
                       " * \U$tag\E under \U$ptag\E makes an implicit TR\n"
                     if DEBUG > 1;
                    $self->insert_element('tr', 1);
                    # presumably pos's value isn't used after this.
=5=

1|2|3|4| < PREV = PAGE 5 = NEXT > |6|7|8|9|10|11|12|13|14.19

UP TO ROOT | UP TO DIR | TO FIRST PAGE

Google
 


E-mail Facebook Google Digg del.icio.us BlinkList Fark Furl Ma.gnolia Netscape NewsVine Reddit Slashdot Spurl StumbleUpon Technorati YahooMyWeb LiveJournal Blogmarks TwitThis Live News2.ru BobrDobr.ru Memori.ru MoeMesto.ru

0.00611496 wallclock secs ( 0.00 usr + 0.00 sys = 0.00 CPU)