/[suikacvs]/markup/html/whatpm/Whatpm/HTML.pm.src
Suika

Diff of /markup/html/whatpm/Whatpm/HTML.pm.src

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.151 by wakaba, Sun Jun 8 05:08:42 2008 UTC revision 1.166 by wakaba, Sat Sep 13 08:21:35 2008 UTC
# Line 354  sub parse_byte_string ($$$$;$) { Line 354  sub parse_byte_string ($$$$;$) {
354    return $self->parse_byte_stream ($charset_name, $input, @_[1..$#_]);    return $self->parse_byte_stream ($charset_name, $input, @_[1..$#_]);
355  } # parse_byte_string  } # parse_byte_string
356    
357  sub parse_byte_stream ($$$$;$) {  sub parse_byte_stream ($$$$;$$) {
358      # my ($self, $charset_name, $byte_stream, $doc, $onerror, $get_wrapper) = @_;
359    my $self = ref $_[0] ? shift : shift->new;    my $self = ref $_[0] ? shift : shift->new;
360    my $charset_name = shift;    my $charset_name = shift;
361    my $byte_stream = $_[0];    my $byte_stream = $_[0];
# Line 365  sub parse_byte_stream ($$$$;$) { Line 366  sub parse_byte_stream ($$$$;$) {
366    };    };
367    $self->{parse_error} = $onerror; # updated later by parse_char_string    $self->{parse_error} = $onerror; # updated later by parse_char_string
368    
369      my $get_wrapper = $_[3] || sub ($) {
370        return $_[0]; # $_[0] = byte stream handle, returned = arg to char handle
371      };
372    
373    ## HTML5 encoding sniffing algorithm    ## HTML5 encoding sniffing algorithm
374    require Message::Charset::Info;    require Message::Charset::Info;
375    my $charset;    my $charset;
# Line 372  sub parse_byte_stream ($$$$;$) { Line 377  sub parse_byte_stream ($$$$;$) {
377    my ($char_stream, $e_status);    my ($char_stream, $e_status);
378    
379    SNIFFING: {    SNIFFING: {
380        ## NOTE: By setting |allow_fallback| option true when the
381        ## |get_decode_handle| method is invoked, we ignore what the HTML5
382        ## spec requires, i.e. unsupported encoding should be ignored.
383          ## TODO: We should not do this unless the parser is invoked
384          ## in the conformance checking mode, in which this behavior
385          ## would be useful.
386    
387      ## Step 1      ## Step 1
388      if (defined $charset_name) {      if (defined $charset_name) {
389        $charset = Message::Charset::Info->get_by_iana_name ($charset_name);        $charset = Message::Charset::Info->get_by_html_name ($charset_name);
390              ## TODO: Is this ok?  Transfer protocol's parameter should be
391              ## interpreted in its semantics?
392    
393        ## ISSUE: Unsupported encoding is not ignored according to the spec.        ## ISSUE: Unsupported encoding is not ignored according to the spec.
394        ($char_stream, $e_status) = $charset->get_decode_handle        ($char_stream, $e_status) = $charset->get_decode_handle
# Line 399  sub parse_byte_stream ($$$$;$) { Line 412  sub parse_byte_stream ($$$$;$) {
412    
413      ## Step 3      ## Step 3
414      if ($byte_buffer =~ /^\xFE\xFF/) {      if ($byte_buffer =~ /^\xFE\xFF/) {
415        $charset = Message::Charset::Info->get_by_iana_name ('utf-16be');        $charset = Message::Charset::Info->get_by_html_name ('utf-16be');
416        ($char_stream, $e_status) = $charset->get_decode_handle        ($char_stream, $e_status) = $charset->get_decode_handle
417            ($byte_stream, allow_error_reporting => 1,            ($byte_stream, allow_error_reporting => 1,
418             allow_fallback => 1, byte_buffer => \$byte_buffer);             allow_fallback => 1, byte_buffer => \$byte_buffer);
419        $self->{confident} = 1;        $self->{confident} = 1;
420        last SNIFFING;        last SNIFFING;
421      } elsif ($byte_buffer =~ /^\xFF\xFE/) {      } elsif ($byte_buffer =~ /^\xFF\xFE/) {
422        $charset = Message::Charset::Info->get_by_iana_name ('utf-16le');        $charset = Message::Charset::Info->get_by_html_name ('utf-16le');
423        ($char_stream, $e_status) = $charset->get_decode_handle        ($char_stream, $e_status) = $charset->get_decode_handle
424            ($byte_stream, allow_error_reporting => 1,            ($byte_stream, allow_error_reporting => 1,
425             allow_fallback => 1, byte_buffer => \$byte_buffer);             allow_fallback => 1, byte_buffer => \$byte_buffer);
426        $self->{confident} = 1;        $self->{confident} = 1;
427        last SNIFFING;        last SNIFFING;
428      } elsif ($byte_buffer =~ /^\xEF\xBB\xBF/) {      } elsif ($byte_buffer =~ /^\xEF\xBB\xBF/) {
429        $charset = Message::Charset::Info->get_by_iana_name ('utf-8');        $charset = Message::Charset::Info->get_by_html_name ('utf-8');
430        ($char_stream, $e_status) = $charset->get_decode_handle        ($char_stream, $e_status) = $charset->get_decode_handle
431            ($byte_stream, allow_error_reporting => 1,            ($byte_stream, allow_error_reporting => 1,
432             allow_fallback => 1, byte_buffer => \$byte_buffer);             allow_fallback => 1, byte_buffer => \$byte_buffer);
# Line 432  sub parse_byte_stream ($$$$;$) { Line 445  sub parse_byte_stream ($$$$;$) {
445      $charset_name = Whatpm::Charset::UniversalCharDet->detect_byte_string      $charset_name = Whatpm::Charset::UniversalCharDet->detect_byte_string
446          ($byte_buffer);          ($byte_buffer);
447      if (defined $charset_name) {      if (defined $charset_name) {
448        $charset = Message::Charset::Info->get_by_iana_name ($charset_name);        $charset = Message::Charset::Info->get_by_html_name ($charset_name);
449    
450        ## ISSUE: Unsupported encoding is not ignored according to the spec.        ## ISSUE: Unsupported encoding is not ignored according to the spec.
451        require Whatpm::Charset::DecodeHandle;        require Whatpm::Charset::DecodeHandle;
# Line 443  sub parse_byte_stream ($$$$;$) { Line 456  sub parse_byte_stream ($$$$;$) {
456             allow_fallback => 1, byte_buffer => \$byte_buffer);             allow_fallback => 1, byte_buffer => \$byte_buffer);
457        if ($char_stream) {        if ($char_stream) {
458          $buffer->{buffer} = $byte_buffer;          $buffer->{buffer} = $byte_buffer;
459          !!!parse-error (type => 'sniffing:chardet', ## TODO: type name          !!!parse-error (type => 'sniffing:chardet',
460                          value => $charset_name,                          text => $charset_name,
461                          level => $self->{info_level},                          level => $self->{level}->{info},
462                            layer => 'encode',
463                          line => 1, column => 1);                          line => 1, column => 1);
464          $self->{confident} = 0;          $self->{confident} = 0;
465          last SNIFFING;          last SNIFFING;
# Line 454  sub parse_byte_stream ($$$$;$) { Line 468  sub parse_byte_stream ($$$$;$) {
468    
469      ## Step 7: default      ## Step 7: default
470      ## TODO: Make this configurable.      ## TODO: Make this configurable.
471      $charset = Message::Charset::Info->get_by_iana_name ('windows-1252');      $charset = Message::Charset::Info->get_by_html_name ('windows-1252');
472          ## NOTE: We choose |windows-1252| here, since |utf-8| should be          ## NOTE: We choose |windows-1252| here, since |utf-8| should be
473          ## detectable in the step 6.          ## detectable in the step 6.
474      require Whatpm::Charset::DecodeHandle;      require Whatpm::Charset::DecodeHandle;
# Line 466  sub parse_byte_stream ($$$$;$) { Line 480  sub parse_byte_stream ($$$$;$) {
480                                         allow_fallback => 1,                                         allow_fallback => 1,
481                                         byte_buffer => \$byte_buffer);                                         byte_buffer => \$byte_buffer);
482      $buffer->{buffer} = $byte_buffer;      $buffer->{buffer} = $byte_buffer;
483      !!!parse-error (type => 'sniffing:default', ## TODO: type name      !!!parse-error (type => 'sniffing:default',
484                      value => 'windows-1252',                      text => 'windows-1252',
485                      level => $self->{info_level},                      level => $self->{level}->{info},
486                      line => 1, column => 1);                      line => 1, column => 1,
487                        layer => 'encode');
488      $self->{confident} = 0;      $self->{confident} = 0;
489    } # SNIFFING    } # SNIFFING
490    
   $self->{input_encoding} = $charset->get_iana_name;  
491    if ($e_status & Message::Charset::Info::FALLBACK_ENCODING_IMPL ()) {    if ($e_status & Message::Charset::Info::FALLBACK_ENCODING_IMPL ()) {
492      !!!parse-error (type => 'chardecode:fallback', ## TODO: type name      $self->{input_encoding} = $charset->get_iana_name; ## TODO: Should we set actual charset decoder's encoding name?
493                      value => $self->{input_encoding},      !!!parse-error (type => 'chardecode:fallback',
494                      level => $self->{unsupported_level},                      #text => $self->{input_encoding},
495                      line => 1, column => 1);                      level => $self->{level}->{uncertain},
496                        line => 1, column => 1,
497                        layer => 'encode');
498    } elsif (not ($e_status &    } elsif (not ($e_status &
499                  Message::Charset::Info::ERROR_REPORTING_ENCODING_IMPL())) {                  Message::Charset::Info::ERROR_REPORTING_ENCODING_IMPL())) {
500      !!!parse-error (type => 'chardecode:no error', ## TODO: type name      $self->{input_encoding} = $charset->get_iana_name;
501                      value => $self->{input_encoding},      !!!parse-error (type => 'chardecode:no error',
502                      level => $self->{unsupported_level},                      text => $self->{input_encoding},
503                      line => 1, column => 1);                      level => $self->{level}->{uncertain},
504                        line => 1, column => 1,
505                        layer => 'encode');
506      } else {
507        $self->{input_encoding} = $charset->get_iana_name;
508    }    }
509    
510    $self->{change_encoding} = sub {    $self->{change_encoding} = sub {
# Line 492  sub parse_byte_stream ($$$$;$) { Line 512  sub parse_byte_stream ($$$$;$) {
512      $charset_name = shift;      $charset_name = shift;
513      my $token = shift;      my $token = shift;
514    
515      $charset = Message::Charset::Info->get_by_iana_name ($charset_name);      $charset = Message::Charset::Info->get_by_html_name ($charset_name);
516      ($char_stream, $e_status) = $charset->get_decode_handle      ($char_stream, $e_status) = $charset->get_decode_handle
517          ($byte_stream, allow_error_reporting => 1, allow_fallback => 1,          ($byte_stream, allow_error_reporting => 1, allow_fallback => 1,
518           byte_buffer => \ $buffer->{buffer});           byte_buffer => \ $buffer->{buffer});
# Line 503  sub parse_byte_stream ($$$$;$) { Line 523  sub parse_byte_stream ($$$$;$) {
523        ## Step 1            ## Step 1    
524        if ($charset->{category} &        if ($charset->{category} &
525            Message::Charset::Info::CHARSET_CATEGORY_UTF16 ()) {            Message::Charset::Info::CHARSET_CATEGORY_UTF16 ()) {
526          $charset = Message::Charset::Info->get_by_iana_name ('utf-8');          $charset = Message::Charset::Info->get_by_html_name ('utf-8');
527          ($char_stream, $e_status) = $charset->get_decode_handle          ($char_stream, $e_status) = $charset->get_decode_handle
528              ($byte_stream,              ($byte_stream,
529               byte_buffer => \ $buffer->{buffer});               byte_buffer => \ $buffer->{buffer});
# Line 513  sub parse_byte_stream ($$$$;$) { Line 533  sub parse_byte_stream ($$$$;$) {
533        ## Step 2        ## Step 2
534        if (defined $self->{input_encoding} and        if (defined $self->{input_encoding} and
535            $self->{input_encoding} eq $charset_name) {            $self->{input_encoding} eq $charset_name) {
536          !!!parse-error (type => 'charset label:matching', ## TODO: type          !!!parse-error (type => 'charset label:matching',
537                          value => $charset_name,                          text => $charset_name,
538                          level => $self->{info_level});                          level => $self->{level}->{info});
539          $self->{confident} = 1;          $self->{confident} = 1;
540          return;          return;
541        }        }
542    
543        !!!parse-error (type => 'charset label detected:'.$self->{input_encoding}.        !!!parse-error (type => 'charset label detected',
544            ':'.$charset_name, level => 'w', token => $token);                        text => $self->{input_encoding},
545                          value => $charset_name,
546                          level => $self->{level}->{warn},
547                          token => $token);
548                
549        ## Step 3        ## Step 3
550        # if (can) {        # if (can) {
# Line 537  sub parse_byte_stream ($$$$;$) { Line 560  sub parse_byte_stream ($$$$;$) {
560    
561    my $char_onerror = sub {    my $char_onerror = sub {
562      my (undef, $type, %opt) = @_;      my (undef, $type, %opt) = @_;
563      !!!parse-error (%opt, type => $type,      !!!parse-error (layer => 'encode',
564                        %opt, type => $type,
565                      line => $self->{line}, column => $self->{column} + 1);                      line => $self->{line}, column => $self->{column} + 1);
566      if ($opt{octets}) {      if ($opt{octets}) {
567        ${$opt{octets}} = "\x{FFFD}"; # relacement character        ${$opt{octets}} = "\x{FFFD}"; # relacement character
568      }      }
569    };    };
570    $char_stream->onerror ($char_onerror);  
571      my $wrapped_char_stream = $get_wrapper->($char_stream);
572      $wrapped_char_stream->onerror ($char_onerror);
573    
574    my @args = @_; shift @args; # $s    my @args = @_; shift @args; # $s
575    my $return;    my $return;
576    try {    try {
577      $return = $self->parse_char_stream ($char_stream, @args);        $return = $self->parse_char_stream ($wrapped_char_stream, @args);  
578    } catch Whatpm::HTML::RestartParser with {    } catch Whatpm::HTML::RestartParser with {
579      ## NOTE: Invoked after {change_encoding}.      ## NOTE: Invoked after {change_encoding}.
580    
     $self->{input_encoding} = $charset->get_iana_name;  
581      if ($e_status & Message::Charset::Info::FALLBACK_ENCODING_IMPL ()) {      if ($e_status & Message::Charset::Info::FALLBACK_ENCODING_IMPL ()) {
582        !!!parse-error (type => 'chardecode:fallback', ## TODO: type name        $self->{input_encoding} = $charset->get_iana_name; ## TODO: Should we set actual charset decoder's encoding name?
583                        value => $self->{input_encoding},        !!!parse-error (type => 'chardecode:fallback',
584                        level => $self->{unsupported_level},                        level => $self->{level}->{uncertain},
585                        line => 1, column => 1);                        #text => $self->{input_encoding},
586                          line => 1, column => 1,
587                          layer => 'encode');
588      } elsif (not ($e_status &      } elsif (not ($e_status &
589                    Message::Charset::Info::ERROR_REPORTING_ENCODING_IMPL())) {                    Message::Charset::Info::ERROR_REPORTING_ENCODING_IMPL())) {
590        !!!parse-error (type => 'chardecode:no error', ## TODO: type name        $self->{input_encoding} = $charset->get_iana_name;
591                        value => $self->{input_encoding},        !!!parse-error (type => 'chardecode:no error',
592                        level => $self->{unsupported_level},                        text => $self->{input_encoding},
593                        line => 1, column => 1);                        level => $self->{level}->{uncertain},
594                          line => 1, column => 1,
595                          layer => 'encode');
596        } else {
597          $self->{input_encoding} = $charset->get_iana_name;
598      }      }
599      $self->{confident} = 1;      $self->{confident} = 1;
600      $char_stream->onerror ($char_onerror);  
601      $return = $self->parse_char_stream ($char_stream, @args);      $wrapped_char_stream = $get_wrapper->($char_stream);
602        $wrapped_char_stream->onerror ($char_onerror);
603    
604        $return = $self->parse_char_stream ($wrapped_char_stream, @args);
605    };    };
606    return $return;    return $return;
607  } # parse_byte_stream  } # parse_byte_stream
# Line 581  sub parse_byte_stream ($$$$;$) { Line 615  sub parse_byte_stream ($$$$;$) {
615  ## such as |parse_byte_string| in this module, must ensure that it does  ## such as |parse_byte_string| in this module, must ensure that it does
616  ## strip the BOM and never strip any ZWNBSP.  ## strip the BOM and never strip any ZWNBSP.
617    
618  sub parse_char_string ($$$;$) {  sub parse_char_string ($$$;$$) {
619      #my ($self, $s, $doc, $onerror, $get_wrapper) = @_;
620    my $self = shift;    my $self = shift;
621    require utf8;    require utf8;
622    my $s = ref $_[0] ? $_[0] : \($_[0]);    my $s = ref $_[0] ? $_[0] : \($_[0]);
623    open my $input, '<' . (utf8::is_utf8 ($$s) ? ':utf8' : ''), $s;    open my $input, '<' . (utf8::is_utf8 ($$s) ? ':utf8' : ''), $s;
624      if ($_[3]) {
625        $input = $_[3]->($input);
626      }
627    return $self->parse_char_stream ($input, @_[1..$#_]);    return $self->parse_char_stream ($input, @_[1..$#_]);
628  } # parse_char_string  } # parse_char_string
629  *parse_string = \&parse_char_string;  *parse_string = \&parse_char_string; ## NOTE: Alias for backward compatibility.
630    
631  sub parse_char_stream ($$$;$) {  sub parse_char_stream ($$$;$) {
632    my $self = ref $_[0] ? shift : shift->new;    my $self = ref $_[0] ? shift : shift->new;
# Line 662  sub parse_char_stream ($$$;$) { Line 700  sub parse_char_stream ($$$;$) {
700                0x10FFFE => 1, 0x10FFFF => 1,                0x10FFFE => 1, 0x10FFFF => 1,
701               }->{$self->{next_char}}) {               }->{$self->{next_char}}) {
702        !!!cp ('j5');        !!!cp ('j5');
703        !!!parse-error (type => 'control char', level => $self->{must_level});        if ($self->{next_char} < 0x10000) {
704  ## TODO: error type documentation          !!!parse-error (type => 'control char',
705                            text => (sprintf 'U+%04X', $self->{next_char}));
706          } else {
707            !!!parse-error (type => 'control char',
708                            text => (sprintf 'U-%08X', $self->{next_char}));
709          }
710      }      }
711    };    };
712    $self->{prev_char} = [-1, -1, -1];    $self->{prev_char} = [-1, -1, -1];
# Line 692  sub parse_char_stream ($$$;$) { Line 735  sub parse_char_stream ($$$;$) {
735  sub new ($) {  sub new ($) {
736    my $class = shift;    my $class = shift;
737    my $self = bless {    my $self = bless {
738      must_level => 'm',      level => {must => 'm',
739      should_level => 's',                should => 's',
740      good_level => 'w',                warn => 'w',
741      warn_level => 'w',                info => 'i',
742      info_level => 'i',                uncertain => 'u'},
     unsupported_level => 'u',  
743    }, $class;    }, $class;
744    $self->{set_next_char} = sub {    $self->{set_next_char} = sub {
745      $self->{next_char} = -1;      $self->{next_char} = -1;
# Line 761  sub AFTER_DOCTYPE_SYSTEM_IDENTIFIER_STAT Line 803  sub AFTER_DOCTYPE_SYSTEM_IDENTIFIER_STAT
803  sub BOGUS_DOCTYPE_STATE () { 32 }  sub BOGUS_DOCTYPE_STATE () { 32 }
804  sub AFTER_ATTRIBUTE_VALUE_QUOTED_STATE () { 33 }  sub AFTER_ATTRIBUTE_VALUE_QUOTED_STATE () { 33 }
805  sub SELF_CLOSING_START_TAG_STATE () { 34 }  sub SELF_CLOSING_START_TAG_STATE () { 34 }
806  sub CDATA_BLOCK_STATE () { 35 }  sub CDATA_SECTION_STATE () { 35 }
807    sub MD_HYPHEN_STATE () { 36 } # "markup declaration open state" in the spec
808    sub MD_DOCTYPE_STATE () { 37 } # "markup declaration open state" in the spec
809    sub MD_CDATA_STATE () { 38 } # "markup declaration open state" in the spec
810    sub CDATA_PCDATA_CLOSE_TAG_STATE () { 39 } # "close tag open state" in the spec
811    sub CDATA_SECTION_MSE1_STATE () { 40 } # "CDATA section state" in the spec
812    sub CDATA_SECTION_MSE2_STATE () { 41 } # "CDATA section state" in the spec
813    sub PUBLIC_STATE () { 42 } # "after DOCTYPE name state" in the spec
814    sub SYSTEM_STATE () { 43 } # "after DOCTYPE name state" in the spec
815    
816  sub DOCTYPE_TOKEN () { 1 }  sub DOCTYPE_TOKEN () { 1 }
817  sub COMMENT_TOKEN () { 2 }  sub COMMENT_TOKEN () { 2 }
# Line 814  sub IN_COLUMN_GROUP_IM () { 0b10 } Line 864  sub IN_COLUMN_GROUP_IM () { 0b10 }
864  sub _initialize_tokenizer ($) {  sub _initialize_tokenizer ($) {
865    my $self = shift;    my $self = shift;
866    $self->{state} = DATA_STATE; # MUST    $self->{state} = DATA_STATE; # MUST
867      #$self->{state_keyword}; # initialized when used
868    $self->{content_model} = PCDATA_CONTENT_MODEL; # be    $self->{content_model} = PCDATA_CONTENT_MODEL; # be
869    undef $self->{current_token}; # start tag, end tag, comment, or DOCTYPE    undef $self->{current_token};
870    undef $self->{current_attribute};    undef $self->{current_attribute};
871    undef $self->{last_emitted_start_tag_name};    undef $self->{last_emitted_start_tag_name};
872    undef $self->{last_attribute_value_state};    undef $self->{last_attribute_value_state};
# Line 1076  sub _get_next_token ($) { Line 1127  sub _get_next_token ($) {
1127          die "$0: $self->{content_model} in tag open";          die "$0: $self->{content_model} in tag open";
1128        }        }
1129      } elsif ($self->{state} == CLOSE_TAG_OPEN_STATE) {      } elsif ($self->{state} == CLOSE_TAG_OPEN_STATE) {
1130          ## NOTE: The "close tag open state" in the spec is implemented as
1131          ## |CLOSE_TAG_OPEN_STATE| and |CDATA_PCDATA_CLOSE_TAG_STATE|.
1132    
1133        my ($l, $c) = ($self->{line_prev}, $self->{column_prev} - 1); # "<"of"</"        my ($l, $c) = ($self->{line_prev}, $self->{column_prev} - 1); # "<"of"</"
1134        if ($self->{content_model} & CM_LIMITED_MARKUP) { # RCDATA | CDATA        if ($self->{content_model} & CM_LIMITED_MARKUP) { # RCDATA | CDATA
1135          if (defined $self->{last_emitted_start_tag_name}) {          if (defined $self->{last_emitted_start_tag_name}) {
1136              $self->{state} = CDATA_PCDATA_CLOSE_TAG_STATE;
1137            ## NOTE: <http://krijnhoetmer.nl/irc-logs/whatwg/20070626#l-564>            $self->{state_keyword} = '';
1138            my @next_char;            ## Reconsume.
1139            TAGNAME: for (my $i = 0; $i < length $self->{last_emitted_start_tag_name}; $i++) {            redo A;
             push @next_char, $self->{next_char};  
             my $c = ord substr ($self->{last_emitted_start_tag_name}, $i, 1);  
             my $C = 0x0061 <= $c && $c <= 0x007A ? $c - 0x0020 : $c;  
             if ($self->{next_char} == $c or $self->{next_char} == $C) {  
               !!!cp (24);  
               !!!next-input-character;  
               next TAGNAME;  
             } else {  
               !!!cp (25);  
               $self->{next_char} = shift @next_char; # reconsume  
               !!!back-next-input-character (@next_char);  
               $self->{state} = DATA_STATE;  
   
               !!!emit ({type => CHARACTER_TOKEN, data => '</',  
                         line => $l, column => $c,  
                        });  
     
               redo A;  
             }  
           }  
           push @next_char, $self->{next_char};  
         
           unless ($self->{next_char} == 0x0009 or # HT  
                   $self->{next_char} == 0x000A or # LF  
                   $self->{next_char} == 0x000B or # VT  
                   $self->{next_char} == 0x000C or # FF  
                   $self->{next_char} == 0x0020 or # SP  
                   $self->{next_char} == 0x003E or # >  
                   $self->{next_char} == 0x002F or # /  
                   $self->{next_char} == -1) {  
             !!!cp (26);  
             $self->{next_char} = shift @next_char; # reconsume  
             !!!back-next-input-character (@next_char);  
             $self->{state} = DATA_STATE;  
             !!!emit ({type => CHARACTER_TOKEN, data => '</',  
                       line => $l, column => $c,  
                      });  
             redo A;  
           } else {  
             !!!cp (27);  
             $self->{next_char} = shift @next_char;  
             !!!back-next-input-character (@next_char);  
             # and consume...  
           }  
1140          } else {          } else {
1141            ## No start tag token has ever been emitted            ## No start tag token has ever been emitted
1142              ## NOTE: See <http://krijnhoetmer.nl/irc-logs/whatwg/20070626#l-564>.
1143            !!!cp (28);            !!!cp (28);
           # next-input-character is already done  
1144            $self->{state} = DATA_STATE;            $self->{state} = DATA_STATE;
1145              ## Reconsume.
1146            !!!emit ({type => CHARACTER_TOKEN, data => '</',            !!!emit ({type => CHARACTER_TOKEN, data => '</',
1147                      line => $l, column => $c,                      line => $l, column => $c,
1148                     });                     });
1149            redo A;            redo A;
1150          }          }
1151        }        }
1152          
1153        if (0x0041 <= $self->{next_char} and        if (0x0041 <= $self->{next_char} and
1154            $self->{next_char} <= 0x005A) { # A..Z            $self->{next_char} <= 0x005A) { # A..Z
1155          !!!cp (29);          !!!cp (29);
# Line 1185  sub _get_next_token ($) { Line 1196  sub _get_next_token ($) {
1196                                    line => $self->{line_prev}, # "<" of "</"                                    line => $self->{line_prev}, # "<" of "</"
1197                                    column => $self->{column_prev} - 1,                                    column => $self->{column_prev} - 1,
1198                                   };                                   };
1199          ## $self->{next_char} is intentionally left as is          ## NOTE: $self->{next_char} is intentionally left as is.
1200          redo A;          ## Although the "anything else" case of the spec not explicitly
1201            ## states that the next input character is to be reconsumed,
1202            ## it will be included to the |data| of the comment token
1203            ## generated from the bogus end tag, as defined in the
1204            ## "bogus comment state" entry.
1205            redo A;
1206          }
1207        } elsif ($self->{state} == CDATA_PCDATA_CLOSE_TAG_STATE) {
1208          my $ch = substr $self->{last_emitted_start_tag_name}, length $self->{state_keyword}, 1;
1209          if (length $ch) {
1210            my $CH = $ch;
1211            $ch =~ tr/a-z/A-Z/;
1212            my $nch = chr $self->{next_char};
1213            if ($nch eq $ch or $nch eq $CH) {
1214              !!!cp (24);
1215              ## Stay in the state.
1216              $self->{state_keyword} .= $nch;
1217              !!!next-input-character;
1218              redo A;
1219            } else {
1220              !!!cp (25);
1221              $self->{state} = DATA_STATE;
1222              ## Reconsume.
1223              !!!emit ({type => CHARACTER_TOKEN,
1224                        data => '</' . $self->{state_keyword},
1225                        line => $self->{line_prev},
1226                        column => $self->{column_prev} - 1 - length $self->{state_keyword},
1227                       });
1228              redo A;
1229            }
1230          } else { # after "<{tag-name}"
1231            unless ({
1232                     0x0009 => 1, # HT
1233                     0x000A => 1, # LF
1234                     0x000B => 1, # VT
1235                     0x000C => 1, # FF
1236                     0x0020 => 1, # SP
1237                     0x003E => 1, # >
1238                     0x002F => 1, # /
1239                     -1 => 1, # EOF
1240                    }->{$self->{next_char}}) {
1241              !!!cp (26);
1242              ## Reconsume.
1243              $self->{state} = DATA_STATE;
1244              !!!emit ({type => CHARACTER_TOKEN,
1245                        data => '</' . $self->{state_keyword},
1246                        line => $self->{line_prev},
1247                        column => $self->{column_prev} - 1 - length $self->{state_keyword},
1248                       });
1249              redo A;
1250            } else {
1251              !!!cp (27);
1252              $self->{current_token}
1253                  = {type => END_TAG_TOKEN,
1254                     tag_name => $self->{last_emitted_start_tag_name},
1255                     line => $self->{line_prev},
1256                     column => $self->{column_prev} - 1 - length $self->{state_keyword}};
1257              $self->{state} = TAG_NAME_STATE;
1258              ## Reconsume.
1259              redo A;
1260            }
1261        }        }
1262      } elsif ($self->{state} == TAG_NAME_STATE) {      } elsif ($self->{state} == TAG_NAME_STATE) {
1263        if ($self->{next_char} == 0x0009 or # HT        if ($self->{next_char} == 0x0009 or # HT
# Line 1356  sub _get_next_token ($) { Line 1427  sub _get_next_token ($) {
1427          if (exists $self->{current_token}->{attributes} # start tag or end tag          if (exists $self->{current_token}->{attributes} # start tag or end tag
1428              ->{$self->{current_attribute}->{name}}) { # MUST              ->{$self->{current_attribute}->{name}}) { # MUST
1429            !!!cp (57);            !!!cp (57);
1430            !!!parse-error (type => 'duplicate attribute:'.$self->{current_attribute}->{name}, line => $self->{current_attribute}->{line}, column => $self->{current_attribute}->{column});            !!!parse-error (type => 'duplicate attribute', text => $self->{current_attribute}->{name}, line => $self->{current_attribute}->{line}, column => $self->{current_attribute}->{column});
1431            ## Discard $self->{current_attribute} # MUST            ## Discard $self->{current_attribute} # MUST
1432          } else {          } else {
1433            !!!cp (58);            !!!cp (58);
# Line 1527  sub _get_next_token ($) { Line 1598  sub _get_next_token ($) {
1598    
1599          redo A;          redo A;
1600        } else {        } else {
1601          !!!cp (82);          if ($self->{next_char} == 0x0022 or # "
1602                $self->{next_char} == 0x0027) { # '
1603              !!!cp (78);
1604              !!!parse-error (type => 'bad attribute name');
1605            } else {
1606              !!!cp (82);
1607            }
1608          $self->{current_attribute}          $self->{current_attribute}
1609              = {name => chr ($self->{next_char}),              = {name => chr ($self->{next_char}),
1610                 value => '',                 value => '',
# Line 1562  sub _get_next_token ($) { Line 1639  sub _get_next_token ($) {
1639          !!!next-input-character;          !!!next-input-character;
1640          redo A;          redo A;
1641        } elsif ($self->{next_char} == 0x003E) { # >        } elsif ($self->{next_char} == 0x003E) { # >
1642            !!!parse-error (type => 'empty unquoted attribute value');
1643          if ($self->{current_token}->{type} == START_TAG_TOKEN) {          if ($self->{current_token}->{type} == START_TAG_TOKEN) {
1644            !!!cp (87);            !!!cp (87);
1645            $self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name};            $self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name};
# Line 1952  sub _get_next_token ($) { Line 2030  sub _get_next_token ($) {
2030        die "$0: _get_next_token: unexpected case [BC]";        die "$0: _get_next_token: unexpected case [BC]";
2031      } elsif ($self->{state} == MARKUP_DECLARATION_OPEN_STATE) {      } elsif ($self->{state} == MARKUP_DECLARATION_OPEN_STATE) {
2032        ## (only happen if PCDATA state)        ## (only happen if PCDATA state)
   
       my ($l, $c) = ($self->{line_prev}, $self->{column_prev} - 1);  
   
       my @next_char;  
       push @next_char, $self->{next_char};  
2033                
2034        if ($self->{next_char} == 0x002D) { # -        if ($self->{next_char} == 0x002D) { # -
2035            !!!cp (133);
2036            $self->{state} = MD_HYPHEN_STATE;
2037          !!!next-input-character;          !!!next-input-character;
2038          push @next_char, $self->{next_char};          redo A;
         if ($self->{next_char} == 0x002D) { # -  
           !!!cp (127);  
           $self->{current_token} = {type => COMMENT_TOKEN, data => '',  
                                     line => $l, column => $c,  
                                    };  
           $self->{state} = COMMENT_START_STATE;  
           !!!next-input-character;  
           redo A;  
         } else {  
           !!!cp (128);  
         }  
2039        } elsif ($self->{next_char} == 0x0044 or # D        } elsif ($self->{next_char} == 0x0044 or # D
2040                 $self->{next_char} == 0x0064) { # d                 $self->{next_char} == 0x0064) { # d
2041            ## ASCII case-insensitive.
2042            !!!cp (130);
2043            $self->{state} = MD_DOCTYPE_STATE;
2044            $self->{state_keyword} = chr $self->{next_char};
2045          !!!next-input-character;          !!!next-input-character;
2046          push @next_char, $self->{next_char};          redo A;
         if ($self->{next_char} == 0x004F or # O  
             $self->{next_char} == 0x006F) { # o  
           !!!next-input-character;  
           push @next_char, $self->{next_char};  
           if ($self->{next_char} == 0x0043 or # C  
               $self->{next_char} == 0x0063) { # c  
             !!!next-input-character;  
             push @next_char, $self->{next_char};  
             if ($self->{next_char} == 0x0054 or # T  
                 $self->{next_char} == 0x0074) { # t  
               !!!next-input-character;  
               push @next_char, $self->{next_char};  
               if ($self->{next_char} == 0x0059 or # Y  
                   $self->{next_char} == 0x0079) { # y  
                 !!!next-input-character;  
                 push @next_char, $self->{next_char};  
                 if ($self->{next_char} == 0x0050 or # P  
                     $self->{next_char} == 0x0070) { # p  
                   !!!next-input-character;  
                   push @next_char, $self->{next_char};  
                   if ($self->{next_char} == 0x0045 or # E  
                       $self->{next_char} == 0x0065) { # e  
                     !!!cp (129);  
                     ## TODO: What a stupid code this is!  
                     $self->{state} = DOCTYPE_STATE;  
                     $self->{current_token} = {type => DOCTYPE_TOKEN,  
                                               quirks => 1,  
                                               line => $l, column => $c,  
                                              };  
                     !!!next-input-character;  
                     redo A;  
                   } else {  
                     !!!cp (130);  
                   }  
                 } else {  
                   !!!cp (131);  
                 }  
               } else {  
                 !!!cp (132);  
               }  
             } else {  
               !!!cp (133);  
             }  
           } else {  
             !!!cp (134);  
           }  
         } else {  
           !!!cp (135);  
         }  
2047        } elsif ($self->{insertion_mode} & IN_FOREIGN_CONTENT_IM and        } elsif ($self->{insertion_mode} & IN_FOREIGN_CONTENT_IM and
2048                 $self->{open_elements}->[-1]->[1] & FOREIGN_EL and                 $self->{open_elements}->[-1]->[1] & FOREIGN_EL and
2049                 $self->{next_char} == 0x005B) { # [                 $self->{next_char} == 0x005B) { # [
2050            !!!cp (135.4);                
2051            $self->{state} = MD_CDATA_STATE;
2052            $self->{state_keyword} = '[';
2053          !!!next-input-character;          !!!next-input-character;
2054          push @next_char, $self->{next_char};          redo A;
         if ($self->{next_char} == 0x0043) { # C  
           !!!next-input-character;  
           push @next_char, $self->{next_char};  
           if ($self->{next_char} == 0x0044) { # D  
             !!!next-input-character;  
             push @next_char, $self->{next_char};  
             if ($self->{next_char} == 0x0041) { # A  
               !!!next-input-character;  
               push @next_char, $self->{next_char};  
               if ($self->{next_char} == 0x0054) { # T  
                 !!!next-input-character;  
                 push @next_char, $self->{next_char};  
                 if ($self->{next_char} == 0x0041) { # A  
                   !!!next-input-character;  
                   push @next_char, $self->{next_char};  
                   if ($self->{next_char} == 0x005B) { # [  
                     !!!cp (135.1);  
                     $self->{state} = CDATA_BLOCK_STATE;  
                     !!!next-input-character;  
                     redo A;  
                   } else {  
                     !!!cp (135.2);  
                   }  
                 } else {  
                   !!!cp (135.3);  
                 }  
               } else {  
                 !!!cp (135.4);                  
               }  
             } else {  
               !!!cp (135.5);  
             }  
           } else {  
             !!!cp (135.6);  
           }  
         } else {  
           !!!cp (135.7);  
         }  
2055        } else {        } else {
2056          !!!cp (136);          !!!cp (136);
2057        }        }
2058    
2059        !!!parse-error (type => 'bogus comment');        !!!parse-error (type => 'bogus comment',
2060        $self->{next_char} = shift @next_char;                        line => $self->{line_prev},
2061        !!!back-next-input-character (@next_char);                        column => $self->{column_prev} - 1);
2062          ## Reconsume.
2063        $self->{state} = BOGUS_COMMENT_STATE;        $self->{state} = BOGUS_COMMENT_STATE;
2064        $self->{current_token} = {type => COMMENT_TOKEN, data => '',        $self->{current_token} = {type => COMMENT_TOKEN, data => '',
2065                                  line => $l, column => $c,                                  line => $self->{line_prev},
2066                                    column => $self->{column_prev} - 1,
2067                                 };                                 };
2068        redo A;        redo A;
2069              } elsif ($self->{state} == MD_HYPHEN_STATE) {
2070        ## ISSUE: typos in spec: chacacters, is is a parse error        if ($self->{next_char} == 0x002D) { # -
2071        ## ISSUE: spec is somewhat unclear on "is the first character that will be in the comment"; what is "that will be in the comment" is what the algorithm defines, isn't it?          !!!cp (127);
2072            $self->{current_token} = {type => COMMENT_TOKEN, data => '',
2073                                      line => $self->{line_prev},
2074                                      column => $self->{column_prev} - 2,
2075                                     };
2076            $self->{state} = COMMENT_START_STATE;
2077            !!!next-input-character;
2078            redo A;
2079          } else {
2080            !!!cp (128);
2081            !!!parse-error (type => 'bogus comment',
2082                            line => $self->{line_prev},
2083                            column => $self->{column_prev} - 2);
2084            $self->{state} = BOGUS_COMMENT_STATE;
2085            ## Reconsume.
2086            $self->{current_token} = {type => COMMENT_TOKEN,
2087                                      data => '-',
2088                                      line => $self->{line_prev},
2089                                      column => $self->{column_prev} - 2,
2090                                     };
2091            redo A;
2092          }
2093        } elsif ($self->{state} == MD_DOCTYPE_STATE) {
2094          ## ASCII case-insensitive.
2095          if ($self->{next_char} == [
2096                undef,
2097                0x004F, # O
2098                0x0043, # C
2099                0x0054, # T
2100                0x0059, # Y
2101                0x0050, # P
2102              ]->[length $self->{state_keyword}] or
2103              $self->{next_char} == [
2104                undef,
2105                0x006F, # o
2106                0x0063, # c
2107                0x0074, # t
2108                0x0079, # y
2109                0x0070, # p
2110              ]->[length $self->{state_keyword}]) {
2111            !!!cp (131);
2112            ## Stay in the state.
2113            $self->{state_keyword} .= chr $self->{next_char};
2114            !!!next-input-character;
2115            redo A;
2116          } elsif ((length $self->{state_keyword}) == 6 and
2117                   ($self->{next_char} == 0x0045 or # E
2118                    $self->{next_char} == 0x0065)) { # e
2119            !!!cp (129);
2120            $self->{state} = DOCTYPE_STATE;
2121            $self->{current_token} = {type => DOCTYPE_TOKEN,
2122                                      quirks => 1,
2123                                      line => $self->{line_prev},
2124                                      column => $self->{column_prev} - 7,
2125                                     };
2126            !!!next-input-character;
2127            redo A;
2128          } else {
2129            !!!cp (132);        
2130            !!!parse-error (type => 'bogus comment',
2131                            line => $self->{line_prev},
2132                            column => $self->{column_prev} - 1 - length $self->{state_keyword});
2133            $self->{state} = BOGUS_COMMENT_STATE;
2134            ## Reconsume.
2135            $self->{current_token} = {type => COMMENT_TOKEN,
2136                                      data => $self->{state_keyword},
2137                                      line => $self->{line_prev},
2138                                      column => $self->{column_prev} - 1 - length $self->{state_keyword},
2139                                     };
2140            redo A;
2141          }
2142        } elsif ($self->{state} == MD_CDATA_STATE) {
2143          if ($self->{next_char} == {
2144                '[' => 0x0043, # C
2145                '[C' => 0x0044, # D
2146                '[CD' => 0x0041, # A
2147                '[CDA' => 0x0054, # T
2148                '[CDAT' => 0x0041, # A
2149              }->{$self->{state_keyword}}) {
2150            !!!cp (135.1);
2151            ## Stay in the state.
2152            $self->{state_keyword} .= chr $self->{next_char};
2153            !!!next-input-character;
2154            redo A;
2155          } elsif ($self->{state_keyword} eq '[CDATA' and
2156                   $self->{next_char} == 0x005B) { # [
2157            !!!cp (135.2);
2158            $self->{current_token} = {type => CHARACTER_TOKEN,
2159                                      data => '',
2160                                      line => $self->{line_prev},
2161                                      column => $self->{column_prev} - 7};
2162            $self->{state} = CDATA_SECTION_STATE;
2163            !!!next-input-character;
2164            redo A;
2165          } else {
2166            !!!cp (135.3);
2167            !!!parse-error (type => 'bogus comment',
2168                            line => $self->{line_prev},
2169                            column => $self->{column_prev} - 1 - length $self->{state_keyword});
2170            $self->{state} = BOGUS_COMMENT_STATE;
2171            ## Reconsume.
2172            $self->{current_token} = {type => COMMENT_TOKEN,
2173                                      data => $self->{state_keyword},
2174                                      line => $self->{line_prev},
2175                                      column => $self->{column_prev} - 1 - length $self->{state_keyword},
2176                                     };
2177            redo A;
2178          }
2179      } elsif ($self->{state} == COMMENT_START_STATE) {      } elsif ($self->{state} == COMMENT_START_STATE) {
2180        if ($self->{next_char} == 0x002D) { # -        if ($self->{next_char} == 0x002D) { # -
2181          !!!cp (137);          !!!cp (137);
# Line 2349  sub _get_next_token ($) { Line 2442  sub _get_next_token ($) {
2442          redo A;          redo A;
2443        } elsif ($self->{next_char} == 0x0050 or # P        } elsif ($self->{next_char} == 0x0050 or # P
2444                 $self->{next_char} == 0x0070) { # p                 $self->{next_char} == 0x0070) { # p
2445            $self->{state} = PUBLIC_STATE;
2446            $self->{state_keyword} = chr $self->{next_char};
2447          !!!next-input-character;          !!!next-input-character;
2448          if ($self->{next_char} == 0x0055 or # U          redo A;
             $self->{next_char} == 0x0075) { # u  
           !!!next-input-character;  
           if ($self->{next_char} == 0x0042 or # B  
               $self->{next_char} == 0x0062) { # b  
             !!!next-input-character;  
             if ($self->{next_char} == 0x004C or # L  
                 $self->{next_char} == 0x006C) { # l  
               !!!next-input-character;  
               if ($self->{next_char} == 0x0049 or # I  
                   $self->{next_char} == 0x0069) { # i  
                 !!!next-input-character;  
                 if ($self->{next_char} == 0x0043 or # C  
                     $self->{next_char} == 0x0063) { # c  
                   !!!cp (168);  
                   $self->{state} = BEFORE_DOCTYPE_PUBLIC_IDENTIFIER_STATE;  
                   !!!next-input-character;  
                   redo A;  
                 } else {  
                   !!!cp (169);  
                 }  
               } else {  
                 !!!cp (170);  
               }  
             } else {  
               !!!cp (171);  
             }  
           } else {  
             !!!cp (172);  
           }  
         } else {  
           !!!cp (173);  
         }  
   
         #  
2449        } elsif ($self->{next_char} == 0x0053 or # S        } elsif ($self->{next_char} == 0x0053 or # S
2450                 $self->{next_char} == 0x0073) { # s                 $self->{next_char} == 0x0073) { # s
2451            $self->{state} = SYSTEM_STATE;
2452            $self->{state_keyword} = chr $self->{next_char};
2453          !!!next-input-character;          !!!next-input-character;
2454          if ($self->{next_char} == 0x0059 or # Y          redo A;
             $self->{next_char} == 0x0079) { # y  
           !!!next-input-character;  
           if ($self->{next_char} == 0x0053 or # S  
               $self->{next_char} == 0x0073) { # s  
             !!!next-input-character;  
             if ($self->{next_char} == 0x0054 or # T  
                 $self->{next_char} == 0x0074) { # t  
               !!!next-input-character;  
               if ($self->{next_char} == 0x0045 or # E  
                   $self->{next_char} == 0x0065) { # e  
                 !!!next-input-character;  
                 if ($self->{next_char} == 0x004D or # M  
                     $self->{next_char} == 0x006D) { # m  
                   !!!cp (174);  
                   $self->{state} = BEFORE_DOCTYPE_SYSTEM_IDENTIFIER_STATE;  
                   !!!next-input-character;  
                   redo A;  
                 } else {  
                   !!!cp (175);  
                 }  
               } else {  
                 !!!cp (176);  
               }  
             } else {  
               !!!cp (177);  
             }  
           } else {  
             !!!cp (178);  
           }  
         } else {  
           !!!cp (179);  
         }  
   
         #  
2455        } else {        } else {
2456          !!!cp (180);          !!!cp (180);
2457            !!!parse-error (type => 'string after DOCTYPE name');
2458            $self->{current_token}->{quirks} = 1;
2459    
2460            $self->{state} = BOGUS_DOCTYPE_STATE;
2461          !!!next-input-character;          !!!next-input-character;
2462          #          redo A;
2463        }        }
2464        } elsif ($self->{state} == PUBLIC_STATE) {
2465          ## ASCII case-insensitive
2466          if ($self->{next_char} == [
2467                undef,
2468                0x0055, # U
2469                0x0042, # B
2470                0x004C, # L
2471                0x0049, # I
2472              ]->[length $self->{state_keyword}] or
2473              $self->{next_char} == [
2474                undef,
2475                0x0075, # u
2476                0x0062, # b
2477                0x006C, # l
2478                0x0069, # i
2479              ]->[length $self->{state_keyword}]) {
2480            !!!cp (175);
2481            ## Stay in the state.
2482            $self->{state_keyword} .= chr $self->{next_char};
2483            !!!next-input-character;
2484            redo A;
2485          } elsif ((length $self->{state_keyword}) == 5 and
2486                   ($self->{next_char} == 0x0043 or # C
2487                    $self->{next_char} == 0x0063)) { # c
2488            !!!cp (168);
2489            $self->{state} = BEFORE_DOCTYPE_PUBLIC_IDENTIFIER_STATE;
2490            !!!next-input-character;
2491            redo A;
2492          } else {
2493            !!!cp (169);
2494            !!!parse-error (type => 'string after DOCTYPE name',
2495                            line => $self->{line_prev},
2496                            column => $self->{column_prev} + 1 - length $self->{state_keyword});
2497            $self->{current_token}->{quirks} = 1;
2498    
2499        !!!parse-error (type => 'string after DOCTYPE name');          $self->{state} = BOGUS_DOCTYPE_STATE;
2500        $self->{current_token}->{quirks} = 1;          ## Reconsume.
2501            redo A;
2502          }
2503        } elsif ($self->{state} == SYSTEM_STATE) {
2504          ## ASCII case-insensitive
2505          if ($self->{next_char} == [
2506                undef,
2507                0x0059, # Y
2508                0x0053, # S
2509                0x0054, # T
2510                0x0045, # E
2511              ]->[length $self->{state_keyword}] or
2512              $self->{next_char} == [
2513                undef,
2514                0x0079, # y
2515                0x0073, # s
2516                0x0074, # t
2517                0x0065, # e
2518              ]->[length $self->{state_keyword}]) {
2519            !!!cp (170);
2520            ## Stay in the state.
2521            $self->{state_keyword} .= chr $self->{next_char};
2522            !!!next-input-character;
2523            redo A;
2524          } elsif ((length $self->{state_keyword}) == 5 and
2525                   ($self->{next_char} == 0x004D or # M
2526                    $self->{next_char} == 0x006D)) { # m
2527            !!!cp (171);
2528            $self->{state} = BEFORE_DOCTYPE_SYSTEM_IDENTIFIER_STATE;
2529            !!!next-input-character;
2530            redo A;
2531          } else {
2532            !!!cp (172);
2533            !!!parse-error (type => 'string after DOCTYPE name',
2534                            line => $self->{line_prev},
2535                            column => $self->{column_prev} + 1 - length $self->{state_keyword});
2536            $self->{current_token}->{quirks} = 1;
2537    
2538        $self->{state} = BOGUS_DOCTYPE_STATE;          $self->{state} = BOGUS_DOCTYPE_STATE;
2539        # next-input-character is already done          ## Reconsume.
2540        redo A;          redo A;
2541          }
2542      } elsif ($self->{state} == BEFORE_DOCTYPE_PUBLIC_IDENTIFIER_STATE) {      } elsif ($self->{state} == BEFORE_DOCTYPE_PUBLIC_IDENTIFIER_STATE) {
2543        if ({        if ({
2544              0x0009 => 1, 0x000A => 1, 0x000B => 1, 0x000C => 1, 0x0020 => 1,              0x0009 => 1, 0x000A => 1, 0x000B => 1, 0x000C => 1, 0x0020 => 1,
# Line 2667  sub _get_next_token ($) { Line 2771  sub _get_next_token ($) {
2771          redo A;          redo A;
2772        } elsif ($self->{next_char} == 0x003E) { # >        } elsif ($self->{next_char} == 0x003E) { # >
2773          !!!cp (208);          !!!cp (208);
2774          !!!parse-error (type => 'unclosed PUBLIC literal');          !!!parse-error (type => 'unclosed SYSTEM literal');
2775    
2776          $self->{state} = DATA_STATE;          $self->{state} = DATA_STATE;
2777          !!!next-input-character;          !!!next-input-character;
# Line 2703  sub _get_next_token ($) { Line 2807  sub _get_next_token ($) {
2807          redo A;          redo A;
2808        } elsif ($self->{next_char} == 0x003E) { # >        } elsif ($self->{next_char} == 0x003E) { # >
2809          !!!cp (212);          !!!cp (212);
2810          !!!parse-error (type => 'unclosed PUBLIC literal');          !!!parse-error (type => 'unclosed SYSTEM literal');
2811    
2812          $self->{state} = DATA_STATE;          $self->{state} = DATA_STATE;
2813          !!!next-input-character;          !!!next-input-character;
# Line 2791  sub _get_next_token ($) { Line 2895  sub _get_next_token ($) {
2895          !!!next-input-character;          !!!next-input-character;
2896          redo A;          redo A;
2897        }        }
2898      } elsif ($self->{state} == CDATA_BLOCK_STATE) {      } elsif ($self->{state} == CDATA_SECTION_STATE) {
2899        my $s = '';        ## NOTE: "CDATA section state" in the state is jointly implemented
2900          ## by three states, |CDATA_SECTION_STATE|, |CDATA_SECTION_MSE1_STATE|,
2901          ## and |CDATA_SECTION_MSE2_STATE|.
2902                
2903        my ($l, $c) = ($self->{line}, $self->{column});        if ($self->{next_char} == 0x005D) { # ]
2904            !!!cp (221.1);
2905            $self->{state} = CDATA_SECTION_MSE1_STATE;
2906            !!!next-input-character;
2907            redo A;
2908          } elsif ($self->{next_char} == -1) {
2909            $self->{state} = DATA_STATE;
2910            !!!next-input-character;
2911            if (length $self->{current_token}->{data}) { # character
2912              !!!cp (221.2);
2913              !!!emit ($self->{current_token}); # character
2914            } else {
2915              !!!cp (221.3);
2916              ## No token to emit. $self->{current_token} is discarded.
2917            }        
2918            redo A;
2919          } else {
2920            !!!cp (221.4);
2921            $self->{current_token}->{data} .= chr $self->{next_char};
2922            ## Stay in the state.
2923            !!!next-input-character;
2924            redo A;
2925          }
2926    
2927        CS: while ($self->{next_char} != -1) {        ## ISSUE: "text tokens" in spec.
2928          if ($self->{next_char} == 0x005D) { # ]      } elsif ($self->{state} == CDATA_SECTION_MSE1_STATE) {
2929            !!!next-input-character;        if ($self->{next_char} == 0x005D) { # ]
2930            if ($self->{next_char} == 0x005D) { # ]          !!!cp (221.5);
2931              !!!next-input-character;          $self->{state} = CDATA_SECTION_MSE2_STATE;
2932              MDC: {          !!!next-input-character;
2933                if ($self->{next_char} == 0x003E) { # >          redo A;
2934                  !!!cp (221.1);        } else {
2935                  !!!next-input-character;          !!!cp (221.6);
2936                  last CS;          $self->{current_token}->{data} .= ']';
2937                } elsif ($self->{next_char} == 0x005D) { # ]          $self->{state} = CDATA_SECTION_STATE;
2938                  !!!cp (221.2);          ## Reconsume.
2939                  $s .= ']';          redo A;
2940                  !!!next-input-character;        }
2941                  redo MDC;      } elsif ($self->{state} == CDATA_SECTION_MSE2_STATE) {
2942                } else {        if ($self->{next_char} == 0x003E) { # >
2943                  !!!cp (221.3);          $self->{state} = DATA_STATE;
2944                  $s .= ']]';          !!!next-input-character;
2945                  #          if (length $self->{current_token}->{data}) { # character
2946                }            !!!cp (221.7);
2947              } # MDC            !!!emit ($self->{current_token}); # character
           } else {  
             !!!cp (221.4);  
             $s .= ']';  
             #  
           }  
2948          } else {          } else {
2949            !!!cp (221.5);            !!!cp (221.8);
2950            #            ## No token to emit. $self->{current_token} is discarded.
2951          }          }
2952          $s .= chr $self->{next_char};          redo A;
2953          } elsif ($self->{next_char} == 0x005D) { # ]
2954            !!!cp (221.9); # character
2955            $self->{current_token}->{data} .= ']'; ## Add first "]" of "]]]".
2956            ## Stay in the state.
2957          !!!next-input-character;          !!!next-input-character;
2958        } # CS          redo A;
   
       $self->{state} = DATA_STATE;  
       ## next-input-character done or EOF, which is reconsumed.  
   
       if (length $s) {  
         !!!cp (221.6);  
         !!!emit ({type => CHARACTER_TOKEN, data => $s,  
                   line => $l, column => $c});  
2959        } else {        } else {
2960          !!!cp (221.7);          !!!cp (221.11);
2961            $self->{current_token}->{data} .= ']]'; # character
2962            $self->{state} = CDATA_SECTION_STATE;
2963            ## Reconsume.
2964            redo A;
2965        }        }
   
       redo A;  
   
       ## ISSUE: "text tokens" in spec.  
       ## TODO: Streaming support  
2966      } else {      } else {
2967        die "$0: $self->{state}: Unknown state";        die "$0: $self->{state}: Unknown state";
2968      }      }
# Line 2912  sub _tokenize_attempt_to_consume_an_enti Line 3030  sub _tokenize_attempt_to_consume_an_enti
3030    
3031          if ($code == 0 or (0xD800 <= $code and $code <= 0xDFFF)) {          if ($code == 0 or (0xD800 <= $code and $code <= 0xDFFF)) {
3032            !!!cp (1008);            !!!cp (1008);
3033            !!!parse-error (type => (sprintf 'invalid character reference:U+%04X', $code), line => $l, column => $c);            !!!parse-error (type => 'invalid character reference',
3034                              text => (sprintf 'U+%04X', $code),
3035                              line => $l, column => $c);
3036            $code = 0xFFFD;            $code = 0xFFFD;
3037          } elsif ($code > 0x10FFFF) {          } elsif ($code > 0x10FFFF) {
3038            !!!cp (1009);            !!!cp (1009);
3039            !!!parse-error (type => (sprintf 'invalid character reference:U-%08X', $code), line => $l, column => $c);            !!!parse-error (type => 'invalid character reference',
3040                              text => (sprintf 'U-%08X', $code),
3041                              line => $l, column => $c);
3042            $code = 0xFFFD;            $code = 0xFFFD;
3043          } elsif ($code == 0x000D) {          } elsif ($code == 0x000D) {
3044            !!!cp (1010);            !!!cp (1010);
# Line 2924  sub _tokenize_attempt_to_consume_an_enti Line 3046  sub _tokenize_attempt_to_consume_an_enti
3046            $code = 0x000A;            $code = 0x000A;
3047          } elsif (0x80 <= $code and $code <= 0x9F) {          } elsif (0x80 <= $code and $code <= 0x9F) {
3048            !!!cp (1011);            !!!cp (1011);
3049            !!!parse-error (type => (sprintf 'C1 character reference:U+%04X', $code), line => $l, column => $c);            !!!parse-error (type => 'C1 character reference', text => (sprintf 'U+%04X', $code), line => $l, column => $c);
3050            $code = $c1_entity_char->{$code};            $code = $c1_entity_char->{$code};
3051          }          }
3052    
# Line 2957  sub _tokenize_attempt_to_consume_an_enti Line 3079  sub _tokenize_attempt_to_consume_an_enti
3079    
3080        if ($code == 0 or (0xD800 <= $code and $code <= 0xDFFF)) {        if ($code == 0 or (0xD800 <= $code and $code <= 0xDFFF)) {
3081          !!!cp (1015);          !!!cp (1015);
3082          !!!parse-error (type => (sprintf 'invalid character reference:U+%04X', $code), line => $l, column => $c);          !!!parse-error (type => 'invalid character reference',
3083                            text => (sprintf 'U+%04X', $code),
3084                            line => $l, column => $c);
3085          $code = 0xFFFD;          $code = 0xFFFD;
3086        } elsif ($code > 0x10FFFF) {        } elsif ($code > 0x10FFFF) {
3087          !!!cp (1016);          !!!cp (1016);
3088          !!!parse-error (type => (sprintf 'invalid character reference:U-%08X', $code), line => $l, column => $c);          !!!parse-error (type => 'invalid character reference',
3089                            text => (sprintf 'U-%08X', $code),
3090                            line => $l, column => $c);
3091          $code = 0xFFFD;          $code = 0xFFFD;
3092        } elsif ($code == 0x000D) {        } elsif ($code == 0x000D) {
3093          !!!cp (1017);          !!!cp (1017);
3094          !!!parse-error (type => 'CR character reference', line => $l, column => $c);          !!!parse-error (type => 'CR character reference',
3095                            line => $l, column => $c);
3096          $code = 0x000A;          $code = 0x000A;
3097        } elsif (0x80 <= $code and $code <= 0x9F) {        } elsif (0x80 <= $code and $code <= 0x9F) {
3098          !!!cp (1018);          !!!cp (1018);
3099          !!!parse-error (type => (sprintf 'C1 character reference:U+%04X', $code), line => $l, column => $c);          !!!parse-error (type => 'C1 character reference',
3100                            text => (sprintf 'U+%04X', $code),
3101                            line => $l, column => $c);
3102          $code = $c1_entity_char->{$code};          $code = $c1_entity_char->{$code};
3103        }        }
3104                
# Line 3067  sub _initialize_tree_constructor ($) { Line 3196  sub _initialize_tree_constructor ($) {
3196    ## TODO: Turn mutation events off # MUST    ## TODO: Turn mutation events off # MUST
3197    ## TODO: Turn loose Document option (manakai extension) on    ## TODO: Turn loose Document option (manakai extension) on
3198    $self->{document}->manakai_is_html (1); # MUST    $self->{document}->manakai_is_html (1); # MUST
3199      $self->{document}->set_user_data (manakai_source_line => 1);
3200      $self->{document}->set_user_data (manakai_source_column => 1);
3201  } # _initialize_tree_constructor  } # _initialize_tree_constructor
3202    
3203  sub _terminate_tree_constructor ($) {  sub _terminate_tree_constructor ($) {
# Line 3121  sub _tree_construction_initial ($) { Line 3252  sub _tree_construction_initial ($) {
3252        ## language.        ## language.
3253        my $doctype_name = $token->{name};        my $doctype_name = $token->{name};
3254        $doctype_name = '' unless defined $doctype_name;        $doctype_name = '' unless defined $doctype_name;
3255        $doctype_name =~ tr/a-z/A-Z/;        $doctype_name =~ tr/a-z/A-Z/; # ASCII case-insensitive
3256        if (not defined $token->{name} or # <!DOCTYPE>        if (not defined $token->{name} or # <!DOCTYPE>
           defined $token->{public_identifier} or  
3257            defined $token->{system_identifier}) {            defined $token->{system_identifier}) {
3258          !!!cp ('t1');          !!!cp ('t1');
3259          !!!parse-error (type => 'not HTML5', token => $token);          !!!parse-error (type => 'not HTML5', token => $token);
3260        } elsif ($doctype_name ne 'HTML') {        } elsif ($doctype_name ne 'HTML') {
3261          !!!cp ('t2');          !!!cp ('t2');
         ## ISSUE: ASCII case-insensitive? (in fact it does not matter)  
3262          !!!parse-error (type => 'not HTML5', token => $token);          !!!parse-error (type => 'not HTML5', token => $token);
3263          } elsif (defined $token->{public_identifier}) {
3264            if ($token->{public_identifier} eq 'XSLT-compat') {
3265              !!!cp ('t1.2');
3266              !!!parse-error (type => 'XSLT-compat', token => $token,
3267                              level => $self->{level}->{should});
3268            } else {
3269              !!!parse-error (type => 'not HTML5', token => $token);
3270            }
3271        } else {        } else {
3272          !!!cp ('t3');          !!!cp ('t3');
3273            #
3274        }        }
3275                
3276        my $doctype = $self->{document}->create_document_type_definition        my $doctype = $self->{document}->create_document_type_definition
# Line 3634  sub _tree_construction_main ($) { Line 3772  sub _tree_construction_main ($) {
3772        ## NOTE: An end-of-file token.        ## NOTE: An end-of-file token.
3773        if ($content_model_flag == CDATA_CONTENT_MODEL) {        if ($content_model_flag == CDATA_CONTENT_MODEL) {
3774          !!!cp ('t43');          !!!cp ('t43');
3775          !!!parse-error (type => 'in CDATA:#'.$token->{type}, token => $token);          !!!parse-error (type => 'in CDATA:#eof', token => $token);
3776        } elsif ($content_model_flag == RCDATA_CONTENT_MODEL) {        } elsif ($content_model_flag == RCDATA_CONTENT_MODEL) {
3777          !!!cp ('t44');          !!!cp ('t44');
3778          !!!parse-error (type => 'in RCDATA:#'.$token->{type}, token => $token);          !!!parse-error (type => 'in RCDATA:#eof', token => $token);
3779        } else {        } else {
3780          die "$0: $content_model_flag in parse_rcdata";          die "$0: $content_model_flag in parse_rcdata";
3781        }        }
# Line 3674  sub _tree_construction_main ($) { Line 3812  sub _tree_construction_main ($) {
3812        ## Ignore the token        ## Ignore the token
3813      } else {      } else {
3814        !!!cp ('t48');        !!!cp ('t48');
3815        !!!parse-error (type => 'in CDATA:#'.$token->{type}, token => $token);        !!!parse-error (type => 'in CDATA:#eof', token => $token);
3816        ## ISSUE: And ignore?        ## ISSUE: And ignore?
3817        ## TODO: mark as "already executed"        ## TODO: mark as "already executed"
3818      }      }
# Line 3725  sub _tree_construction_main ($) { Line 3863  sub _tree_construction_main ($) {
3863        } # AFE        } # AFE
3864        unless (defined $formatting_element) {        unless (defined $formatting_element) {
3865          !!!cp ('t53');          !!!cp ('t53');
3866          !!!parse-error (type => 'unmatched end tag:'.$tag_name, token => $end_tag_token);          !!!parse-error (type => 'unmatched end tag', text => $tag_name, token => $end_tag_token);
3867          ## Ignore the token          ## Ignore the token
3868          !!!next-token;          !!!next-token;
3869          return;          return;
# Line 3742  sub _tree_construction_main ($) { Line 3880  sub _tree_construction_main ($) {
3880              last INSCOPE;              last INSCOPE;
3881            } else { # in open elements but not in scope            } else { # in open elements but not in scope
3882              !!!cp ('t55');              !!!cp ('t55');
3883              !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name},              !!!parse-error (type => 'unmatched end tag',
3884                                text => $token->{tag_name},
3885                              token => $end_tag_token);                              token => $end_tag_token);
3886              ## Ignore the token              ## Ignore the token
3887              !!!next-token;              !!!next-token;
# Line 3755  sub _tree_construction_main ($) { Line 3894  sub _tree_construction_main ($) {
3894        } # INSCOPE        } # INSCOPE
3895        unless (defined $formatting_element_i_in_open) {        unless (defined $formatting_element_i_in_open) {
3896          !!!cp ('t57');          !!!cp ('t57');
3897          !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name},          !!!parse-error (type => 'unmatched end tag',
3898                            text => $token->{tag_name},
3899                          token => $end_tag_token);                          token => $end_tag_token);
3900          pop @$active_formatting_elements; # $formatting_element          pop @$active_formatting_elements; # $formatting_element
3901          !!!next-token; ## TODO: ok?          !!!next-token; ## TODO: ok?
# Line 3764  sub _tree_construction_main ($) { Line 3904  sub _tree_construction_main ($) {
3904        if (not $self->{open_elements}->[-1]->[0] eq $formatting_element->[0]) {        if (not $self->{open_elements}->[-1]->[0] eq $formatting_element->[0]) {
3905          !!!cp ('t58');          !!!cp ('t58');
3906          !!!parse-error (type => 'not closed',          !!!parse-error (type => 'not closed',
3907                          value => $self->{open_elements}->[-1]->[0]                          text => $self->{open_elements}->[-1]->[0]
3908                              ->manakai_local_name,                              ->manakai_local_name,
3909                          token => $end_tag_token);                          token => $end_tag_token);
3910        }        }
# Line 3973  sub _tree_construction_main ($) { Line 4113  sub _tree_construction_main ($) {
4113    B: while (1) {    B: while (1) {
4114      if ($token->{type} == DOCTYPE_TOKEN) {      if ($token->{type} == DOCTYPE_TOKEN) {
4115        !!!cp ('t73');        !!!cp ('t73');
4116        !!!parse-error (type => 'DOCTYPE in the middle', token => $token);        !!!parse-error (type => 'in html:#DOCTYPE', token => $token);
4117        ## Ignore the token        ## Ignore the token
4118        ## Stay in the phase        ## Stay in the phase
4119        !!!next-token;        !!!next-token;
# Line 3982  sub _tree_construction_main ($) { Line 4122  sub _tree_construction_main ($) {
4122               $token->{tag_name} eq 'html') {               $token->{tag_name} eq 'html') {
4123        if ($self->{insertion_mode} == AFTER_HTML_BODY_IM) {        if ($self->{insertion_mode} == AFTER_HTML_BODY_IM) {
4124          !!!cp ('t79');          !!!cp ('t79');
4125          !!!parse-error (type => 'after html:html', token => $token);          !!!parse-error (type => 'after html', text => 'html', token => $token);
4126          $self->{insertion_mode} = AFTER_BODY_IM;          $self->{insertion_mode} = AFTER_BODY_IM;
4127        } elsif ($self->{insertion_mode} == AFTER_HTML_FRAMESET_IM) {        } elsif ($self->{insertion_mode} == AFTER_HTML_FRAMESET_IM) {
4128          !!!cp ('t80');          !!!cp ('t80');
4129          !!!parse-error (type => 'after html:html', token => $token);          !!!parse-error (type => 'after html', text => 'html', token => $token);
4130          $self->{insertion_mode} = AFTER_FRAMESET_IM;          $self->{insertion_mode} = AFTER_FRAMESET_IM;
4131        } else {        } else {
4132          !!!cp ('t81');          !!!cp ('t81');
# Line 4047  sub _tree_construction_main ($) { Line 4187  sub _tree_construction_main ($) {
4187                   }->{$token->{tag_name}}) {                   }->{$token->{tag_name}}) {
4188            !!!cp ('t87.2');            !!!cp ('t87.2');
4189            !!!parse-error (type => 'not closed',            !!!parse-error (type => 'not closed',
4190                            value => $self->{open_elements}->[-1]->[0]                            text => $self->{open_elements}->[-1]->[0]
4191                                ->manakai_local_name,                                ->manakai_local_name,
4192                            token => $token);                            token => $token);
4193    
# Line 4125  sub _tree_construction_main ($) { Line 4265  sub _tree_construction_main ($) {
4265        } elsif ($token->{type} == END_OF_FILE_TOKEN) {        } elsif ($token->{type} == END_OF_FILE_TOKEN) {
4266          !!!cp ('t87.6');          !!!cp ('t87.6');
4267          !!!parse-error (type => 'not closed',          !!!parse-error (type => 'not closed',
4268                          value => $self->{open_elements}->[-1]->[0]                          text => $self->{open_elements}->[-1]->[0]
4269                              ->manakai_local_name,                              ->manakai_local_name,
4270                          token => $token);                          token => $token);
4271    
# Line 4175  sub _tree_construction_main ($) { Line 4315  sub _tree_construction_main ($) {
4315            !!!cp ('t90');            !!!cp ('t90');
4316            ## As if </noscript>            ## As if </noscript>
4317            pop @{$self->{open_elements}};            pop @{$self->{open_elements}};
4318            !!!parse-error (type => 'in noscript:#character', token => $token);            !!!parse-error (type => 'in noscript:#text', token => $token);
4319                        
4320            ## Reprocess in the "in head" insertion mode...            ## Reprocess in the "in head" insertion mode...
4321            ## As if </head>            ## As if </head>
# Line 4212  sub _tree_construction_main ($) { Line 4352  sub _tree_construction_main ($) {
4352              next B;              next B;
4353            } elsif ($self->{insertion_mode} == AFTER_HEAD_IM) {            } elsif ($self->{insertion_mode} == AFTER_HEAD_IM) {
4354              !!!cp ('t93.2');              !!!cp ('t93.2');
4355              !!!parse-error (type => 'after head:head', token => $token); ## TODO: error type              !!!parse-error (type => 'after head', text => 'head',
4356                                token => $token);
4357              ## Ignore the token              ## Ignore the token
4358              !!!nack ('t93.3');              !!!nack ('t93.3');
4359              !!!next-token;              !!!next-token;
4360              next B;              next B;
4361            } else {            } else {
4362              !!!cp ('t95');              !!!cp ('t95');
4363              !!!parse-error (type => 'in head:head', token => $token); # or in head noscript              !!!parse-error (type => 'in head:head',
4364                                token => $token); # or in head noscript
4365              ## Ignore the token              ## Ignore the token
4366              !!!nack ('t95.1');              !!!nack ('t95.1');
4367              !!!next-token;              !!!next-token;
# Line 4244  sub _tree_construction_main ($) { Line 4386  sub _tree_construction_main ($) {
4386                  !!!cp ('t98');                  !!!cp ('t98');
4387                  ## As if </noscript>                  ## As if </noscript>
4388                  pop @{$self->{open_elements}};                  pop @{$self->{open_elements}};
4389                  !!!parse-error (type => 'in noscript:base', token => $token);                  !!!parse-error (type => 'in noscript', text => 'base',
4390                                    token => $token);
4391                                
4392                  $self->{insertion_mode} = IN_HEAD_IM;                  $self->{insertion_mode} = IN_HEAD_IM;
4393                  ## Reprocess in the "in head" insertion mode...                  ## Reprocess in the "in head" insertion mode...
# Line 4255  sub _tree_construction_main ($) { Line 4398  sub _tree_construction_main ($) {
4398                ## NOTE: There is a "as if in head" code clone.                ## NOTE: There is a "as if in head" code clone.
4399                if ($self->{insertion_mode} == AFTER_HEAD_IM) {                if ($self->{insertion_mode} == AFTER_HEAD_IM) {
4400                  !!!cp ('t100');                  !!!cp ('t100');
4401                  !!!parse-error (type => 'after head:'.$token->{tag_name}, token => $token);                  !!!parse-error (type => 'after head',
4402                                    text => $token->{tag_name}, token => $token);
4403                  push @{$self->{open_elements}},                  push @{$self->{open_elements}},
4404                      [$self->{head_element}, $el_category->{head}];                      [$self->{head_element}, $el_category->{head}];
4405                } else {                } else {
# Line 4272  sub _tree_construction_main ($) { Line 4416  sub _tree_construction_main ($) {
4416                ## NOTE: There is a "as if in head" code clone.                ## NOTE: There is a "as if in head" code clone.
4417                if ($self->{insertion_mode} == AFTER_HEAD_IM) {                if ($self->{insertion_mode} == AFTER_HEAD_IM) {
4418                  !!!cp ('t102');                  !!!cp ('t102');
4419                  !!!parse-error (type => 'after head:'.$token->{tag_name}, token => $token);                  !!!parse-error (type => 'after head',
4420                                    text => $token->{tag_name}, token => $token);
4421                  push @{$self->{open_elements}},                  push @{$self->{open_elements}},
4422                      [$self->{head_element}, $el_category->{head}];                      [$self->{head_element}, $el_category->{head}];
4423                } else {                } else {
# Line 4289  sub _tree_construction_main ($) { Line 4434  sub _tree_construction_main ($) {
4434                ## NOTE: There is a "as if in head" code clone.                ## NOTE: There is a "as if in head" code clone.
4435                if ($self->{insertion_mode} == AFTER_HEAD_IM) {                if ($self->{insertion_mode} == AFTER_HEAD_IM) {
4436                  !!!cp ('t104');                  !!!cp ('t104');
4437                  !!!parse-error (type => 'after head:'.$token->{tag_name}, token => $token);                  !!!parse-error (type => 'after head',
4438                                    text => $token->{tag_name}, token => $token);
4439                  push @{$self->{open_elements}},                  push @{$self->{open_elements}},
4440                      [$self->{head_element}, $el_category->{head}];                      [$self->{head_element}, $el_category->{head}];
4441                } else {                } else {
# Line 4358  sub _tree_construction_main ($) { Line 4504  sub _tree_construction_main ($) {
4504                  !!!cp ('t111');                  !!!cp ('t111');
4505                  ## As if </noscript>                  ## As if </noscript>
4506                  pop @{$self->{open_elements}};                  pop @{$self->{open_elements}};
4507                  !!!parse-error (type => 'in noscript:title', token => $token);                  !!!parse-error (type => 'in noscript', text => 'title',
4508                                    token => $token);
4509                                
4510                  $self->{insertion_mode} = IN_HEAD_IM;                  $self->{insertion_mode} = IN_HEAD_IM;
4511                  ## Reprocess in the "in head" insertion mode...                  ## Reprocess in the "in head" insertion mode...
4512                } elsif ($self->{insertion_mode} == AFTER_HEAD_IM) {                } elsif ($self->{insertion_mode} == AFTER_HEAD_IM) {
4513                  !!!cp ('t112');                  !!!cp ('t112');
4514                  !!!parse-error (type => 'after head:'.$token->{tag_name}, token => $token);                  !!!parse-error (type => 'after head',
4515                                    text => $token->{tag_name}, token => $token);
4516                  push @{$self->{open_elements}},                  push @{$self->{open_elements}},
4517                      [$self->{head_element}, $el_category->{head}];                      [$self->{head_element}, $el_category->{head}];
4518                } else {                } else {
# Line 4385  sub _tree_construction_main ($) { Line 4533  sub _tree_construction_main ($) {
4533                ## NOTE: There is a "as if in head" code clone.                ## NOTE: There is a "as if in head" code clone.
4534                if ($self->{insertion_mode} == AFTER_HEAD_IM) {                if ($self->{insertion_mode} == AFTER_HEAD_IM) {
4535                  !!!cp ('t114');                  !!!cp ('t114');
4536                  !!!parse-error (type => 'after head:'.$token->{tag_name}, token => $token);                  !!!parse-error (type => 'after head',
4537                                    text => $token->{tag_name}, token => $token);
4538                  push @{$self->{open_elements}},                  push @{$self->{open_elements}},
4539                      [$self->{head_element}, $el_category->{head}];                      [$self->{head_element}, $el_category->{head}];
4540                } else {                } else {
# Line 4406  sub _tree_construction_main ($) { Line 4555  sub _tree_construction_main ($) {
4555                  next B;                  next B;
4556                } elsif ($self->{insertion_mode} == IN_HEAD_NOSCRIPT_IM) {                } elsif ($self->{insertion_mode} == IN_HEAD_NOSCRIPT_IM) {
4557                  !!!cp ('t117');                  !!!cp ('t117');
4558                  !!!parse-error (type => 'in noscript:noscript', token => $token);                  !!!parse-error (type => 'in noscript', text => 'noscript',
4559                                    token => $token);
4560                  ## Ignore the token                  ## Ignore the token
4561                  !!!nack ('t117.1');                  !!!nack ('t117.1');
4562                  !!!next-token;                  !!!next-token;
# Line 4420  sub _tree_construction_main ($) { Line 4570  sub _tree_construction_main ($) {
4570                  !!!cp ('t119');                  !!!cp ('t119');
4571                  ## As if </noscript>                  ## As if </noscript>
4572                  pop @{$self->{open_elements}};                  pop @{$self->{open_elements}};
4573                  !!!parse-error (type => 'in noscript:script', token => $token);                  !!!parse-error (type => 'in noscript', text => 'script',
4574                                    token => $token);
4575                                
4576                  $self->{insertion_mode} = IN_HEAD_IM;                  $self->{insertion_mode} = IN_HEAD_IM;
4577                  ## Reprocess in the "in head" insertion mode...                  ## Reprocess in the "in head" insertion mode...
4578                } elsif ($self->{insertion_mode} == AFTER_HEAD_IM) {                } elsif ($self->{insertion_mode} == AFTER_HEAD_IM) {
4579                  !!!cp ('t120');                  !!!cp ('t120');
4580                  !!!parse-error (type => 'after head:'.$token->{tag_name}, token => $token);                  !!!parse-error (type => 'after head',
4581                                    text => $token->{tag_name}, token => $token);
4582                  push @{$self->{open_elements}},                  push @{$self->{open_elements}},
4583                      [$self->{head_element}, $el_category->{head}];                      [$self->{head_element}, $el_category->{head}];
4584                } else {                } else {
# Line 4444  sub _tree_construction_main ($) { Line 4596  sub _tree_construction_main ($) {
4596                  !!!cp ('t122');                  !!!cp ('t122');
4597                  ## As if </noscript>                  ## As if </noscript>
4598                  pop @{$self->{open_elements}};                  pop @{$self->{open_elements}};
4599                  !!!parse-error (type => 'in noscript:'.$token->{tag_name}, token => $token);                  !!!parse-error (type => 'in noscript',
4600                                    text => $token->{tag_name}, token => $token);
4601                                    
4602                  ## Reprocess in the "in head" insertion mode...                  ## Reprocess in the "in head" insertion mode...
4603                  ## As if </head>                  ## As if </head>
# Line 4483  sub _tree_construction_main ($) { Line 4636  sub _tree_construction_main ($) {
4636                !!!cp ('t129');                !!!cp ('t129');
4637                ## As if </noscript>                ## As if </noscript>
4638                pop @{$self->{open_elements}};                pop @{$self->{open_elements}};
4639                !!!parse-error (type => 'in noscript:/'.$token->{tag_name}, token => $token);                !!!parse-error (type => 'in noscript:/',
4640                                  text => $token->{tag_name}, token => $token);
4641                                
4642                ## Reprocess in the "in head" insertion mode...                ## Reprocess in the "in head" insertion mode...
4643                ## As if </head>                ## As if </head>
# Line 4526  sub _tree_construction_main ($) { Line 4680  sub _tree_construction_main ($) {
4680                  !!!cp ('t133');                  !!!cp ('t133');
4681                  ## As if </noscript>                  ## As if </noscript>
4682                  pop @{$self->{open_elements}};                  pop @{$self->{open_elements}};
4683                  !!!parse-error (type => 'in noscript:/head', token => $token);                  !!!parse-error (type => 'in noscript:/',
4684                                    text => 'head', token => $token);
4685                                    
4686                  ## Reprocess in the "in head" insertion mode...                  ## Reprocess in the "in head" insertion mode...
4687                  pop @{$self->{open_elements}};                  pop @{$self->{open_elements}};
# Line 4541  sub _tree_construction_main ($) { Line 4696  sub _tree_construction_main ($) {
4696                  next B;                  next B;
4697                } elsif ($self->{insertion_mode} == AFTER_HEAD_IM) {                } elsif ($self->{insertion_mode} == AFTER_HEAD_IM) {
4698                  !!!cp ('t134.1');                  !!!cp ('t134.1');
4699                  !!!parse-error (type => 'unmatched end tag:head', token => $token);                  !!!parse-error (type => 'unmatched end tag', text => 'head',
4700                                    token => $token);
4701                  ## Ignore the token                  ## Ignore the token
4702                  !!!next-token;                  !!!next-token;
4703                  next B;                  next B;
# Line 4558  sub _tree_construction_main ($) { Line 4714  sub _tree_construction_main ($) {
4714                } elsif ($self->{insertion_mode} == BEFORE_HEAD_IM or                } elsif ($self->{insertion_mode} == BEFORE_HEAD_IM or
4715                         $self->{insertion_mode} == AFTER_HEAD_IM) {                         $self->{insertion_mode} == AFTER_HEAD_IM) {
4716                  !!!cp ('t137');                  !!!cp ('t137');
4717                  !!!parse-error (type => 'unmatched end tag:noscript', token => $token);                  !!!parse-error (type => 'unmatched end tag',
4718                                    text => 'noscript', token => $token);
4719                  ## Ignore the token ## ISSUE: An issue in the spec.                  ## Ignore the token ## ISSUE: An issue in the spec.
4720                  !!!next-token;                  !!!next-token;
4721                  next B;                  next B;
# Line 4573  sub _tree_construction_main ($) { Line 4730  sub _tree_construction_main ($) {
4730                    $self->{insertion_mode} == IN_HEAD_IM or                    $self->{insertion_mode} == IN_HEAD_IM or
4731                    $self->{insertion_mode} == IN_HEAD_NOSCRIPT_IM) {                    $self->{insertion_mode} == IN_HEAD_NOSCRIPT_IM) {
4732                  !!!cp ('t140');                  !!!cp ('t140');
4733                  !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token);                  !!!parse-error (type => 'unmatched end tag',
4734                                    text => $token->{tag_name}, token => $token);
4735                  ## Ignore the token                  ## Ignore the token
4736                  !!!next-token;                  !!!next-token;
4737                  next B;                  next B;
4738                } elsif ($self->{insertion_mode} == AFTER_HEAD_IM) {                } elsif ($self->{insertion_mode} == AFTER_HEAD_IM) {
4739                  !!!cp ('t140.1');                  !!!cp ('t140.1');
4740                  !!!parse-error (type => 'unmatched end tag:' . $token->{tag_name}, token => $token);                  !!!parse-error (type => 'unmatched end tag',
4741                                    text => $token->{tag_name}, token => $token);
4742                  ## Ignore the token                  ## Ignore the token
4743                  !!!next-token;                  !!!next-token;
4744                  next B;                  next B;
# Line 4588  sub _tree_construction_main ($) { Line 4747  sub _tree_construction_main ($) {
4747                }                }
4748              } elsif ($token->{tag_name} eq 'p') {              } elsif ($token->{tag_name} eq 'p') {
4749                !!!cp ('t142');                !!!cp ('t142');
4750                !!!parse-error (type => 'unmatched end tag:p', token => $token);                !!!parse-error (type => 'unmatched end tag',
4751                                  text => $token->{tag_name}, token => $token);
4752                ## Ignore the token                ## Ignore the token
4753                !!!next-token;                !!!next-token;
4754                next B;                next B;
# Line 4611  sub _tree_construction_main ($) { Line 4771  sub _tree_construction_main ($) {
4771                } elsif ($self->{insertion_mode} == IN_HEAD_NOSCRIPT_IM) {                } elsif ($self->{insertion_mode} == IN_HEAD_NOSCRIPT_IM) {
4772                  !!!cp ('t143.3');                  !!!cp ('t143.3');
4773                  ## ISSUE: Two parse errors for <head><noscript></br>                  ## ISSUE: Two parse errors for <head><noscript></br>
4774                  !!!parse-error (type => 'unmatched end tag:br', token => $token);                  !!!parse-error (type => 'unmatched end tag',
4775                                    text => 'br', token => $token);
4776                  ## As if </noscript>                  ## As if </noscript>
4777                  pop @{$self->{open_elements}};                  pop @{$self->{open_elements}};
4778                  $self->{insertion_mode} = IN_HEAD_IM;                  $self->{insertion_mode} = IN_HEAD_IM;
# Line 4630  sub _tree_construction_main ($) { Line 4791  sub _tree_construction_main ($) {
4791                }                }
4792    
4793                ## ISSUE: does not agree with IE7 - it doesn't ignore </br>.                ## ISSUE: does not agree with IE7 - it doesn't ignore </br>.
4794                !!!parse-error (type => 'unmatched end tag:br', token => $token);                !!!parse-error (type => 'unmatched end tag',
4795                                  text => 'br', token => $token);
4796                ## Ignore the token                ## Ignore the token
4797                !!!next-token;                !!!next-token;
4798                next B;                next B;
4799              } else {              } else {
4800                !!!cp ('t145');                !!!cp ('t145');
4801                !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token);                !!!parse-error (type => 'unmatched end tag',
4802                                  text => $token->{tag_name}, token => $token);
4803                ## Ignore the token                ## Ignore the token
4804                !!!next-token;                !!!next-token;
4805                next B;                next B;
# Line 4646  sub _tree_construction_main ($) { Line 4809  sub _tree_construction_main ($) {
4809                !!!cp ('t146');                !!!cp ('t146');
4810                ## As if </noscript>                ## As if </noscript>
4811                pop @{$self->{open_elements}};                pop @{$self->{open_elements}};
4812                !!!parse-error (type => 'in noscript:/'.$token->{tag_name}, token => $token);                !!!parse-error (type => 'in noscript:/',
4813                                  text => $token->{tag_name}, token => $token);
4814                                
4815                ## Reprocess in the "in head" insertion mode...                ## Reprocess in the "in head" insertion mode...
4816                ## As if </head>                ## As if </head>
# Line 4662  sub _tree_construction_main ($) { Line 4826  sub _tree_construction_main ($) {
4826              } elsif ($self->{insertion_mode} == BEFORE_HEAD_IM) {              } elsif ($self->{insertion_mode} == BEFORE_HEAD_IM) {
4827  ## ISSUE: This case cannot be reached?  ## ISSUE: This case cannot be reached?
4828                !!!cp ('t148');                !!!cp ('t148');
4829                !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token);                !!!parse-error (type => 'unmatched end tag',
4830                                  text => $token->{tag_name}, token => $token);
4831                ## Ignore the token ## ISSUE: An issue in the spec.                ## Ignore the token ## ISSUE: An issue in the spec.
4832                !!!next-token;                !!!next-token;
4833                next B;                next B;
# Line 4773  sub _tree_construction_main ($) { Line 4938  sub _tree_construction_main ($) {
4938    
4939                  !!!cp ('t153');                  !!!cp ('t153');
4940                  !!!parse-error (type => 'start tag not allowed',                  !!!parse-error (type => 'start tag not allowed',
4941                      value => $token->{tag_name}, token => $token);                      text => $token->{tag_name}, token => $token);
4942                  ## Ignore the token                  ## Ignore the token
4943                  !!!nack ('t153.1');                  !!!nack ('t153.1');
4944                  !!!next-token;                  !!!next-token;
4945                  next B;                  next B;
4946                } elsif ($self->{insertion_mode} == IN_CAPTION_IM) {                } elsif ($self->{insertion_mode} == IN_CAPTION_IM) {
4947                  !!!parse-error (type => 'not closed:caption', token => $token);                  !!!parse-error (type => 'not closed', text => 'caption',
4948                                    token => $token);
4949                                    
4950                  ## NOTE: As if </caption>.                  ## NOTE: As if </caption>.
4951                  ## have a table element in table scope                  ## have a table element in table scope
# Line 4799  sub _tree_construction_main ($) { Line 4965  sub _tree_construction_main ($) {
4965    
4966                    !!!cp ('t157');                    !!!cp ('t157');
4967                    !!!parse-error (type => 'start tag not allowed',                    !!!parse-error (type => 'start tag not allowed',
4968                                    value => $token->{tag_name}, token => $token);                                    text => $token->{tag_name}, token => $token);
4969                    ## Ignore the token                    ## Ignore the token
4970                    !!!nack ('t157.1');                    !!!nack ('t157.1');
4971                    !!!next-token;                    !!!next-token;
# Line 4816  sub _tree_construction_main ($) { Line 4982  sub _tree_construction_main ($) {
4982                  unless ($self->{open_elements}->[-1]->[1] & CAPTION_EL) {                  unless ($self->{open_elements}->[-1]->[1] & CAPTION_EL) {
4983                    !!!cp ('t159');                    !!!cp ('t159');
4984                    !!!parse-error (type => 'not closed',                    !!!parse-error (type => 'not closed',
4985                                    value => $self->{open_elements}->[-1]->[0]                                    text => $self->{open_elements}->[-1]->[0]
4986                                        ->manakai_local_name,                                        ->manakai_local_name,
4987                                    token => $token);                                    token => $token);
4988                  } else {                  } else {
# Line 4858  sub _tree_construction_main ($) { Line 5024  sub _tree_construction_main ($) {
5024                  } # INSCOPE                  } # INSCOPE
5025                    unless (defined $i) {                    unless (defined $i) {
5026                      !!!cp ('t165');                      !!!cp ('t165');
5027                      !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token);                      !!!parse-error (type => 'unmatched end tag',
5028                                        text => $token->{tag_name},
5029                                        token => $token);
5030                      ## Ignore the token                      ## Ignore the token
5031                      !!!next-token;                      !!!next-token;
5032                      next B;                      next B;
# Line 4875  sub _tree_construction_main ($) { Line 5043  sub _tree_construction_main ($) {
5043                          ne $token->{tag_name}) {                          ne $token->{tag_name}) {
5044                    !!!cp ('t167');                    !!!cp ('t167');
5045                    !!!parse-error (type => 'not closed',                    !!!parse-error (type => 'not closed',
5046                                    value => $self->{open_elements}->[-1]->[0]                                    text => $self->{open_elements}->[-1]->[0]
5047                                        ->manakai_local_name,                                        ->manakai_local_name,
5048                                    token => $token);                                    token => $token);
5049                  } else {                  } else {
# Line 4892  sub _tree_construction_main ($) { Line 5060  sub _tree_construction_main ($) {
5060                  next B;                  next B;
5061                } elsif ($self->{insertion_mode} == IN_CAPTION_IM) {                } elsif ($self->{insertion_mode} == IN_CAPTION_IM) {
5062                  !!!cp ('t169');                  !!!cp ('t169');
5063                  !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token);                  !!!parse-error (type => 'unmatched end tag',
5064                                    text => $token->{tag_name}, token => $token);
5065                  ## Ignore the token                  ## Ignore the token
5066                  !!!next-token;                  !!!next-token;
5067                  next B;                  next B;
# Line 4919  sub _tree_construction_main ($) { Line 5088  sub _tree_construction_main ($) {
5088    
5089                    !!!cp ('t173');                    !!!cp ('t173');
5090                    !!!parse-error (type => 'unmatched end tag',                    !!!parse-error (type => 'unmatched end tag',
5091                                    value => $token->{tag_name}, token => $token);                                    text => $token->{tag_name}, token => $token);
5092                    ## Ignore the token                    ## Ignore the token
5093                    !!!next-token;                    !!!next-token;
5094                    next B;                    next B;
# Line 4935  sub _tree_construction_main ($) { Line 5104  sub _tree_construction_main ($) {
5104                  unless ($self->{open_elements}->[-1]->[1] & CAPTION_EL) {                  unless ($self->{open_elements}->[-1]->[1] & CAPTION_EL) {
5105                    !!!cp ('t175');                    !!!cp ('t175');
5106                    !!!parse-error (type => 'not closed',                    !!!parse-error (type => 'not closed',
5107                                    value => $self->{open_elements}->[-1]->[0]                                    text => $self->{open_elements}->[-1]->[0]
5108                                        ->manakai_local_name,                                        ->manakai_local_name,
5109                                    token => $token);                                    token => $token);
5110                  } else {                  } else {
# Line 4952  sub _tree_construction_main ($) { Line 5121  sub _tree_construction_main ($) {
5121                  next B;                  next B;
5122                } elsif ($self->{insertion_mode} == IN_CELL_IM) {                } elsif ($self->{insertion_mode} == IN_CELL_IM) {
5123                  !!!cp ('t177');                  !!!cp ('t177');
5124                  !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token);                  !!!parse-error (type => 'unmatched end tag',
5125                                    text => $token->{tag_name}, token => $token);
5126                  ## Ignore the token                  ## Ignore the token
5127                  !!!next-token;                  !!!next-token;
5128                  next B;                  next B;
# Line 4995  sub _tree_construction_main ($) { Line 5165  sub _tree_construction_main ($) {
5165    
5166                  !!!cp ('t182');                  !!!cp ('t182');
5167                  !!!parse-error (type => 'unmatched end tag',                  !!!parse-error (type => 'unmatched end tag',
5168                      value => $token->{tag_name}, token => $token);                      text => $token->{tag_name}, token => $token);
5169                  ## Ignore the token                  ## Ignore the token
5170                  !!!next-token;                  !!!next-token;
5171                  next B;                  next B;
5172                } # INSCOPE                } # INSCOPE
5173              } elsif ($token->{tag_name} eq 'table' and              } elsif ($token->{tag_name} eq 'table' and
5174                       $self->{insertion_mode} == IN_CAPTION_IM) {                       $self->{insertion_mode} == IN_CAPTION_IM) {
5175                !!!parse-error (type => 'not closed:caption', token => $token);                !!!parse-error (type => 'not closed', text => 'caption',
5176                                  token => $token);
5177    
5178                ## As if </caption>                ## As if </caption>
5179                ## have a table element in table scope                ## have a table element in table scope
# Line 5020  sub _tree_construction_main ($) { Line 5191  sub _tree_construction_main ($) {
5191                } # INSCOPE                } # INSCOPE
5192                unless (defined $i) {                unless (defined $i) {
5193                  !!!cp ('t186');                  !!!cp ('t186');
5194                  !!!parse-error (type => 'unmatched end tag:caption', token => $token);                  !!!parse-error (type => 'unmatched end tag',
5195                                    text => 'caption', token => $token);
5196                  ## Ignore the token                  ## Ignore the token
5197                  !!!next-token;                  !!!next-token;
5198                  next B;                  next B;
# Line 5035  sub _tree_construction_main ($) { Line 5207  sub _tree_construction_main ($) {
5207                unless ($self->{open_elements}->[-1]->[1] & CAPTION_EL) {                unless ($self->{open_elements}->[-1]->[1] & CAPTION_EL) {
5208                  !!!cp ('t188');                  !!!cp ('t188');
5209                  !!!parse-error (type => 'not closed',                  !!!parse-error (type => 'not closed',
5210                                  value => $self->{open_elements}->[-1]->[0]                                  text => $self->{open_elements}->[-1]->[0]
5211                                      ->manakai_local_name,                                      ->manakai_local_name,
5212                                  token => $token);                                  token => $token);
5213                } else {                } else {
# Line 5055  sub _tree_construction_main ($) { Line 5227  sub _tree_construction_main ($) {
5227                       }->{$token->{tag_name}}) {                       }->{$token->{tag_name}}) {
5228                if ($self->{insertion_mode} & BODY_TABLE_IMS) {                if ($self->{insertion_mode} & BODY_TABLE_IMS) {
5229                  !!!cp ('t190');                  !!!cp ('t190');
5230                  !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token);                  !!!parse-error (type => 'unmatched end tag',
5231                                    text => $token->{tag_name}, token => $token);
5232                  ## Ignore the token                  ## Ignore the token
5233                  !!!next-token;                  !!!next-token;
5234                  next B;                  next B;
# Line 5069  sub _tree_construction_main ($) { Line 5242  sub _tree_construction_main ($) {
5242                       }->{$token->{tag_name}} and                       }->{$token->{tag_name}} and
5243                       $self->{insertion_mode} == IN_CAPTION_IM) {                       $self->{insertion_mode} == IN_CAPTION_IM) {
5244                !!!cp ('t192');                !!!cp ('t192');
5245                !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token);                !!!parse-error (type => 'unmatched end tag',
5246                                  text => $token->{tag_name}, token => $token);
5247                ## Ignore the token                ## Ignore the token
5248                !!!next-token;                !!!next-token;
5249                next B;                next B;
# Line 5109  sub _tree_construction_main ($) { Line 5283  sub _tree_construction_main ($) {
5283            }            }
5284          }          }
5285    
5286              !!!parse-error (type => 'in table:#character', token => $token);          !!!parse-error (type => 'in table:#text', token => $token);
5287    
5288              ## As if in body, but insert into foster parent element              ## As if in body, but insert into foster parent element
5289              ## ISSUE: Spec says that "whenever a node would be inserted              ## ISSUE: Spec says that "whenever a node would be inserted
# Line 5160  sub _tree_construction_main ($) { Line 5334  sub _tree_construction_main ($) {
5334          !!!next-token;          !!!next-token;
5335          next B;          next B;
5336        } elsif ($token->{type} == START_TAG_TOKEN) {        } elsif ($token->{type} == START_TAG_TOKEN) {
5337              if ({          if ({
5338                   tr => ($self->{insertion_mode} != IN_ROW_IM),               tr => ($self->{insertion_mode} != IN_ROW_IM),
5339                   th => 1, td => 1,               th => 1, td => 1,
5340                  }->{$token->{tag_name}}) {              }->{$token->{tag_name}}) {
5341                if ($self->{insertion_mode} == IN_TABLE_IM) {            if ($self->{insertion_mode} == IN_TABLE_IM) {
5342                  ## Clear back to table context              ## Clear back to table context
5343                  while (not ($self->{open_elements}->[-1]->[1]              while (not ($self->{open_elements}->[-1]->[1]
5344                                  & TABLE_SCOPING_EL)) {                              & TABLE_SCOPING_EL)) {
5345                    !!!cp ('t201');                !!!cp ('t201');
5346                    pop @{$self->{open_elements}};                pop @{$self->{open_elements}};
5347                  }              }
5348                                
5349                  !!!insert-element ('tbody',, $token);              !!!insert-element ('tbody',, $token);
5350                  $self->{insertion_mode} = IN_TABLE_BODY_IM;              $self->{insertion_mode} = IN_TABLE_BODY_IM;
5351                  ## reprocess in the "in table body" insertion mode...              ## reprocess in the "in table body" insertion mode...
5352                }            }
5353              
5354                if ($self->{insertion_mode} == IN_TABLE_BODY_IM) {            if ($self->{insertion_mode} == IN_TABLE_BODY_IM) {
5355                  unless ($token->{tag_name} eq 'tr') {              unless ($token->{tag_name} eq 'tr') {
5356                    !!!cp ('t202');                !!!cp ('t202');
5357                    !!!parse-error (type => 'missing start tag:tr', token => $token);                !!!parse-error (type => 'missing start tag:tr', token => $token);
5358                  }              }
5359                                    
5360                  ## Clear back to table body context              ## Clear back to table body context
5361                  while (not ($self->{open_elements}->[-1]->[1]              while (not ($self->{open_elements}->[-1]->[1]
5362                                  & TABLE_ROWS_SCOPING_EL)) {                              & TABLE_ROWS_SCOPING_EL)) {
5363                    !!!cp ('t203');                !!!cp ('t203');
5364                    ## ISSUE: Can this case be reached?                ## ISSUE: Can this case be reached?
5365                    pop @{$self->{open_elements}};                pop @{$self->{open_elements}};
5366                  }              }
5367                                    
5368                  $self->{insertion_mode} = IN_ROW_IM;                  $self->{insertion_mode} = IN_ROW_IM;
5369                  if ($token->{tag_name} eq 'tr') {                  if ($token->{tag_name} eq 'tr') {
# Line 5245  sub _tree_construction_main ($) { Line 5419  sub _tree_construction_main ($) {
5419                  unless (defined $i) {                  unless (defined $i) {
5420                    !!!cp ('t210');                    !!!cp ('t210');
5421  ## TODO: This type is wrong.  ## TODO: This type is wrong.
5422                    !!!parse-error (type => 'unmacthed end tag:'.$token->{tag_name}, token => $token);                    !!!parse-error (type => 'unmacthed end tag',
5423                                      text => $token->{tag_name}, token => $token);
5424                    ## Ignore the token                    ## Ignore the token
5425                    !!!nack ('t210.1');                    !!!nack ('t210.1');
5426                    !!!next-token;                    !!!next-token;
# Line 5289  sub _tree_construction_main ($) { Line 5464  sub _tree_construction_main ($) {
5464                  } # INSCOPE                  } # INSCOPE
5465                  unless (defined $i) {                  unless (defined $i) {
5466                    !!!cp ('t216');                    !!!cp ('t216');
5467  ## TODO: This erorr type ios wrong.  ## TODO: This erorr type is wrong.
5468                    !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token);                    !!!parse-error (type => 'unmatched end tag',
5469                                      text => $token->{tag_name}, token => $token);
5470                    ## Ignore the token                    ## Ignore the token
5471                    !!!nack ('t216.1');                    !!!nack ('t216.1');
5472                    !!!next-token;                    !!!next-token;
# Line 5365  sub _tree_construction_main ($) { Line 5541  sub _tree_construction_main ($) {
5541                }                }
5542              } elsif ($token->{tag_name} eq 'table') {              } elsif ($token->{tag_name} eq 'table') {
5543                !!!parse-error (type => 'not closed',                !!!parse-error (type => 'not closed',
5544                                value => $self->{open_elements}->[-1]->[0]                                text => $self->{open_elements}->[-1]->[0]
5545                                    ->manakai_local_name,                                    ->manakai_local_name,
5546                                token => $token);                                token => $token);
5547    
# Line 5386  sub _tree_construction_main ($) { Line 5562  sub _tree_construction_main ($) {
5562                unless (defined $i) {                unless (defined $i) {
5563                  !!!cp ('t223');                  !!!cp ('t223');
5564  ## TODO: The following is wrong, maybe.  ## TODO: The following is wrong, maybe.
5565                  !!!parse-error (type => 'unmatched end tag:table', token => $token);                  !!!parse-error (type => 'unmatched end tag', text => 'table',
5566                                    token => $token);
5567                  ## Ignore tokens </table><table>                  ## Ignore tokens </table><table>
5568                  !!!nack ('t223.1');                  !!!nack ('t223.1');
5569                  !!!next-token;                  !!!next-token;
# Line 5404  sub _tree_construction_main ($) { Line 5581  sub _tree_construction_main ($) {
5581                  !!!cp ('t225');                  !!!cp ('t225');
5582                  ## NOTE: |<table><tr><table>|                  ## NOTE: |<table><tr><table>|
5583                  !!!parse-error (type => 'not closed',                  !!!parse-error (type => 'not closed',
5584                                  value => $self->{open_elements}->[-1]->[0]                                  text => $self->{open_elements}->[-1]->[0]
5585                                      ->manakai_local_name,                                      ->manakai_local_name,
5586                                  token => $token);                                  token => $token);
5587                } else {                } else {
# Line 5445  sub _tree_construction_main ($) { Line 5622  sub _tree_construction_main ($) {
5622                my $type = lc $token->{attributes}->{type}->{value};                my $type = lc $token->{attributes}->{type}->{value};
5623                if ($type eq 'hidden') {                if ($type eq 'hidden') {
5624                  !!!cp ('t227.3');                  !!!cp ('t227.3');
5625                  !!!parse-error (type => 'in table:'.$token->{tag_name}, token => $token);                  !!!parse-error (type => 'in table',
5626                                    text => $token->{tag_name}, token => $token);
5627    
5628                  !!!insert-element ($token->{tag_name}, $token->{attributes}, $token);                  !!!insert-element ($token->{tag_name}, $token->{attributes}, $token);
5629    
# Line 5473  sub _tree_construction_main ($) { Line 5651  sub _tree_construction_main ($) {
5651            #            #
5652          }          }
5653    
5654          !!!parse-error (type => 'in table:'.$token->{tag_name}, token => $token);          !!!parse-error (type => 'in table', text => $token->{tag_name},
5655                            token => $token);
5656    
5657          $insert = $insert_to_foster;          $insert = $insert_to_foster;
5658          #          #
# Line 5495  sub _tree_construction_main ($) { Line 5674  sub _tree_construction_main ($) {
5674                } # INSCOPE                } # INSCOPE
5675                unless (defined $i) {                unless (defined $i) {
5676                  !!!cp ('t230');                  !!!cp ('t230');
5677                  !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token);                  !!!parse-error (type => 'unmatched end tag',
5678                                    text => $token->{tag_name}, token => $token);
5679                  ## Ignore the token                  ## Ignore the token
5680                  !!!nack ('t230.1');                  !!!nack ('t230.1');
5681                  !!!next-token;                  !!!next-token;
# Line 5536  sub _tree_construction_main ($) { Line 5716  sub _tree_construction_main ($) {
5716                  unless (defined $i) {                  unless (defined $i) {
5717                    !!!cp ('t235');                    !!!cp ('t235');
5718  ## TODO: The following is wrong.  ## TODO: The following is wrong.
5719                    !!!parse-error (type => 'unmatched end tag:'.$token->{type}, token => $token);                    !!!parse-error (type => 'unmatched end tag',
5720                                      text => $token->{type}, token => $token);
5721                    ## Ignore the token                    ## Ignore the token
5722                    !!!nack ('t236.1');                    !!!nack ('t236.1');
5723                    !!!next-token;                    !!!next-token;
# Line 5572  sub _tree_construction_main ($) { Line 5753  sub _tree_construction_main ($) {
5753                  } # INSCOPE                  } # INSCOPE
5754                  unless (defined $i) {                  unless (defined $i) {
5755                    !!!cp ('t239');                    !!!cp ('t239');
5756                    !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token);                    !!!parse-error (type => 'unmatched end tag',
5757                                      text => $token->{tag_name}, token => $token);
5758                    ## Ignore the token                    ## Ignore the token
5759                    !!!nack ('t239.1');                    !!!nack ('t239.1');
5760                    !!!next-token;                    !!!next-token;
# Line 5618  sub _tree_construction_main ($) { Line 5800  sub _tree_construction_main ($) {
5800                } # INSCOPE                } # INSCOPE
5801                unless (defined $i) {                unless (defined $i) {
5802                  !!!cp ('t243');                  !!!cp ('t243');
5803                  !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token);                  !!!parse-error (type => 'unmatched end tag',
5804                                    text => $token->{tag_name}, token => $token);
5805                  ## Ignore the token                  ## Ignore the token
5806                  !!!nack ('t243.1');                  !!!nack ('t243.1');
5807                  !!!next-token;                  !!!next-token;
# Line 5652  sub _tree_construction_main ($) { Line 5835  sub _tree_construction_main ($) {
5835                  } # INSCOPE                  } # INSCOPE
5836                    unless (defined $i) {                    unless (defined $i) {
5837                      !!!cp ('t249');                      !!!cp ('t249');
5838                      !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token);                      !!!parse-error (type => 'unmatched end tag',
5839                                        text => $token->{tag_name}, token => $token);
5840                      ## Ignore the token                      ## Ignore the token
5841                      !!!nack ('t249.1');                      !!!nack ('t249.1');
5842                      !!!next-token;                      !!!next-token;
# Line 5675  sub _tree_construction_main ($) { Line 5859  sub _tree_construction_main ($) {
5859                  } # INSCOPE                  } # INSCOPE
5860                    unless (defined $i) {                    unless (defined $i) {
5861                      !!!cp ('t252');                      !!!cp ('t252');
5862                      !!!parse-error (type => 'unmatched end tag:tr', token => $token);                      !!!parse-error (type => 'unmatched end tag',
5863                                        text => 'tr', token => $token);
5864                      ## Ignore the token                      ## Ignore the token
5865                      !!!nack ('t252.1');                      !!!nack ('t252.1');
5866                      !!!next-token;                      !!!next-token;
# Line 5710  sub _tree_construction_main ($) { Line 5895  sub _tree_construction_main ($) {
5895                } # INSCOPE                } # INSCOPE
5896                unless (defined $i) {                unless (defined $i) {
5897                  !!!cp ('t256');                  !!!cp ('t256');
5898                  !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token);                  !!!parse-error (type => 'unmatched end tag',
5899                                    text => $token->{tag_name}, token => $token);
5900                  ## Ignore the token                  ## Ignore the token
5901                  !!!nack ('t256.1');                  !!!nack ('t256.1');
5902                  !!!next-token;                  !!!next-token;
# Line 5737  sub _tree_construction_main ($) { Line 5923  sub _tree_construction_main ($) {
5923                        tbody => 1, tfoot => 1, thead => 1, # $self->{insertion_mode} == IN_TABLE_IM                        tbody => 1, tfoot => 1, thead => 1, # $self->{insertion_mode} == IN_TABLE_IM
5924                       }->{$token->{tag_name}}) {                       }->{$token->{tag_name}}) {
5925            !!!cp ('t258');            !!!cp ('t258');
5926            !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token);            !!!parse-error (type => 'unmatched end tag',
5927                              text => $token->{tag_name}, token => $token);
5928            ## Ignore the token            ## Ignore the token
5929            !!!nack ('t258.1');            !!!nack ('t258.1');
5930             !!!next-token;             !!!next-token;
5931            next B;            next B;
5932          } else {          } else {
5933            !!!cp ('t259');            !!!cp ('t259');
5934            !!!parse-error (type => 'in table:/'.$token->{tag_name}, token => $token);            !!!parse-error (type => 'in table:/',
5935                              text => $token->{tag_name}, token => $token);
5936    
5937            $insert = $insert_to_foster;            $insert = $insert_to_foster;
5938            #            #
# Line 5794  sub _tree_construction_main ($) { Line 5982  sub _tree_construction_main ($) {
5982              if ($token->{tag_name} eq 'colgroup') {              if ($token->{tag_name} eq 'colgroup') {
5983                if ($self->{open_elements}->[-1]->[1] & HTML_EL) {                if ($self->{open_elements}->[-1]->[1] & HTML_EL) {
5984                  !!!cp ('t264');                  !!!cp ('t264');
5985                  !!!parse-error (type => 'unmatched end tag:colgroup', token => $token);                  !!!parse-error (type => 'unmatched end tag',
5986                                    text => 'colgroup', token => $token);
5987                  ## Ignore the token                  ## Ignore the token
5988                  !!!next-token;                  !!!next-token;
5989                  next B;                  next B;
# Line 5807  sub _tree_construction_main ($) { Line 5996  sub _tree_construction_main ($) {
5996                }                }
5997              } elsif ($token->{tag_name} eq 'col') {              } elsif ($token->{tag_name} eq 'col') {
5998                !!!cp ('t266');                !!!cp ('t266');
5999                !!!parse-error (type => 'unmatched end tag:col', token => $token);                !!!parse-error (type => 'unmatched end tag',
6000                                  text => 'col', token => $token);
6001                ## Ignore the token                ## Ignore the token
6002                !!!next-token;                !!!next-token;
6003                next B;                next B;
# Line 5837  sub _tree_construction_main ($) { Line 6027  sub _tree_construction_main ($) {
6027            if ($self->{open_elements}->[-1]->[1] & HTML_EL) {            if ($self->{open_elements}->[-1]->[1] & HTML_EL) {
6028              !!!cp ('t269');              !!!cp ('t269');
6029  ## TODO: Wrong error type?  ## TODO: Wrong error type?
6030              !!!parse-error (type => 'unmatched end tag:colgroup', token => $token);              !!!parse-error (type => 'unmatched end tag',
6031                                text => 'colgroup', token => $token);
6032              ## Ignore the token              ## Ignore the token
6033              !!!nack ('t269.1');              !!!nack ('t269.1');
6034              !!!next-token;              !!!next-token;
# Line 5901  sub _tree_construction_main ($) { Line 6092  sub _tree_construction_main ($) {
6092                     tr => 1, td => 1, th => 1,                     tr => 1, td => 1, th => 1,
6093                    }->{$token->{tag_name}})) {                    }->{$token->{tag_name}})) {
6094            ## TODO: The type below is not good - <select> is replaced by </select>            ## TODO: The type below is not good - <select> is replaced by </select>
6095            !!!parse-error (type => 'not closed:select', token => $token);            !!!parse-error (type => 'not closed', text => 'select',
6096                              token => $token);
6097            ## NOTE: As if the token were </select> (<select> case) or            ## NOTE: As if the token were </select> (<select> case) or
6098            ## as if there were </select> (otherwise).            ## as if there were </select> (otherwise).
6099            ## have an element in table scope            ## have an element in table scope
# Line 5919  sub _tree_construction_main ($) { Line 6111  sub _tree_construction_main ($) {
6111            } # INSCOPE            } # INSCOPE
6112            unless (defined $i) {            unless (defined $i) {
6113              !!!cp ('t280');              !!!cp ('t280');
6114              !!!parse-error (type => 'unmatched end tag:select', token => $token);              !!!parse-error (type => 'unmatched end tag',
6115                                text => 'select', token => $token);
6116              ## Ignore the token              ## Ignore the token
6117              !!!nack ('t280.1');              !!!nack ('t280.1');
6118              !!!next-token;              !!!next-token;
# Line 5943  sub _tree_construction_main ($) { Line 6136  sub _tree_construction_main ($) {
6136            }            }
6137          } else {          } else {
6138            !!!cp ('t282');            !!!cp ('t282');
6139            !!!parse-error (type => 'in select:'.$token->{tag_name}, token => $token);            !!!parse-error (type => 'in select',
6140                              text => $token->{tag_name}, token => $token);
6141            ## Ignore the token            ## Ignore the token
6142            !!!nack ('t282.1');            !!!nack ('t282.1');
6143            !!!next-token;            !!!next-token;
# Line 5961  sub _tree_construction_main ($) { Line 6155  sub _tree_construction_main ($) {
6155              pop @{$self->{open_elements}};              pop @{$self->{open_elements}};
6156            } else {            } else {
6157              !!!cp ('t285');              !!!cp ('t285');
6158              !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token);              !!!parse-error (type => 'unmatched end tag',
6159                                text => $token->{tag_name}, token => $token);
6160              ## Ignore the token              ## Ignore the token
6161            }            }
6162            !!!nack ('t285.1');            !!!nack ('t285.1');
# Line 5973  sub _tree_construction_main ($) { Line 6168  sub _tree_construction_main ($) {
6168              pop @{$self->{open_elements}};              pop @{$self->{open_elements}};
6169            } else {            } else {
6170              !!!cp ('t287');              !!!cp ('t287');
6171              !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token);              !!!parse-error (type => 'unmatched end tag',
6172                                text => $token->{tag_name}, token => $token);
6173              ## Ignore the token              ## Ignore the token
6174            }            }
6175            !!!nack ('t287.1');            !!!nack ('t287.1');
# Line 5995  sub _tree_construction_main ($) { Line 6191  sub _tree_construction_main ($) {
6191            } # INSCOPE            } # INSCOPE
6192            unless (defined $i) {            unless (defined $i) {
6193              !!!cp ('t290');              !!!cp ('t290');
6194              !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token);              !!!parse-error (type => 'unmatched end tag',
6195                                text => $token->{tag_name}, token => $token);
6196              ## Ignore the token              ## Ignore the token
6197              !!!nack ('t290.1');              !!!nack ('t290.1');
6198              !!!next-token;              !!!next-token;
# Line 6016  sub _tree_construction_main ($) { Line 6213  sub _tree_construction_main ($) {
6213                    tfoot => 1, thead => 1, tr => 1, td => 1, th => 1,                    tfoot => 1, thead => 1, tr => 1, td => 1, th => 1,
6214                   }->{$token->{tag_name}}) {                   }->{$token->{tag_name}}) {
6215  ## TODO: The following is wrong?  ## TODO: The following is wrong?
6216            !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token);            !!!parse-error (type => 'unmatched end tag',
6217                              text => $token->{tag_name}, token => $token);
6218                                
6219            ## have an element in table scope            ## have an element in table scope
6220            my $i;            my $i;
# Line 6057  sub _tree_construction_main ($) { Line 6255  sub _tree_construction_main ($) {
6255            unless (defined $i) {            unless (defined $i) {
6256              !!!cp ('t297');              !!!cp ('t297');
6257  ## TODO: The following error type is correct?  ## TODO: The following error type is correct?
6258              !!!parse-error (type => 'unmatched end tag:select', token => $token);              !!!parse-error (type => 'unmatched end tag',
6259                                text => 'select', token => $token);
6260              ## Ignore the </select> token              ## Ignore the </select> token
6261              !!!nack ('t297.1');              !!!nack ('t297.1');
6262              !!!next-token; ## TODO: ok?              !!!next-token; ## TODO: ok?
# Line 6074  sub _tree_construction_main ($) { Line 6273  sub _tree_construction_main ($) {
6273            next B;            next B;
6274          } else {          } else {
6275            !!!cp ('t299');            !!!cp ('t299');
6276            !!!parse-error (type => 'in select:/'.$token->{tag_name}, token => $token);            !!!parse-error (type => 'in select:/',
6277                              text => $token->{tag_name}, token => $token);
6278            ## Ignore the token            ## Ignore the token
6279            !!!nack ('t299.3');            !!!nack ('t299.3');
6280            !!!next-token;            !!!next-token;
# Line 6112  sub _tree_construction_main ($) { Line 6312  sub _tree_construction_main ($) {
6312                    
6313          if ($self->{insertion_mode} == AFTER_HTML_BODY_IM) {          if ($self->{insertion_mode} == AFTER_HTML_BODY_IM) {
6314            !!!cp ('t301');            !!!cp ('t301');
6315            !!!parse-error (type => 'after html:#character', token => $token);            !!!parse-error (type => 'after html:#text', token => $token);
6316    
6317            ## Reprocess in the "after body" insertion mode.            ## Reprocess in the "after body" insertion mode.
6318          } else {          } else {
# Line 6120  sub _tree_construction_main ($) { Line 6320  sub _tree_construction_main ($) {
6320          }          }
6321                    
6322          ## "after body" insertion mode          ## "after body" insertion mode
6323          !!!parse-error (type => 'after body:#character', token => $token);          !!!parse-error (type => 'after body:#text', token => $token);
6324    
6325          $self->{insertion_mode} = IN_BODY_IM;          $self->{insertion_mode} = IN_BODY_IM;
6326          ## reprocess          ## reprocess
# Line 6128  sub _tree_construction_main ($) { Line 6328  sub _tree_construction_main ($) {
6328        } elsif ($token->{type} == START_TAG_TOKEN) {        } elsif ($token->{type} == START_TAG_TOKEN) {
6329          if ($self->{insertion_mode} == AFTER_HTML_BODY_IM) {          if ($self->{insertion_mode} == AFTER_HTML_BODY_IM) {
6330            !!!cp ('t303');            !!!cp ('t303');
6331            !!!parse-error (type => 'after html:'.$token->{tag_name}, token => $token);            !!!parse-error (type => 'after html',
6332                              text => $token->{tag_name}, token => $token);
6333                        
6334            ## Reprocess in the "after body" insertion mode.            ## Reprocess in the "after body" insertion mode.
6335          } else {          } else {
# Line 6136  sub _tree_construction_main ($) { Line 6337  sub _tree_construction_main ($) {
6337          }          }
6338    
6339          ## "after body" insertion mode          ## "after body" insertion mode
6340          !!!parse-error (type => 'after body:'.$token->{tag_name}, token => $token);          !!!parse-error (type => 'after body',
6341                            text => $token->{tag_name}, token => $token);
6342    
6343          $self->{insertion_mode} = IN_BODY_IM;          $self->{insertion_mode} = IN_BODY_IM;
6344          !!!ack-later;          !!!ack-later;
# Line 6145  sub _tree_construction_main ($) { Line 6347  sub _tree_construction_main ($) {
6347        } elsif ($token->{type} == END_TAG_TOKEN) {        } elsif ($token->{type} == END_TAG_TOKEN) {
6348          if ($self->{insertion_mode} == AFTER_HTML_BODY_IM) {          if ($self->{insertion_mode} == AFTER_HTML_BODY_IM) {
6349            !!!cp ('t305');            !!!cp ('t305');
6350            !!!parse-error (type => 'after html:/'.$token->{tag_name}, token => $token);            !!!parse-error (type => 'after html:/',
6351                              text => $token->{tag_name}, token => $token);
6352                        
6353            $self->{insertion_mode} = AFTER_BODY_IM;            $self->{insertion_mode} = AFTER_BODY_IM;
6354            ## Reprocess in the "after body" insertion mode.            ## Reprocess in the "after body" insertion mode.
# Line 6157  sub _tree_construction_main ($) { Line 6360  sub _tree_construction_main ($) {
6360          if ($token->{tag_name} eq 'html') {          if ($token->{tag_name} eq 'html') {
6361            if (defined $self->{inner_html_node}) {            if (defined $self->{inner_html_node}) {
6362              !!!cp ('t307');              !!!cp ('t307');
6363              !!!parse-error (type => 'unmatched end tag:html', token => $token);              !!!parse-error (type => 'unmatched end tag',
6364                                text => 'html', token => $token);
6365              ## Ignore the token              ## Ignore the token
6366              !!!next-token;              !!!next-token;
6367              next B;              next B;
# Line 6169  sub _tree_construction_main ($) { Line 6373  sub _tree_construction_main ($) {
6373            }            }
6374          } else {          } else {
6375            !!!cp ('t309');            !!!cp ('t309');
6376            !!!parse-error (type => 'after body:/'.$token->{tag_name}, token => $token);            !!!parse-error (type => 'after body:/',
6377                              text => $token->{tag_name}, token => $token);
6378    
6379            $self->{insertion_mode} = IN_BODY_IM;            $self->{insertion_mode} = IN_BODY_IM;
6380            ## reprocess            ## reprocess
# Line 6197  sub _tree_construction_main ($) { Line 6402  sub _tree_construction_main ($) {
6402          if ($token->{data} =~ s/^[^\x09\x0A\x0B\x0C\x20]+//) {          if ($token->{data} =~ s/^[^\x09\x0A\x0B\x0C\x20]+//) {
6403            if ($self->{insertion_mode} == IN_FRAMESET_IM) {            if ($self->{insertion_mode} == IN_FRAMESET_IM) {
6404              !!!cp ('t311');              !!!cp ('t311');
6405              !!!parse-error (type => 'in frameset:#character', token => $token);              !!!parse-error (type => 'in frameset:#text', token => $token);
6406            } elsif ($self->{insertion_mode} == AFTER_FRAMESET_IM) {            } elsif ($self->{insertion_mode} == AFTER_FRAMESET_IM) {
6407              !!!cp ('t312');              !!!cp ('t312');
6408              !!!parse-error (type => 'after frameset:#character', token => $token);              !!!parse-error (type => 'after frameset:#text', token => $token);
6409            } else { # "after html frameset"            } else { # "after after frameset"
6410              !!!cp ('t313');              !!!cp ('t313');
6411              !!!parse-error (type => 'after html:#character', token => $token);              !!!parse-error (type => 'after html:#text', token => $token);
   
             $self->{insertion_mode} = AFTER_FRAMESET_IM;  
             ## Reprocess in the "after frameset" insertion mode.  
             !!!parse-error (type => 'after frameset:#character', token => $token);  
6412            }            }
6413                        
6414            ## Ignore the token.            ## Ignore the token.
# Line 6223  sub _tree_construction_main ($) { Line 6424  sub _tree_construction_main ($) {
6424                    
6425          die qq[$0: Character "$token->{data}"];          die qq[$0: Character "$token->{data}"];
6426        } elsif ($token->{type} == START_TAG_TOKEN) {        } elsif ($token->{type} == START_TAG_TOKEN) {
         if ($self->{insertion_mode} == AFTER_HTML_FRAMESET_IM) {  
           !!!cp ('t316');  
           !!!parse-error (type => 'after html:'.$token->{tag_name}, token => $token);  
   
           $self->{insertion_mode} = AFTER_FRAMESET_IM;  
           ## Process in the "after frameset" insertion mode.  
         } else {  
           !!!cp ('t317');  
         }  
   
6427          if ($token->{tag_name} eq 'frameset' and          if ($token->{tag_name} eq 'frameset' and
6428              $self->{insertion_mode} == IN_FRAMESET_IM) {              $self->{insertion_mode} == IN_FRAMESET_IM) {
6429            !!!cp ('t318');            !!!cp ('t318');
# Line 6253  sub _tree_construction_main ($) { Line 6444  sub _tree_construction_main ($) {
6444            ## NOTE: As if in head.            ## NOTE: As if in head.
6445            $parse_rcdata->(CDATA_CONTENT_MODEL);            $parse_rcdata->(CDATA_CONTENT_MODEL);
6446            next B;            next B;
6447    
6448              ## NOTE: |<!DOCTYPE HTML><frameset></frameset></html><noframes></noframes>|
6449              ## has no parse error.
6450          } else {          } else {
6451            if ($self->{insertion_mode} == IN_FRAMESET_IM) {            if ($self->{insertion_mode} == IN_FRAMESET_IM) {
6452              !!!cp ('t321');              !!!cp ('t321');
6453              !!!parse-error (type => 'in frameset:'.$token->{tag_name}, token => $token);              !!!parse-error (type => 'in frameset',
6454            } else {                              text => $token->{tag_name}, token => $token);
6455              } elsif ($self->{insertion_mode} == AFTER_FRAMESET_IM) {
6456              !!!cp ('t322');              !!!cp ('t322');
6457              !!!parse-error (type => 'after frameset:'.$token->{tag_name}, token => $token);              !!!parse-error (type => 'after frameset',
6458                                text => $token->{tag_name}, token => $token);
6459              } else { # "after after frameset"
6460                !!!cp ('t322.2');
6461                !!!parse-error (type => 'after after frameset',
6462                                text => $token->{tag_name}, token => $token);
6463            }            }
6464            ## Ignore the token            ## Ignore the token
6465            !!!nack ('t322.1');            !!!nack ('t322.1');
# Line 6267  sub _tree_construction_main ($) { Line 6467  sub _tree_construction_main ($) {
6467            next B;            next B;
6468          }          }
6469        } elsif ($token->{type} == END_TAG_TOKEN) {        } elsif ($token->{type} == END_TAG_TOKEN) {
         if ($self->{insertion_mode} == AFTER_HTML_FRAMESET_IM) {  
           !!!cp ('t323');  
           !!!parse-error (type => 'after html:/'.$token->{tag_name}, token => $token);  
   
           $self->{insertion_mode} = AFTER_FRAMESET_IM;  
           ## Process in the "after frameset" insertion mode.  
         } else {  
           !!!cp ('t324');  
         }  
   
6470          if ($token->{tag_name} eq 'frameset' and          if ($token->{tag_name} eq 'frameset' and
6471              $self->{insertion_mode} == IN_FRAMESET_IM) {              $self->{insertion_mode} == IN_FRAMESET_IM) {
6472            if ($self->{open_elements}->[-1]->[1] & HTML_EL and            if ($self->{open_elements}->[-1]->[1] & HTML_EL and
6473                @{$self->{open_elements}} == 1) {                @{$self->{open_elements}} == 1) {
6474              !!!cp ('t325');              !!!cp ('t325');
6475              !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token);              !!!parse-error (type => 'unmatched end tag',
6476                                text => $token->{tag_name}, token => $token);
6477              ## Ignore the token              ## Ignore the token
6478              !!!next-token;              !!!next-token;
6479            } else {            } else {
# Line 6308  sub _tree_construction_main ($) { Line 6499  sub _tree_construction_main ($) {
6499          } else {          } else {
6500            if ($self->{insertion_mode} == IN_FRAMESET_IM) {            if ($self->{insertion_mode} == IN_FRAMESET_IM) {
6501              !!!cp ('t330');              !!!cp ('t330');
6502              !!!parse-error (type => 'in frameset:/'.$token->{tag_name}, token => $token);              !!!parse-error (type => 'in frameset:/',
6503            } else {                              text => $token->{tag_name}, token => $token);
6504              } elsif ($self->{insertion_mode} == AFTER_FRAMESET_IM) {
6505                !!!cp ('t330.1');
6506                !!!parse-error (type => 'after frameset:/',
6507                                text => $token->{tag_name}, token => $token);
6508              } else { # "after after html"
6509              !!!cp ('t331');              !!!cp ('t331');
6510              !!!parse-error (type => 'after frameset:/'.$token->{tag_name}, token => $token);              !!!parse-error (type => 'after after frameset:/',
6511                                text => $token->{tag_name}, token => $token);
6512            }            }
6513            ## Ignore the token            ## Ignore the token
6514            !!!next-token;            !!!next-token;
# Line 6419  sub _tree_construction_main ($) { Line 6616  sub _tree_construction_main ($) {
6616          $parse_rcdata->(RCDATA_CONTENT_MODEL);          $parse_rcdata->(RCDATA_CONTENT_MODEL);
6617          next B;          next B;
6618        } elsif ($token->{tag_name} eq 'body') {        } elsif ($token->{tag_name} eq 'body') {
6619          !!!parse-error (type => 'in body:body', token => $token);          !!!parse-error (type => 'in body', text => 'body', token => $token);
6620                                
6621          if (@{$self->{open_elements}} == 1 or          if (@{$self->{open_elements}} == 1 or
6622              not ($self->{open_elements}->[1]->[1] & BODY_EL)) {              not ($self->{open_elements}->[1]->[1] & BODY_EL)) {
# Line 6539  sub _tree_construction_main ($) { Line 6736  sub _tree_construction_main ($) {
6736              if ($i != -1) {              if ($i != -1) {
6737                !!!cp ('t355');                !!!cp ('t355');
6738                !!!parse-error (type => 'not closed',                !!!parse-error (type => 'not closed',
6739                                value => $self->{open_elements}->[-1]->[0]                                text => $self->{open_elements}->[-1]->[0]
6740                                    ->manakai_local_name,                                    ->manakai_local_name,
6741                                token => $token);                                token => $token);
6742              } else {              } else {
# Line 6807  sub _tree_construction_main ($) { Line 7004  sub _tree_construction_main ($) {
7004            ## Ignore the token            ## Ignore the token
7005          } else {          } else {
7006            !!!cp ('t398');            !!!cp ('t398');
7007            !!!parse-error (type => 'in RCDATA:#'.$token->{type}, token => $token);            !!!parse-error (type => 'in RCDATA:#eof', token => $token);
7008          }          }
7009          !!!next-token;          !!!next-token;
7010          next B;          next B;
# Line 6826  sub _tree_construction_main ($) { Line 7023  sub _tree_construction_main ($) {
7023              unless ($self->{open_elements}->[-1]->[1] & RUBY_EL) {              unless ($self->{open_elements}->[-1]->[1] & RUBY_EL) {
7024                !!!cp ('t398.3');                !!!cp ('t398.3');
7025                !!!parse-error (type => 'not closed',                !!!parse-error (type => 'not closed',
7026                                value => $self->{open_elements}->[-1]->[0]                                text => $self->{open_elements}->[-1]->[0]
7027                                    ->manakai_local_name,                                    ->manakai_local_name,
7028                                token => $token);                                token => $token);
7029                pop @{$self->{open_elements}}                pop @{$self->{open_elements}}
# Line 6848  sub _tree_construction_main ($) { Line 7045  sub _tree_construction_main ($) {
7045                 $token->{tag_name} eq 'svg') {                 $token->{tag_name} eq 'svg') {
7046          $reconstruct_active_formatting_elements->($insert_to_current);          $reconstruct_active_formatting_elements->($insert_to_current);
7047    
7048            ## "Adjust MathML attributes" ('math' only) - done in insert-element-f
7049    
7050          ## "adjust SVG attributes" ('svg' only) - done in insert-element-f          ## "adjust SVG attributes" ('svg' only) - done in insert-element-f
7051    
7052          ## "adjust foreign attributes" - done in insert-element-f          ## "adjust foreign attributes" - done in insert-element-f
# Line 6874  sub _tree_construction_main ($) { Line 7073  sub _tree_construction_main ($) {
7073                  thead => 1, tr => 1,                  thead => 1, tr => 1,
7074                 }->{$token->{tag_name}}) {                 }->{$token->{tag_name}}) {
7075          !!!cp ('t401');          !!!cp ('t401');
7076          !!!parse-error (type => 'in body:'.$token->{tag_name}, token => $token);          !!!parse-error (type => 'in body',
7077                            text => $token->{tag_name}, token => $token);
7078          ## Ignore the token          ## Ignore the token
7079          !!!nack ('t401.1'); ## NOTE: |<col/>| or |<frame/>| here is an error.          !!!nack ('t401.1'); ## NOTE: |<col/>| or |<frame/>| here is an error.
7080          !!!next-token;          !!!next-token;
# Line 6959  sub _tree_construction_main ($) { Line 7159  sub _tree_construction_main ($) {
7159            }            }
7160    
7161            !!!parse-error (type => 'start tag not allowed',            !!!parse-error (type => 'start tag not allowed',
7162                            value => $token->{tag_name}, token => $token);                            text => $token->{tag_name}, token => $token);
7163            ## NOTE: Ignore the token.            ## NOTE: Ignore the token.
7164            !!!next-token;            !!!next-token;
7165            next B;            next B;
# Line 6969  sub _tree_construction_main ($) { Line 7169  sub _tree_construction_main ($) {
7169            unless ($_->[1] & ALL_END_TAG_OPTIONAL_EL) {            unless ($_->[1] & ALL_END_TAG_OPTIONAL_EL) {
7170              !!!cp ('t403');              !!!cp ('t403');
7171              !!!parse-error (type => 'not closed',              !!!parse-error (type => 'not closed',
7172                              value => $_->[0]->manakai_local_name,                              text => $_->[0]->manakai_local_name,
7173                              token => $token);                              token => $token);
7174              last;              last;
7175            } else {            } else {
# Line 6989  sub _tree_construction_main ($) { Line 7189  sub _tree_construction_main ($) {
7189            unless ($self->{open_elements}->[-1]->[1] & BODY_EL) {            unless ($self->{open_elements}->[-1]->[1] & BODY_EL) {
7190              !!!cp ('t406');              !!!cp ('t406');
7191              !!!parse-error (type => 'not closed',              !!!parse-error (type => 'not closed',
7192                              value => $self->{open_elements}->[1]->[0]                              text => $self->{open_elements}->[1]->[0]
7193                                  ->manakai_local_name,                                  ->manakai_local_name,
7194                              token => $token);                              token => $token);
7195            } else {            } else {
# Line 7000  sub _tree_construction_main ($) { Line 7200  sub _tree_construction_main ($) {
7200            next B;            next B;
7201          } else {          } else {
7202            !!!cp ('t408');            !!!cp ('t408');
7203            !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token);            !!!parse-error (type => 'unmatched end tag',
7204                              text => $token->{tag_name}, token => $token);
7205            ## Ignore the token            ## Ignore the token
7206            !!!next-token;            !!!next-token;
7207            next B;            next B;
# Line 7028  sub _tree_construction_main ($) { Line 7229  sub _tree_construction_main ($) {
7229    
7230          unless (defined $i) { # has an element in scope          unless (defined $i) { # has an element in scope
7231            !!!cp ('t413');            !!!cp ('t413');
7232            !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token);            !!!parse-error (type => 'unmatched end tag',
7233                              text => $token->{tag_name}, token => $token);
7234              ## NOTE: Ignore the token.
7235          } else {          } else {
7236            ## Step 1. generate implied end tags            ## Step 1. generate implied end tags
7237            while ({            while ({
# Line 7049  sub _tree_construction_main ($) { Line 7252  sub _tree_construction_main ($) {
7252                    ne $token->{tag_name}) {                    ne $token->{tag_name}) {
7253              !!!cp ('t412');              !!!cp ('t412');
7254              !!!parse-error (type => 'not closed',              !!!parse-error (type => 'not closed',
7255                              value => $self->{open_elements}->[-1]->[0]                              text => $self->{open_elements}->[-1]->[0]
7256                                  ->manakai_local_name,                                  ->manakai_local_name,
7257                              token => $token);                              token => $token);
7258            } else {            } else {
# Line 7086  sub _tree_construction_main ($) { Line 7289  sub _tree_construction_main ($) {
7289    
7290          unless (defined $i) { # has an element in scope          unless (defined $i) { # has an element in scope
7291            !!!cp ('t421');            !!!cp ('t421');
7292            !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token);            !!!parse-error (type => 'unmatched end tag',
7293                              text => $token->{tag_name}, token => $token);
7294              ## NOTE: Ignore the token.
7295          } else {          } else {
7296            ## Step 1. generate implied end tags            ## Step 1. generate implied end tags
7297            while ($self->{open_elements}->[-1]->[1] & END_TAG_OPTIONAL_EL) {            while ($self->{open_elements}->[-1]->[1] & END_TAG_OPTIONAL_EL) {
# Line 7099  sub _tree_construction_main ($) { Line 7304  sub _tree_construction_main ($) {
7304                    ne $token->{tag_name}) {                    ne $token->{tag_name}) {
7305              !!!cp ('t417.1');              !!!cp ('t417.1');
7306              !!!parse-error (type => 'not closed',              !!!parse-error (type => 'not closed',
7307                              value => $self->{open_elements}->[-1]->[0]                              text => $self->{open_elements}->[-1]->[0]
7308                                  ->manakai_local_name,                                  ->manakai_local_name,
7309                              token => $token);                              token => $token);
7310            } else {            } else {
# Line 7131  sub _tree_construction_main ($) { Line 7336  sub _tree_construction_main ($) {
7336    
7337          unless (defined $i) { # has an element in scope          unless (defined $i) { # has an element in scope
7338            !!!cp ('t425.1');            !!!cp ('t425.1');
7339            !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token);            !!!parse-error (type => 'unmatched end tag',
7340                              text => $token->{tag_name}, token => $token);
7341              ## NOTE: Ignore the token.
7342          } else {          } else {
7343            ## Step 1. generate implied end tags            ## Step 1. generate implied end tags
7344            while ($self->{open_elements}->[-1]->[1] & END_TAG_OPTIONAL_EL) {            while ($self->{open_elements}->[-1]->[1] & END_TAG_OPTIONAL_EL) {
# Line 7143  sub _tree_construction_main ($) { Line 7350  sub _tree_construction_main ($) {
7350            if ($self->{open_elements}->[-1]->[0]->manakai_local_name            if ($self->{open_elements}->[-1]->[0]->manakai_local_name
7351                    ne $token->{tag_name}) {                    ne $token->{tag_name}) {
7352              !!!cp ('t425');              !!!cp ('t425');
7353              !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token);              !!!parse-error (type => 'unmatched end tag',
7354                                text => $token->{tag_name}, token => $token);
7355            } else {            } else {
7356              !!!cp ('t426');              !!!cp ('t426');
7357            }            }
# Line 7174  sub _tree_construction_main ($) { Line 7382  sub _tree_construction_main ($) {
7382                    ne $token->{tag_name}) {                    ne $token->{tag_name}) {
7383              !!!cp ('t412.1');              !!!cp ('t412.1');
7384              !!!parse-error (type => 'not closed',              !!!parse-error (type => 'not closed',
7385                              value => $self->{open_elements}->[-1]->[0]                              text => $self->{open_elements}->[-1]->[0]
7386                                  ->manakai_local_name,                                  ->manakai_local_name,
7387                              token => $token);                              token => $token);
7388            } else {            } else {
# Line 7184  sub _tree_construction_main ($) { Line 7392  sub _tree_construction_main ($) {
7392            splice @{$self->{open_elements}}, $i;            splice @{$self->{open_elements}}, $i;
7393          } else {          } else {
7394            !!!cp ('t413.1');            !!!cp ('t413.1');
7395            !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token);            !!!parse-error (type => 'unmatched end tag',
7396                              text => $token->{tag_name}, token => $token);
7397    
7398            !!!cp ('t415.1');            !!!cp ('t415.1');
7399            ## As if <p>, then reprocess the current token            ## As if <p>, then reprocess the current token
# Line 7207  sub _tree_construction_main ($) { Line 7416  sub _tree_construction_main ($) {
7416          next B;          next B;
7417        } elsif ($token->{tag_name} eq 'br') {        } elsif ($token->{tag_name} eq 'br') {
7418          !!!cp ('t428');          !!!cp ('t428');
7419          !!!parse-error (type => 'unmatched end tag:br', token => $token);          !!!parse-error (type => 'unmatched end tag',
7420                            text => 'br', token => $token);
7421    
7422          ## As if <br>          ## As if <br>
7423          $reconstruct_active_formatting_elements->($insert_to_current);          $reconstruct_active_formatting_elements->($insert_to_current);
# Line 7232  sub _tree_construction_main ($) { Line 7442  sub _tree_construction_main ($) {
7442                  noscript => 0, ## TODO: if scripting is enabled                  noscript => 0, ## TODO: if scripting is enabled
7443                 }->{$token->{tag_name}}) {                 }->{$token->{tag_name}}) {
7444          !!!cp ('t429');          !!!cp ('t429');
7445          !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token);          !!!parse-error (type => 'unmatched end tag',
7446                            text => $token->{tag_name}, token => $token);
7447          ## Ignore the token          ## Ignore the token
7448          !!!next-token;          !!!next-token;
7449          next B;          next B;
# Line 7264  sub _tree_construction_main ($) { Line 7475  sub _tree_construction_main ($) {
7475                !!!cp ('t431');                !!!cp ('t431');
7476                ## NOTE: <x><y></x>                ## NOTE: <x><y></x>
7477                !!!parse-error (type => 'not closed',                !!!parse-error (type => 'not closed',
7478                                value => $self->{open_elements}->[-1]->[0]                                text => $self->{open_elements}->[-1]->[0]
7479                                    ->manakai_local_name,                                    ->manakai_local_name,
7480                                token => $token);                                token => $token);
7481              } else {              } else {
# Line 7283  sub _tree_construction_main ($) { Line 7494  sub _tree_construction_main ($) {
7494                  ($node->[1] & SPECIAL_EL or                  ($node->[1] & SPECIAL_EL or
7495                   $node->[1] & SCOPING_EL)) {                   $node->[1] & SCOPING_EL)) {
7496                !!!cp ('t433');                !!!cp ('t433');
7497                !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token);                !!!parse-error (type => 'unmatched end tag',
7498                                  text => $token->{tag_name}, token => $token);
7499                ## Ignore the token                ## Ignore the token
7500                !!!next-token;                !!!next-token;
7501                last S2;                last S2;
# Line 7329  sub _tree_construction_main ($) { Line 7541  sub _tree_construction_main ($) {
7541    ## TODO: script stuffs    ## TODO: script stuffs
7542  } # _tree_construct_main  } # _tree_construct_main
7543    
7544  sub set_inner_html ($$$) {  sub set_inner_html ($$$;$) {
7545    my $class = shift;    my $class = shift;
7546    my $node = shift;    my $node = shift;
7547    my $s = \$_[0];    my $s = \$_[0];
7548    my $onerror = $_[1];    my $onerror = $_[1];
7549      my $get_wrapper = $_[2] || sub ($) { return $_[0] };
7550    
7551    ## ISSUE: Should {confident} be true?    ## ISSUE: Should {confident} be true?
7552    
# Line 7352  sub set_inner_html ($$$) { Line 7565  sub set_inner_html ($$$) {
7565      }      }
7566    
7567      ## Step 3, 4, 5 # MUST      ## Step 3, 4, 5 # MUST
7568      $class->parse_string ($$s => $node, $onerror);      $class->parse_char_string ($$s => $node, $onerror, $get_wrapper);
7569    } elsif ($nt == 1) {    } elsif ($nt == 1) {
7570      ## TODO: If non-html element      ## TODO: If non-html element
7571    
7572      ## NOTE: Most of this code is copied from |parse_string|      ## NOTE: Most of this code is copied from |parse_string|
7573    
7574    ## TODO: Support for $get_wrapper
7575    
7576      ## Step 1 # MUST      ## Step 1 # MUST
7577      my $this_doc = $node->owner_document;      my $this_doc = $node->owner_document;
7578      my $doc = $this_doc->implementation->create_document;      my $doc = $this_doc->implementation->create_document;
# Line 7419  sub set_inner_html ($$$) { Line 7634  sub set_inner_html ($$$) {
7634                  0x10FFFE => 1, 0x10FFFF => 1,                  0x10FFFE => 1, 0x10FFFF => 1,
7635                 }->{$self->{next_char}}) {                 }->{$self->{next_char}}) {
7636          !!!cp ('i4.1');          !!!cp ('i4.1');
7637          !!!parse-error (type => 'control char', level => $self->{must_level});          if ($self->{next_char} < 0x10000) {
7638  ## TODO: error type documentation            !!!parse-error (type => 'control char',
7639                              text => (sprintf 'U+%04X', $self->{next_char}));
7640            } else {
7641              !!!parse-error (type => 'control char',
7642                              text => (sprintf 'U-%08X', $self->{next_char}));
7643            }
7644        }        }
7645      };      };
7646      $p->{prev_char} = [-1, -1, -1];      $p->{prev_char} = [-1, -1, -1];

Legend:
Removed from v.1.151  
changed lines
  Added in v.1.166

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24