/[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.112 by wakaba, Sun Mar 16 06:39:57 2008 UTC revision 1.116 by wakaba, Mon Mar 17 13:23:39 2008 UTC
# Line 108  sub parse_byte_string ($$$$;$) { Line 108  sub parse_byte_string ($$$$;$) {
108    $self->{change_encoding} = sub {    $self->{change_encoding} = sub {
109      my $self = shift;      my $self = shift;
110      my $charset = lc shift;      my $charset = lc shift;
111        my $token = shift;
112      ## TODO: if $charset is supported      ## TODO: if $charset is supported
113      ## TODO: normalize charset name      ## TODO: normalize charset name
114    
# Line 126  sub parse_byte_string ($$$$;$) { Line 127  sub parse_byte_string ($$$$;$) {
127      }      }
128    
129      !!!parse-error (type => 'charset label detected:'.$self->{input_encoding}.      !!!parse-error (type => 'charset label detected:'.$self->{input_encoding}.
130          ':'.$charset, level => 'w');          ':'.$charset, level => 'w', token => $token);
131    
132      ## Step 3      ## Step 3
133      # if (can) {      # if (can) {
# Line 544  sub _get_next_token ($) { Line 545  sub _get_next_token ($) {
545            redo A;            redo A;
546          } elsif ($self->{next_char} == 0x003E) { # >          } elsif ($self->{next_char} == 0x003E) { # >
547            !!!cp (21);            !!!cp (21);
548            !!!parse-error (type => 'empty start tag');            !!!parse-error (type => 'empty start tag',
549                              line => $self->{line_prev},
550                              column => $self->{column_prev});
551            $self->{state} = DATA_STATE;            $self->{state} = DATA_STATE;
552            !!!next-input-character;            !!!next-input-character;
553    
# Line 555  sub _get_next_token ($) { Line 558  sub _get_next_token ($) {
558            redo A;            redo A;
559          } elsif ($self->{next_char} == 0x003F) { # ?          } elsif ($self->{next_char} == 0x003F) { # ?
560            !!!cp (22);            !!!cp (22);
561            !!!parse-error (type => 'pio');            !!!parse-error (type => 'pio',
562                              line => $self->{line_prev},
563                              column => $self->{column_prev});
564            $self->{state} = BOGUS_COMMENT_STATE;            $self->{state} = BOGUS_COMMENT_STATE;
565            $self->{current_token} = {type => COMMENT_TOKEN, data => '',            $self->{current_token} = {type => COMMENT_TOKEN, data => '',
566                                      line => $self->{line_prev},                                      line => $self->{line_prev},
# Line 578  sub _get_next_token ($) { Line 583  sub _get_next_token ($) {
583          die "$0: $self->{content_model} in tag open";          die "$0: $self->{content_model} in tag open";
584        }        }
585      } elsif ($self->{state} == CLOSE_TAG_OPEN_STATE) {      } elsif ($self->{state} == CLOSE_TAG_OPEN_STATE) {
586        my ($l, $c) = ($self->{line_prev}, $self->{column_prev});        my ($l, $c) = ($self->{line_prev}, $self->{column_prev} - 1); # "<"of"</"
587        if ($self->{content_model} & CM_LIMITED_MARKUP) { # RCDATA | CDATA        if ($self->{content_model} & CM_LIMITED_MARKUP) { # RCDATA | CDATA
588          if (defined $self->{last_emitted_start_tag_name}) {          if (defined $self->{last_emitted_start_tag_name}) {
589    
# Line 659  sub _get_next_token ($) { Line 664  sub _get_next_token ($) {
664          redo A;          redo A;
665        } elsif ($self->{next_char} == 0x003E) { # >        } elsif ($self->{next_char} == 0x003E) { # >
666          !!!cp (31);          !!!cp (31);
667          !!!parse-error (type => 'empty end tag');          !!!parse-error (type => 'empty end tag',
668                            line => $self->{line_prev}, ## "<" in "</>"
669                            column => $self->{column_prev} - 1);
670          $self->{state} = DATA_STATE;          $self->{state} = DATA_STATE;
671          !!!next-input-character;          !!!next-input-character;
672          redo A;          redo A;
# Line 1651  sub _get_next_token ($) { Line 1658  sub _get_next_token ($) {
1658          redo A;          redo A;
1659        } elsif ($self->{next_char} == 0x002D) { # -        } elsif ($self->{next_char} == 0x002D) { # -
1660          !!!cp (152);          !!!cp (152);
1661          !!!parse-error (type => 'dash in comment');          !!!parse-error (type => 'dash in comment',
1662                            line => $self->{line_prev},
1663                            column => $self->{column_prev});
1664          $self->{current_token}->{data} .= '-'; # comment          $self->{current_token}->{data} .= '-'; # comment
1665          ## Stay in the state          ## Stay in the state
1666          !!!next-input-character;          !!!next-input-character;
# Line 1667  sub _get_next_token ($) { Line 1676  sub _get_next_token ($) {
1676          redo A;          redo A;
1677        } else {        } else {
1678          !!!cp (154);          !!!cp (154);
1679          !!!parse-error (type => 'dash in comment');          !!!parse-error (type => 'dash in comment',
1680                            line => $self->{line_prev},
1681                            column => $self->{column_prev});
1682          $self->{current_token}->{data} .= '--' . chr ($self->{next_char}); # comment          $self->{current_token}->{data} .= '--' . chr ($self->{next_char}); # comment
1683          $self->{state} = COMMENT_STATE;          $self->{state} = COMMENT_STATE;
1684          !!!next-input-character;          !!!next-input-character;
# Line 2511  sub _tree_construction_initial ($) { Line 2522  sub _tree_construction_initial ($) {
2522            defined $token->{public_identifier} or            defined $token->{public_identifier} or
2523            defined $token->{system_identifier}) {            defined $token->{system_identifier}) {
2524          !!!cp ('t1');          !!!cp ('t1');
2525          !!!parse-error (type => 'not HTML5');          !!!parse-error (type => 'not HTML5', token => $token);
2526        } elsif ($doctype_name ne 'HTML') {        } elsif ($doctype_name ne 'HTML') {
2527          !!!cp ('t2');          !!!cp ('t2');
2528          ## ISSUE: ASCII case-insensitive? (in fact it does not matter)          ## ISSUE: ASCII case-insensitive? (in fact it does not matter)
2529          !!!parse-error (type => 'not HTML5');          !!!parse-error (type => 'not HTML5', token => $token);
2530        } else {        } else {
2531          !!!cp ('t3');          !!!cp ('t3');
2532        }        }
# Line 2654  sub _tree_construction_initial ($) { Line 2665  sub _tree_construction_initial ($) {
2665                END_OF_FILE_TOKEN, 1,                END_OF_FILE_TOKEN, 1,
2666               }->{$token->{type}}) {               }->{$token->{type}}) {
2667        !!!cp ('t14');        !!!cp ('t14');
2668        !!!parse-error (type => 'no DOCTYPE');        !!!parse-error (type => 'no DOCTYPE', token => $token);
2669        $self->{document}->manakai_compat_mode ('quirks');        $self->{document}->manakai_compat_mode ('quirks');
2670        ## Go to the "before html" insertion mode.        ## Go to the "before html" insertion mode.
2671        ## reprocess        ## reprocess
# Line 2675  sub _tree_construction_initial ($) { Line 2686  sub _tree_construction_initial ($) {
2686          !!!cp ('t17');          !!!cp ('t17');
2687        }        }
2688    
2689        !!!parse-error (type => 'no DOCTYPE');        !!!parse-error (type => 'no DOCTYPE', token => $token);
2690        $self->{document}->manakai_compat_mode ('quirks');        $self->{document}->manakai_compat_mode ('quirks');
2691        ## Go to the "before html" insertion mode.        ## Go to the "before html" insertion mode.
2692        ## reprocess        ## reprocess
# Line 2704  sub _tree_construction_root_element ($) Line 2715  sub _tree_construction_root_element ($)
2715    B: {    B: {
2716        if ($token->{type} == DOCTYPE_TOKEN) {        if ($token->{type} == DOCTYPE_TOKEN) {
2717          !!!cp ('t19');          !!!cp ('t19');
2718          !!!parse-error (type => 'in html:#DOCTYPE');          !!!parse-error (type => 'in html:#DOCTYPE', token => $token);
2719          ## Ignore the token          ## Ignore the token
2720          ## Stay in the insertion mode.          ## Stay in the insertion mode.
2721          !!!next-token;          !!!next-token;
# Line 2738  sub _tree_construction_root_element ($) Line 2749  sub _tree_construction_root_element ($)
2749        } elsif ($token->{type} == START_TAG_TOKEN) {        } elsif ($token->{type} == START_TAG_TOKEN) {
2750          if ($token->{tag_name} eq 'html') {          if ($token->{tag_name} eq 'html') {
2751            my $root_element;            my $root_element;
2752            !!!create-element ($root_element, $token->{tag_name}, $token->{attributes});            !!!create-element ($root_element, $token->{tag_name}, $token->{attributes}, $token);
2753            $self->{document}->append_child ($root_element);            $self->{document}->append_child ($root_element);
2754            push @{$self->{open_elements}}, [$root_element, 'html'];            push @{$self->{open_elements}}, [$root_element, 'html'];
2755    
# Line 2768  sub _tree_construction_root_element ($) Line 2779  sub _tree_construction_root_element ($)
2779          die "$0: $token->{type}: Unknown token type";          die "$0: $token->{type}: Unknown token type";
2780        }        }
2781    
2782      my $root_element; !!!create-element ($root_element, 'html');      my $root_element; !!!create-element ($root_element, 'html',, $token);
2783      $self->{document}->append_child ($root_element);      $self->{document}->append_child ($root_element);
2784      push @{$self->{open_elements}}, [$root_element, 'html'];      push @{$self->{open_elements}}, [$root_element, 'html'];
2785    
# Line 2963  sub _tree_construction_main ($) { Line 2974  sub _tree_construction_main ($) {
2974      ## Step 1      ## Step 1
2975      my $start_tag_name = $token->{tag_name};      my $start_tag_name = $token->{tag_name};
2976      my $el;      my $el;
2977      !!!create-element ($el, $start_tag_name, $token->{attributes});      !!!create-element ($el, $start_tag_name, $token->{attributes}, $token);
2978    
2979      ## Step 2      ## Step 2
2980      $insert->($el);      $insert->($el);
# Line 3000  sub _tree_construction_main ($) { Line 3011  sub _tree_construction_main ($) {
3011        ## NOTE: An end-of-file token.        ## NOTE: An end-of-file token.
3012        if ($content_model_flag == CDATA_CONTENT_MODEL) {        if ($content_model_flag == CDATA_CONTENT_MODEL) {
3013          !!!cp ('t43');          !!!cp ('t43');
3014          !!!parse-error (type => 'in CDATA:#'.$token->{type});          !!!parse-error (type => 'in CDATA:#'.$token->{type}, token => $token);
3015        } elsif ($content_model_flag == RCDATA_CONTENT_MODEL) {        } elsif ($content_model_flag == RCDATA_CONTENT_MODEL) {
3016          !!!cp ('t44');          !!!cp ('t44');
3017          !!!parse-error (type => 'in RCDATA:#'.$token->{type});          !!!parse-error (type => 'in RCDATA:#'.$token->{type}, token => $token);
3018        } else {        } else {
3019          die "$0: $content_model_flag in parse_rcdata";          die "$0: $content_model_flag in parse_rcdata";
3020        }        }
# Line 3013  sub _tree_construction_main ($) { Line 3024  sub _tree_construction_main ($) {
3024    
3025    my $script_start_tag = sub () {    my $script_start_tag = sub () {
3026      my $script_el;      my $script_el;
3027      !!!create-element ($script_el, 'script', $token->{attributes});      !!!create-element ($script_el, 'script', $token->{attributes}, $token);
3028      ## TODO: mark as "parser-inserted"      ## TODO: mark as "parser-inserted"
3029    
3030      $self->{content_model} = CDATA_CONTENT_MODEL;      $self->{content_model} = CDATA_CONTENT_MODEL;
# Line 3039  sub _tree_construction_main ($) { Line 3050  sub _tree_construction_main ($) {
3050        ## Ignore the token        ## Ignore the token
3051      } else {      } else {
3052        !!!cp ('t48');        !!!cp ('t48');
3053        !!!parse-error (type => 'in CDATA:#'.$token->{type});        !!!parse-error (type => 'in CDATA:#'.$token->{type}, token => $token);
3054        ## ISSUE: And ignore?        ## ISSUE: And ignore?
3055        ## TODO: mark as "already executed"        ## TODO: mark as "already executed"
3056      }      }
# Line 3067  sub _tree_construction_main ($) { Line 3078  sub _tree_construction_main ($) {
3078    my $open_tables = [[$self->{open_elements}->[0]->[0]]];    my $open_tables = [[$self->{open_elements}->[0]->[0]]];
3079    
3080    my $formatting_end_tag = sub {    my $formatting_end_tag = sub {
3081      my $tag_name = shift;      my $end_tag_token = shift;
3082        my $tag_name = $end_tag_token->{tag_name};
3083    
3084      ## NOTE: The adoption agency algorithm (AAA).      ## NOTE: The adoption agency algorithm (AAA).
3085    
# Line 3088  sub _tree_construction_main ($) { Line 3100  sub _tree_construction_main ($) {
3100        } # AFE        } # AFE
3101        unless (defined $formatting_element) {        unless (defined $formatting_element) {
3102          !!!cp ('t53');          !!!cp ('t53');
3103          !!!parse-error (type => 'unmatched end tag:'.$tag_name);          !!!parse-error (type => 'unmatched end tag:'.$tag_name, token => $end_tag_token);
3104          ## Ignore the token          ## Ignore the token
3105          !!!next-token;          !!!next-token;
3106          return;          return;
# Line 3105  sub _tree_construction_main ($) { Line 3117  sub _tree_construction_main ($) {
3117              last INSCOPE;              last INSCOPE;
3118            } else { # in open elements but not in scope            } else { # in open elements but not in scope
3119              !!!cp ('t55');              !!!cp ('t55');
3120              !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name});              !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name},
3121                                token => $end_tag_token);
3122              ## Ignore the token              ## Ignore the token
3123              !!!next-token;              !!!next-token;
3124              return;              return;
# Line 3120  sub _tree_construction_main ($) { Line 3133  sub _tree_construction_main ($) {
3133        } # INSCOPE        } # INSCOPE
3134        unless (defined $formatting_element_i_in_open) {        unless (defined $formatting_element_i_in_open) {
3135          !!!cp ('t57');          !!!cp ('t57');
3136          !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name});          !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name},
3137                            token => $end_tag_token);
3138          pop @$active_formatting_elements; # $formatting_element          pop @$active_formatting_elements; # $formatting_element
3139          !!!next-token; ## TODO: ok?          !!!next-token; ## TODO: ok?
3140          return;          return;
3141        }        }
3142        if (not $self->{open_elements}->[-1]->[0] eq $formatting_element->[0]) {        if (not $self->{open_elements}->[-1]->[0] eq $formatting_element->[0]) {
3143          !!!cp ('t58');          !!!cp ('t58');
3144          !!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]);          !!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1],
3145                            token => $end_tag_token);
3146        }        }
3147                
3148        ## Step 2        ## Step 2
# Line 3338  sub _tree_construction_main ($) { Line 3353  sub _tree_construction_main ($) {
3353    B: {    B: {
3354      if ($token->{type} == DOCTYPE_TOKEN) {      if ($token->{type} == DOCTYPE_TOKEN) {
3355        !!!cp ('t73');        !!!cp ('t73');
3356        !!!parse-error (type => 'DOCTYPE in the middle');        !!!parse-error (type => 'DOCTYPE in the middle', token => $token);
3357        ## Ignore the token        ## Ignore the token
3358        ## Stay in the phase        ## Stay in the phase
3359        !!!next-token;        !!!next-token;
# Line 3347  sub _tree_construction_main ($) { Line 3362  sub _tree_construction_main ($) {
3362               $token->{tag_name} eq 'html') {               $token->{tag_name} eq 'html') {
3363        if ($self->{insertion_mode} == AFTER_HTML_BODY_IM) {        if ($self->{insertion_mode} == AFTER_HTML_BODY_IM) {
3364          !!!cp ('t79');          !!!cp ('t79');
3365          !!!parse-error (type => 'after html:html');          !!!parse-error (type => 'after html:html', token => $token);
3366          $self->{insertion_mode} = AFTER_BODY_IM;          $self->{insertion_mode} = AFTER_BODY_IM;
3367        } elsif ($self->{insertion_mode} == AFTER_HTML_FRAMESET_IM) {        } elsif ($self->{insertion_mode} == AFTER_HTML_FRAMESET_IM) {
3368          !!!cp ('t80');          !!!cp ('t80');
3369          !!!parse-error (type => 'after html:html');          !!!parse-error (type => 'after html:html', token => $token);
3370          $self->{insertion_mode} = AFTER_FRAMESET_IM;          $self->{insertion_mode} = AFTER_FRAMESET_IM;
3371        } else {        } else {
3372          !!!cp ('t81');          !!!cp ('t81');
3373        }        }
3374    
3375        !!!cp ('t82');        !!!cp ('t82');
3376        !!!parse-error (type => 'not first start tag');        !!!parse-error (type => 'not first start tag', token => $token);
3377        my $top_el = $self->{open_elements}->[0]->[0];        my $top_el = $self->{open_elements}->[0]->[0];
3378        for my $attr_name (keys %{$token->{attributes}}) {        for my $attr_name (keys %{$token->{attributes}}) {
3379          unless ($top_el->has_attribute_ns (undef, $attr_name)) {          unless ($top_el->has_attribute_ns (undef, $attr_name)) {
# Line 3406  sub _tree_construction_main ($) { Line 3421  sub _tree_construction_main ($) {
3421          if ($self->{insertion_mode} == BEFORE_HEAD_IM) {          if ($self->{insertion_mode} == BEFORE_HEAD_IM) {
3422            !!!cp ('t89');            !!!cp ('t89');
3423            ## As if <head>            ## As if <head>
3424            !!!create-element ($self->{head_element}, 'head');            !!!create-element ($self->{head_element}, 'head',, $token);
3425            $self->{open_elements}->[-1]->[0]->append_child ($self->{head_element});            $self->{open_elements}->[-1]->[0]->append_child ($self->{head_element});
3426            push @{$self->{open_elements}}, [$self->{head_element}, 'head'];            push @{$self->{open_elements}}, [$self->{head_element}, 'head'];
3427    
# Line 3418  sub _tree_construction_main ($) { Line 3433  sub _tree_construction_main ($) {
3433            !!!cp ('t90');            !!!cp ('t90');
3434            ## As if </noscript>            ## As if </noscript>
3435            pop @{$self->{open_elements}};            pop @{$self->{open_elements}};
3436            !!!parse-error (type => 'in noscript:#character');            !!!parse-error (type => 'in noscript:#character', token => $token);
3437                        
3438            ## Reprocess in the "in head" insertion mode...            ## Reprocess in the "in head" insertion mode...
3439            ## As if </head>            ## As if </head>
# Line 3436  sub _tree_construction_main ($) { Line 3451  sub _tree_construction_main ($) {
3451    
3452              ## "after head" insertion mode              ## "after head" insertion mode
3453              ## As if <body>              ## As if <body>
3454              !!!insert-element ('body');              !!!insert-element ('body',, $token);
3455              $self->{insertion_mode} = IN_BODY_IM;              $self->{insertion_mode} = IN_BODY_IM;
3456              ## reprocess              ## reprocess
3457              redo B;              redo B;
# Line 3444  sub _tree_construction_main ($) { Line 3459  sub _tree_construction_main ($) {
3459              if ($token->{tag_name} eq 'head') {              if ($token->{tag_name} eq 'head') {
3460                if ($self->{insertion_mode} == BEFORE_HEAD_IM) {                if ($self->{insertion_mode} == BEFORE_HEAD_IM) {
3461                  !!!cp ('t93');                  !!!cp ('t93');
3462                  !!!create-element ($self->{head_element}, $token->{tag_name}, $token->{attributes});                  !!!create-element ($self->{head_element}, $token->{tag_name}, $token->{attributes}, $token);
3463                  $self->{open_elements}->[-1]->[0]->append_child ($self->{head_element});                  $self->{open_elements}->[-1]->[0]->append_child ($self->{head_element});
3464                  push @{$self->{open_elements}}, [$self->{head_element}, $token->{tag_name}];                  push @{$self->{open_elements}}, [$self->{head_element}, $token->{tag_name}];
3465                  $self->{insertion_mode} = IN_HEAD_IM;                  $self->{insertion_mode} = IN_HEAD_IM;
# Line 3455  sub _tree_construction_main ($) { Line 3470  sub _tree_construction_main ($) {
3470                  #                  #
3471                } else {                } else {
3472                  !!!cp ('t95');                  !!!cp ('t95');
3473                  !!!parse-error (type => 'in head:head'); # or in head noscript                  !!!parse-error (type => 'in head:head', token => $token); # or in head noscript
3474                  ## Ignore the token                  ## Ignore the token
3475                  !!!next-token;                  !!!next-token;
3476                  redo B;                  redo B;
# Line 3463  sub _tree_construction_main ($) { Line 3478  sub _tree_construction_main ($) {
3478              } elsif ($self->{insertion_mode} == BEFORE_HEAD_IM) {              } elsif ($self->{insertion_mode} == BEFORE_HEAD_IM) {
3479                !!!cp ('t96');                !!!cp ('t96');
3480                ## As if <head>                ## As if <head>
3481                !!!create-element ($self->{head_element}, 'head');                !!!create-element ($self->{head_element}, 'head',, $token);
3482                $self->{open_elements}->[-1]->[0]->append_child ($self->{head_element});                $self->{open_elements}->[-1]->[0]->append_child ($self->{head_element});
3483                push @{$self->{open_elements}}, [$self->{head_element}, 'head'];                push @{$self->{open_elements}}, [$self->{head_element}, 'head'];
3484    
# Line 3478  sub _tree_construction_main ($) { Line 3493  sub _tree_construction_main ($) {
3493                  !!!cp ('t98');                  !!!cp ('t98');
3494                  ## As if </noscript>                  ## As if </noscript>
3495                  pop @{$self->{open_elements}};                  pop @{$self->{open_elements}};
3496                  !!!parse-error (type => 'in noscript:base');                  !!!parse-error (type => 'in noscript:base', token => $token);
3497                                
3498                  $self->{insertion_mode} = IN_HEAD_IM;                  $self->{insertion_mode} = IN_HEAD_IM;
3499                  ## Reprocess in the "in head" insertion mode...                  ## Reprocess in the "in head" insertion mode...
# Line 3489  sub _tree_construction_main ($) { Line 3504  sub _tree_construction_main ($) {
3504                ## NOTE: There is a "as if in head" code clone.                ## NOTE: There is a "as if in head" code clone.
3505                if ($self->{insertion_mode} == AFTER_HEAD_IM) {                if ($self->{insertion_mode} == AFTER_HEAD_IM) {
3506                  !!!cp ('t100');                  !!!cp ('t100');
3507                  !!!parse-error (type => 'after head:'.$token->{tag_name});                  !!!parse-error (type => 'after head:'.$token->{tag_name}, token => $token);
3508                  push @{$self->{open_elements}}, [$self->{head_element}, 'head'];                  push @{$self->{open_elements}}, [$self->{head_element}, 'head'];
3509                } else {                } else {
3510                  !!!cp ('t101');                  !!!cp ('t101');
3511                }                }
3512                !!!insert-element ($token->{tag_name}, $token->{attributes});                !!!insert-element ($token->{tag_name}, $token->{attributes}, $token);
3513                pop @{$self->{open_elements}}; ## ISSUE: This step is missing in the spec.                pop @{$self->{open_elements}}; ## ISSUE: This step is missing in the spec.
3514                pop @{$self->{open_elements}} # <head>                pop @{$self->{open_elements}} # <head>
3515                    if $self->{insertion_mode} == AFTER_HEAD_IM;                    if $self->{insertion_mode} == AFTER_HEAD_IM;
# Line 3504  sub _tree_construction_main ($) { Line 3519  sub _tree_construction_main ($) {
3519                ## NOTE: There is a "as if in head" code clone.                ## NOTE: There is a "as if in head" code clone.
3520                if ($self->{insertion_mode} == AFTER_HEAD_IM) {                if ($self->{insertion_mode} == AFTER_HEAD_IM) {
3521                  !!!cp ('t102');                  !!!cp ('t102');
3522                  !!!parse-error (type => 'after head:'.$token->{tag_name});                  !!!parse-error (type => 'after head:'.$token->{tag_name}, token => $token);
3523                  push @{$self->{open_elements}}, [$self->{head_element}, 'head'];                  push @{$self->{open_elements}}, [$self->{head_element}, 'head'];
3524                } else {                } else {
3525                  !!!cp ('t103');                  !!!cp ('t103');
3526                }                }
3527                !!!insert-element ($token->{tag_name}, $token->{attributes});                !!!insert-element ($token->{tag_name}, $token->{attributes}, $token);
3528                pop @{$self->{open_elements}}; ## ISSUE: This step is missing in the spec.                pop @{$self->{open_elements}}; ## ISSUE: This step is missing in the spec.
3529                pop @{$self->{open_elements}} # <head>                pop @{$self->{open_elements}} # <head>
3530                    if $self->{insertion_mode} == AFTER_HEAD_IM;                    if $self->{insertion_mode} == AFTER_HEAD_IM;
# Line 3519  sub _tree_construction_main ($) { Line 3534  sub _tree_construction_main ($) {
3534                ## NOTE: There is a "as if in head" code clone.                ## NOTE: There is a "as if in head" code clone.
3535                if ($self->{insertion_mode} == AFTER_HEAD_IM) {                if ($self->{insertion_mode} == AFTER_HEAD_IM) {
3536                  !!!cp ('t104');                  !!!cp ('t104');
3537                  !!!parse-error (type => 'after head:'.$token->{tag_name});                  !!!parse-error (type => 'after head:'.$token->{tag_name}, token => $token);
3538                  push @{$self->{open_elements}}, [$self->{head_element}, 'head'];                  push @{$self->{open_elements}}, [$self->{head_element}, 'head'];
3539                } else {                } else {
3540                  !!!cp ('t105');                  !!!cp ('t105');
3541                }                }
3542                !!!insert-element ($token->{tag_name}, $token->{attributes});                !!!insert-element ($token->{tag_name}, $token->{attributes}, $token);
3543                my $meta_el = pop @{$self->{open_elements}}; ## ISSUE: This step is missing in the spec.                my $meta_el = pop @{$self->{open_elements}}; ## ISSUE: This step is missing in the spec.
3544    
3545                unless ($self->{confident}) {                unless ($self->{confident}) {
3546                  if ($token->{attributes}->{charset}) { ## TODO: And if supported                  if ($token->{attributes}->{charset}) { ## TODO: And if supported
3547                    !!!cp ('t106');                    !!!cp ('t106');
3548                    $self->{change_encoding}                    $self->{change_encoding}
3549                        ->($self, $token->{attributes}->{charset}->{value});                        ->($self, $token->{attributes}->{charset}->{value},
3550                             $token);
3551                                        
3552                    $meta_el->[0]->get_attribute_node_ns (undef, 'charset')                    $meta_el->[0]->get_attribute_node_ns (undef, 'charset')
3553                        ->set_user_data (manakai_has_reference =>                        ->set_user_data (manakai_has_reference =>
# Line 3546  sub _tree_construction_main ($) { Line 3562  sub _tree_construction_main ($) {
3562                            ([^"'\x09-\x0D\x20][^\x09-\x0D\x20]*))/x) {                            ([^"'\x09-\x0D\x20][^\x09-\x0D\x20]*))/x) {
3563                      !!!cp ('t107');                      !!!cp ('t107');
3564                      $self->{change_encoding}                      $self->{change_encoding}
3565                          ->($self, defined $1 ? $1 : defined $2 ? $2 : $3);                          ->($self, defined $1 ? $1 : defined $2 ? $2 : $3,
3566                               $token);
3567                      $meta_el->[0]->get_attribute_node_ns (undef, 'content')                      $meta_el->[0]->get_attribute_node_ns (undef, 'content')
3568                          ->set_user_data (manakai_has_reference =>                          ->set_user_data (manakai_has_reference =>
3569                                               $token->{attributes}->{content}                                               $token->{attributes}->{content}
# Line 3581  sub _tree_construction_main ($) { Line 3598  sub _tree_construction_main ($) {
3598                  !!!cp ('t111');                  !!!cp ('t111');
3599                  ## As if </noscript>                  ## As if </noscript>
3600                  pop @{$self->{open_elements}};                  pop @{$self->{open_elements}};
3601                  !!!parse-error (type => 'in noscript:title');                  !!!parse-error (type => 'in noscript:title', token => $token);
3602                                
3603                  $self->{insertion_mode} = IN_HEAD_IM;                  $self->{insertion_mode} = IN_HEAD_IM;
3604                  ## Reprocess in the "in head" insertion mode...                  ## Reprocess in the "in head" insertion mode...
3605                } elsif ($self->{insertion_mode} == AFTER_HEAD_IM) {                } elsif ($self->{insertion_mode} == AFTER_HEAD_IM) {
3606                  !!!cp ('t112');                  !!!cp ('t112');
3607                  !!!parse-error (type => 'after head:'.$token->{tag_name});                  !!!parse-error (type => 'after head:'.$token->{tag_name}, token => $token);
3608                  push @{$self->{open_elements}}, [$self->{head_element}, 'head'];                  push @{$self->{open_elements}}, [$self->{head_element}, 'head'];
3609                } else {                } else {
3610                  !!!cp ('t113');                  !!!cp ('t113');
# Line 3606  sub _tree_construction_main ($) { Line 3623  sub _tree_construction_main ($) {
3623                ## NOTE: There is a "as if in head" code clone.                ## NOTE: There is a "as if in head" code clone.
3624                if ($self->{insertion_mode} == AFTER_HEAD_IM) {                if ($self->{insertion_mode} == AFTER_HEAD_IM) {
3625                  !!!cp ('t114');                  !!!cp ('t114');
3626                  !!!parse-error (type => 'after head:'.$token->{tag_name});                  !!!parse-error (type => 'after head:'.$token->{tag_name}, token => $token);
3627                  push @{$self->{open_elements}}, [$self->{head_element}, 'head'];                  push @{$self->{open_elements}}, [$self->{head_element}, 'head'];
3628                } else {                } else {
3629                  !!!cp ('t115');                  !!!cp ('t115');
# Line 3619  sub _tree_construction_main ($) { Line 3636  sub _tree_construction_main ($) {
3636                if ($self->{insertion_mode} == IN_HEAD_IM) {                if ($self->{insertion_mode} == IN_HEAD_IM) {
3637                  !!!cp ('t116');                  !!!cp ('t116');
3638                  ## NOTE: and scripting is disalbed                  ## NOTE: and scripting is disalbed
3639                  !!!insert-element ($token->{tag_name}, $token->{attributes});                  !!!insert-element ($token->{tag_name}, $token->{attributes}, $token);
3640                  $self->{insertion_mode} = IN_HEAD_NOSCRIPT_IM;                  $self->{insertion_mode} = IN_HEAD_NOSCRIPT_IM;
3641                  !!!next-token;                  !!!next-token;
3642                  redo B;                  redo B;
3643                } elsif ($self->{insertion_mode} == IN_HEAD_NOSCRIPT_IM) {                } elsif ($self->{insertion_mode} == IN_HEAD_NOSCRIPT_IM) {
3644                  !!!cp ('t117');                  !!!cp ('t117');
3645                  !!!parse-error (type => 'in noscript:noscript');                  !!!parse-error (type => 'in noscript:noscript', token => $token);
3646                  ## Ignore the token                  ## Ignore the token
3647                  !!!next-token;                  !!!next-token;
3648                  redo B;                  redo B;
# Line 3638  sub _tree_construction_main ($) { Line 3655  sub _tree_construction_main ($) {
3655                  !!!cp ('t119');                  !!!cp ('t119');
3656                  ## As if </noscript>                  ## As if </noscript>
3657                  pop @{$self->{open_elements}};                  pop @{$self->{open_elements}};
3658                  !!!parse-error (type => 'in noscript:script');                  !!!parse-error (type => 'in noscript:script', token => $token);
3659                                
3660                  $self->{insertion_mode} = IN_HEAD_IM;                  $self->{insertion_mode} = IN_HEAD_IM;
3661                  ## Reprocess in the "in head" insertion mode...                  ## Reprocess in the "in head" insertion mode...
3662                } elsif ($self->{insertion_mode} == AFTER_HEAD_IM) {                } elsif ($self->{insertion_mode} == AFTER_HEAD_IM) {
3663                  !!!cp ('t120');                  !!!cp ('t120');
3664                  !!!parse-error (type => 'after head:'.$token->{tag_name});                  !!!parse-error (type => 'after head:'.$token->{tag_name}, token => $token);
3665                  push @{$self->{open_elements}}, [$self->{head_element}, 'head'];                  push @{$self->{open_elements}}, [$self->{head_element}, 'head'];
3666                } else {                } else {
3667                  !!!cp ('t121');                  !!!cp ('t121');
# Line 3661  sub _tree_construction_main ($) { Line 3678  sub _tree_construction_main ($) {
3678                  !!!cp ('t122');                  !!!cp ('t122');
3679                  ## As if </noscript>                  ## As if </noscript>
3680                  pop @{$self->{open_elements}};                  pop @{$self->{open_elements}};
3681                  !!!parse-error (type => 'in noscript:'.$token->{tag_name});                  !!!parse-error (type => 'in noscript:'.$token->{tag_name}, token => $token);
3682                                    
3683                  ## Reprocess in the "in head" insertion mode...                  ## Reprocess in the "in head" insertion mode...
3684                  ## As if </head>                  ## As if </head>
# Line 3678  sub _tree_construction_main ($) { Line 3695  sub _tree_construction_main ($) {
3695                }                }
3696    
3697                ## "after head" insertion mode                ## "after head" insertion mode
3698                !!!insert-element ($token->{tag_name}, $token->{attributes});                !!!insert-element ($token->{tag_name}, $token->{attributes}, $token);
3699                if ($token->{tag_name} eq 'body') {                if ($token->{tag_name} eq 'body') {
3700                  !!!cp ('t126');                  !!!cp ('t126');
3701                  $self->{insertion_mode} = IN_BODY_IM;                  $self->{insertion_mode} = IN_BODY_IM;
# Line 3699  sub _tree_construction_main ($) { Line 3716  sub _tree_construction_main ($) {
3716                !!!cp ('t129');                !!!cp ('t129');
3717                ## As if </noscript>                ## As if </noscript>
3718                pop @{$self->{open_elements}};                pop @{$self->{open_elements}};
3719                !!!parse-error (type => 'in noscript:/'.$token->{tag_name});                !!!parse-error (type => 'in noscript:/'.$token->{tag_name}, token => $token);
3720                                
3721                ## Reprocess in the "in head" insertion mode...                ## Reprocess in the "in head" insertion mode...
3722                ## As if </head>                ## As if </head>
# Line 3718  sub _tree_construction_main ($) { Line 3735  sub _tree_construction_main ($) {
3735    
3736              ## "after head" insertion mode              ## "after head" insertion mode
3737              ## As if <body>              ## As if <body>
3738              !!!insert-element ('body');              !!!insert-element ('body',, $token);
3739              $self->{insertion_mode} = IN_BODY_IM;              $self->{insertion_mode} = IN_BODY_IM;
3740              ## reprocess              ## reprocess
3741              redo B;              redo B;
# Line 3727  sub _tree_construction_main ($) { Line 3744  sub _tree_construction_main ($) {
3744                if ($self->{insertion_mode} == BEFORE_HEAD_IM) {                if ($self->{insertion_mode} == BEFORE_HEAD_IM) {
3745                  !!!cp ('t132');                  !!!cp ('t132');
3746                  ## As if <head>                  ## As if <head>
3747                  !!!create-element ($self->{head_element}, 'head');                  !!!create-element ($self->{head_element}, 'head',, $token);
3748                  $self->{open_elements}->[-1]->[0]->append_child ($self->{head_element});                  $self->{open_elements}->[-1]->[0]->append_child ($self->{head_element});
3749                  push @{$self->{open_elements}}, [$self->{head_element}, 'head'];                  push @{$self->{open_elements}}, [$self->{head_element}, 'head'];
3750    
# Line 3740  sub _tree_construction_main ($) { Line 3757  sub _tree_construction_main ($) {
3757                  !!!cp ('t133');                  !!!cp ('t133');
3758                  ## As if </noscript>                  ## As if </noscript>
3759                  pop @{$self->{open_elements}};                  pop @{$self->{open_elements}};
3760                  !!!parse-error (type => 'in noscript:/head');                  !!!parse-error (type => 'in noscript:/head', token => $token);
3761                                    
3762                  ## Reprocess in the "in head" insertion mode...                  ## Reprocess in the "in head" insertion mode...
3763                  pop @{$self->{open_elements}};                  pop @{$self->{open_elements}};
# Line 3766  sub _tree_construction_main ($) { Line 3783  sub _tree_construction_main ($) {
3783                  redo B;                  redo B;
3784                } elsif ($self->{insertion_mode} == BEFORE_HEAD_IM) {                } elsif ($self->{insertion_mode} == BEFORE_HEAD_IM) {
3785                  !!!cp ('t137');                  !!!cp ('t137');
3786                  !!!parse-error (type => 'unmatched end tag:noscript');                  !!!parse-error (type => 'unmatched end tag:noscript', token => $token);
3787                  ## Ignore the token ## ISSUE: An issue in the spec.                  ## Ignore the token ## ISSUE: An issue in the spec.
3788                  !!!next-token;                  !!!next-token;
3789                  redo B;                  redo B;
# Line 3780  sub _tree_construction_main ($) { Line 3797  sub _tree_construction_main ($) {
3797                if ($self->{insertion_mode} == BEFORE_HEAD_IM) {                if ($self->{insertion_mode} == BEFORE_HEAD_IM) {
3798                  !!!cp ('t139');                  !!!cp ('t139');
3799                  ## As if <head>                  ## As if <head>
3800                  !!!create-element ($self->{head_element}, 'head');                  !!!create-element ($self->{head_element}, 'head',, $token);
3801                  $self->{open_elements}->[-1]->[0]->append_child ($self->{head_element});                  $self->{open_elements}->[-1]->[0]->append_child ($self->{head_element});
3802                  push @{$self->{open_elements}}, [$self->{head_element}, 'head'];                  push @{$self->{open_elements}}, [$self->{head_element}, 'head'];
3803    
# Line 3788  sub _tree_construction_main ($) { Line 3805  sub _tree_construction_main ($) {
3805                  ## Reprocess in the "in head" insertion mode...                  ## Reprocess in the "in head" insertion mode...
3806                } elsif ($self->{insertion_mode} == IN_HEAD_NOSCRIPT_IM) {                } elsif ($self->{insertion_mode} == IN_HEAD_NOSCRIPT_IM) {
3807                  !!!cp ('t140');                  !!!cp ('t140');
3808                  !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name});                  !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token);
3809                  ## Ignore the token                  ## Ignore the token
3810                  !!!next-token;                  !!!next-token;
3811                  redo B;                  redo B;
# Line 3803  sub _tree_construction_main ($) { Line 3820  sub _tree_construction_main ($) {
3820                if ($self->{insertion_mode} == BEFORE_HEAD_IM) {                if ($self->{insertion_mode} == BEFORE_HEAD_IM) {
3821                  !!!cp ('t142');                  !!!cp ('t142');
3822                  ## As if <head>                  ## As if <head>
3823                  !!!create-element ($self->{head_element}, 'head');                  !!!create-element ($self->{head_element}, 'head',, $token);
3824                  $self->{open_elements}->[-1]->[0]->append_child ($self->{head_element});                  $self->{open_elements}->[-1]->[0]->append_child ($self->{head_element});
3825                  push @{$self->{open_elements}}, [$self->{head_element}, 'head'];                  push @{$self->{open_elements}}, [$self->{head_element}, 'head'];
3826    
# Line 3820  sub _tree_construction_main ($) { Line 3837  sub _tree_construction_main ($) {
3837                  #                  #
3838                } else {                } else {
3839                  !!!cp ('t145');                  !!!cp ('t145');
3840                  !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name});                  !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token);
3841                  ## Ignore the token                  ## Ignore the token
3842                  !!!next-token;                  !!!next-token;
3843                  redo B;                  redo B;
# Line 3831  sub _tree_construction_main ($) { Line 3848  sub _tree_construction_main ($) {
3848                !!!cp ('t146');                !!!cp ('t146');
3849                ## As if </noscript>                ## As if </noscript>
3850                pop @{$self->{open_elements}};                pop @{$self->{open_elements}};
3851                !!!parse-error (type => 'in noscript:/'.$token->{tag_name});                !!!parse-error (type => 'in noscript:/'.$token->{tag_name}, token => $token);
3852                                
3853                ## Reprocess in the "in head" insertion mode...                ## Reprocess in the "in head" insertion mode...
3854                ## As if </head>                ## As if </head>
# Line 3847  sub _tree_construction_main ($) { Line 3864  sub _tree_construction_main ($) {
3864              } elsif ($self->{insertion_mode} == BEFORE_HEAD_IM) {              } elsif ($self->{insertion_mode} == BEFORE_HEAD_IM) {
3865  ## ISSUE: This case cannot be reached?  ## ISSUE: This case cannot be reached?
3866                !!!cp ('t148');                !!!cp ('t148');
3867                !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name});                !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token);
3868                ## Ignore the token ## ISSUE: An issue in the spec.                ## Ignore the token ## ISSUE: An issue in the spec.
3869                !!!next-token;                !!!next-token;
3870                redo B;                redo B;
# Line 3857  sub _tree_construction_main ($) { Line 3874  sub _tree_construction_main ($) {
3874    
3875              ## "after head" insertion mode              ## "after head" insertion mode
3876              ## As if <body>              ## As if <body>
3877              !!!insert-element ('body');              !!!insert-element ('body',, $token);
3878              $self->{insertion_mode} = IN_BODY_IM;              $self->{insertion_mode} = IN_BODY_IM;
3879              ## reprocess              ## reprocess
3880              redo B;              redo B;
# Line 3866  sub _tree_construction_main ($) { Line 3883  sub _tree_construction_main ($) {
3883            !!!cp ('t149.1');            !!!cp ('t149.1');
3884    
3885            ## NOTE: As if <head>            ## NOTE: As if <head>
3886            !!!create-element ($self->{head_element}, 'head');            !!!create-element ($self->{head_element}, 'head',, $token);
3887            $self->{open_elements}->[-1]->[0]->append_child            $self->{open_elements}->[-1]->[0]->append_child
3888                ($self->{head_element});                ($self->{head_element});
3889            #push @{$self->{open_elements}}, [$self->{head_element}, 'head'];            #push @{$self->{open_elements}}, [$self->{head_element}, 'head'];
# Line 3891  sub _tree_construction_main ($) { Line 3908  sub _tree_construction_main ($) {
3908          } elsif ($self->{insertion_mode} == IN_HEAD_NOSCRIPT_IM) {          } elsif ($self->{insertion_mode} == IN_HEAD_NOSCRIPT_IM) {
3909            !!!cp ('t149.3');            !!!cp ('t149.3');
3910    
3911            !!!parse-error (type => 'in noscript:#eof');            !!!parse-error (type => 'in noscript:#eof', token => $token);
3912    
3913            ## As if </noscript>            ## As if </noscript>
3914            pop @{$self->{open_elements}};            pop @{$self->{open_elements}};
# Line 3910  sub _tree_construction_main ($) { Line 3927  sub _tree_construction_main ($) {
3927          }          }
3928    
3929          ## NOTE: As if <body>          ## NOTE: As if <body>
3930          !!!insert-element ('body');          !!!insert-element ('body',, $token);
3931          $self->{insertion_mode} = IN_BODY_IM;          $self->{insertion_mode} = IN_BODY_IM;
3932          ## NOTE: Reprocess.          ## NOTE: Reprocess.
3933          redo B;          redo B;
# Line 3943  sub _tree_construction_main ($) { Line 3960  sub _tree_construction_main ($) {
3960    
3961                      ## Close the cell                      ## Close the cell
3962                      !!!back-token; # <?>                      !!!back-token; # <?>
3963                      $token = {type => END_TAG_TOKEN, tag_name => $node->[1]};                      $token = {type => END_TAG_TOKEN, tag_name => $node->[1],
3964                                  line => $token->{line},
3965                                  column => $token->{column}};
3966                      redo B;                      redo B;
3967                    } elsif ({                    } elsif ({
3968                              table => 1, html => 1,                              table => 1, html => 1,
# Line 3956  sub _tree_construction_main ($) { Line 3975  sub _tree_construction_main ($) {
3975    
3976                  !!!cp ('t153');                  !!!cp ('t153');
3977                  !!!parse-error (type => 'start tag not allowed',                  !!!parse-error (type => 'start tag not allowed',
3978                      value => $token->{tag_name});                      value => $token->{tag_name}, token => $token);
3979                  ## Ignore the token                  ## Ignore the token
3980                  !!!next-token;                  !!!next-token;
3981                  redo B;                  redo B;
3982                } elsif ($self->{insertion_mode} == IN_CAPTION_IM) {                } elsif ($self->{insertion_mode} == IN_CAPTION_IM) {
3983                  !!!parse-error (type => 'not closed:caption');                  !!!parse-error (type => 'not closed:caption', token => $token);
3984                                    
3985                  ## NOTE: As if </caption>.                  ## NOTE: As if </caption>.
3986                  ## have a table element in table scope                  ## have a table element in table scope
# Line 3983  sub _tree_construction_main ($) { Line 4002  sub _tree_construction_main ($) {
4002    
4003                    !!!cp ('t157');                    !!!cp ('t157');
4004                    !!!parse-error (type => 'start tag not allowed',                    !!!parse-error (type => 'start tag not allowed',
4005                                    value => $token->{tag_name});                                    value => $token->{tag_name}, token => $token);
4006                    ## Ignore the token                    ## Ignore the token
4007                    !!!next-token;                    !!!next-token;
4008                    redo B;                    redo B;
# Line 3999  sub _tree_construction_main ($) { Line 4018  sub _tree_construction_main ($) {
4018    
4019                  if ($self->{open_elements}->[-1]->[1] ne 'caption') {                  if ($self->{open_elements}->[-1]->[1] ne 'caption') {
4020                    !!!cp ('t159');                    !!!cp ('t159');
4021                    !!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]);                    !!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1], token => $token);
4022                  } else {                  } else {
4023                    !!!cp ('t160');                    !!!cp ('t160');
4024                  }                  }
# Line 4040  sub _tree_construction_main ($) { Line 4059  sub _tree_construction_main ($) {
4059                  } # INSCOPE                  } # INSCOPE
4060                    unless (defined $i) {                    unless (defined $i) {
4061                      !!!cp ('t165');                      !!!cp ('t165');
4062                      !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name});                      !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token);
4063                      ## Ignore the token                      ## Ignore the token
4064                      !!!next-token;                      !!!next-token;
4065                      redo B;                      redo B;
# Line 4056  sub _tree_construction_main ($) { Line 4075  sub _tree_construction_main ($) {
4075    
4076                  if ($self->{open_elements}->[-1]->[1] ne $token->{tag_name}) {                  if ($self->{open_elements}->[-1]->[1] ne $token->{tag_name}) {
4077                    !!!cp ('t167');                    !!!cp ('t167');
4078                    !!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]);                    !!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1], token => $token);
4079                  } else {                  } else {
4080                    !!!cp ('t168');                    !!!cp ('t168');
4081                  }                  }
# Line 4071  sub _tree_construction_main ($) { Line 4090  sub _tree_construction_main ($) {
4090                  redo B;                  redo B;
4091                } elsif ($self->{insertion_mode} == IN_CAPTION_IM) {                } elsif ($self->{insertion_mode} == IN_CAPTION_IM) {
4092                  !!!cp ('t169');                  !!!cp ('t169');
4093                  !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name});                  !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token);
4094                  ## Ignore the token                  ## Ignore the token
4095                  !!!next-token;                  !!!next-token;
4096                  redo B;                  redo B;
# Line 4100  sub _tree_construction_main ($) { Line 4119  sub _tree_construction_main ($) {
4119    
4120                    !!!cp ('t173');                    !!!cp ('t173');
4121                    !!!parse-error (type => 'unmatched end tag',                    !!!parse-error (type => 'unmatched end tag',
4122                                    value => $token->{tag_name});                                    value => $token->{tag_name}, token => $token);
4123                    ## Ignore the token                    ## Ignore the token
4124                    !!!next-token;                    !!!next-token;
4125                    redo B;                    redo B;
# Line 4116  sub _tree_construction_main ($) { Line 4135  sub _tree_construction_main ($) {
4135                                    
4136                  if ($self->{open_elements}->[-1]->[1] ne 'caption') {                  if ($self->{open_elements}->[-1]->[1] ne 'caption') {
4137                    !!!cp ('t175');                    !!!cp ('t175');
4138                    !!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]);                    !!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1], token => $token);
4139                  } else {                  } else {
4140                    !!!cp ('t176');                    !!!cp ('t176');
4141                  }                  }
# Line 4131  sub _tree_construction_main ($) { Line 4150  sub _tree_construction_main ($) {
4150                  redo B;                  redo B;
4151                } elsif ($self->{insertion_mode} == IN_CELL_IM) {                } elsif ($self->{insertion_mode} == IN_CELL_IM) {
4152                  !!!cp ('t177');                  !!!cp ('t177');
4153                  !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name});                  !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token);
4154                  ## Ignore the token                  ## Ignore the token
4155                  !!!next-token;                  !!!next-token;
4156                  redo B;                  redo B;
# Line 4156  sub _tree_construction_main ($) { Line 4175  sub _tree_construction_main ($) {
4175    
4176                      ## Close the cell                      ## Close the cell
4177                      !!!back-token; # </?>                      !!!back-token; # </?>
4178                      $token = {type => END_TAG_TOKEN, tag_name => $tn};                      $token = {type => END_TAG_TOKEN, tag_name => $tn,
4179                                  line => $token->{line},
4180                                  column => $token->{column}};
4181                      redo B;                      redo B;
4182                    } elsif ($node->[1] eq 'td' or $node->[1] eq 'th') {                    } elsif ($node->[1] eq 'td' or $node->[1] eq 'th') {
4183                      !!!cp ('t180');                      !!!cp ('t180');
# Line 4174  sub _tree_construction_main ($) { Line 4195  sub _tree_construction_main ($) {
4195    
4196                  !!!cp ('t182');                  !!!cp ('t182');
4197                  !!!parse-error (type => 'unmatched end tag',                  !!!parse-error (type => 'unmatched end tag',
4198                      value => $token->{tag_name});                      value => $token->{tag_name}, token => $token);
4199                  ## Ignore the token                  ## Ignore the token
4200                  !!!next-token;                  !!!next-token;
4201                  redo B;                  redo B;
4202                } # INSCOPE                } # INSCOPE
4203              } elsif ($token->{tag_name} eq 'table' and              } elsif ($token->{tag_name} eq 'table' and
4204                       $self->{insertion_mode} == IN_CAPTION_IM) {                       $self->{insertion_mode} == IN_CAPTION_IM) {
4205                !!!parse-error (type => 'not closed:caption');                !!!parse-error (type => 'not closed:caption', token => $token);
4206    
4207                ## As if </caption>                ## As if </caption>
4208                ## have a table element in table scope                ## have a table element in table scope
# Line 4201  sub _tree_construction_main ($) { Line 4222  sub _tree_construction_main ($) {
4222                } # INSCOPE                } # INSCOPE
4223                unless (defined $i) {                unless (defined $i) {
4224                  !!!cp ('t186');                  !!!cp ('t186');
4225                  !!!parse-error (type => 'unmatched end tag:caption');                  !!!parse-error (type => 'unmatched end tag:caption', token => $token);
4226                  ## Ignore the token                  ## Ignore the token
4227                  !!!next-token;                  !!!next-token;
4228                  redo B;                  redo B;
# Line 4217  sub _tree_construction_main ($) { Line 4238  sub _tree_construction_main ($) {
4238    
4239                if ($self->{open_elements}->[-1]->[1] ne 'caption') {                if ($self->{open_elements}->[-1]->[1] ne 'caption') {
4240                  !!!cp ('t188');                  !!!cp ('t188');
4241                  !!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]);                  !!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1], token => $token);
4242                } else {                } else {
4243                  !!!cp ('t189');                  !!!cp ('t189');
4244                }                }
# Line 4235  sub _tree_construction_main ($) { Line 4256  sub _tree_construction_main ($) {
4256                       }->{$token->{tag_name}}) {                       }->{$token->{tag_name}}) {
4257                if ($self->{insertion_mode} & BODY_TABLE_IMS) {                if ($self->{insertion_mode} & BODY_TABLE_IMS) {
4258                  !!!cp ('t190');                  !!!cp ('t190');
4259                  !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name});                  !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token);
4260                  ## Ignore the token                  ## Ignore the token
4261                  !!!next-token;                  !!!next-token;
4262                  redo B;                  redo B;
# Line 4249  sub _tree_construction_main ($) { Line 4270  sub _tree_construction_main ($) {
4270                       }->{$token->{tag_name}} and                       }->{$token->{tag_name}} and
4271                       $self->{insertion_mode} == IN_CAPTION_IM) {                       $self->{insertion_mode} == IN_CAPTION_IM) {
4272                !!!cp ('t192');                !!!cp ('t192');
4273                !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name});                !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token);
4274                ## Ignore the token                ## Ignore the token
4275                !!!next-token;                !!!next-token;
4276                redo B;                redo B;
# Line 4264  sub _tree_construction_main ($) { Line 4285  sub _tree_construction_main ($) {
4285              th => 1, thead => 1, tr => 1, body => 1, html => 1,              th => 1, thead => 1, tr => 1, body => 1, html => 1,
4286            }->{$entry->[1]}) {            }->{$entry->[1]}) {
4287              !!!cp ('t75');              !!!cp ('t75');
4288              !!!parse-error (type => 'in body:#eof');              !!!parse-error (type => 'in body:#eof', token => $token);
4289              last;              last;
4290            }            }
4291          }          }
# Line 4292  sub _tree_construction_main ($) { Line 4313  sub _tree_construction_main ($) {
4313            }            }
4314          }          }
4315    
4316              !!!parse-error (type => 'in table:#character');              !!!parse-error (type => 'in table:#character', token => $token);
4317    
4318              ## As if in body, but insert into foster parent element              ## As if in body, but insert into foster parent element
4319              ## ISSUE: Spec says that "whenever a node would be inserted              ## ISSUE: Spec says that "whenever a node would be inserted
# Line 4358  sub _tree_construction_main ($) { Line 4379  sub _tree_construction_main ($) {
4379                    pop @{$self->{open_elements}};                    pop @{$self->{open_elements}};
4380                  }                  }
4381                                    
4382                  !!!insert-element ('tbody');                  !!!insert-element ('tbody',, $token);
4383                  $self->{insertion_mode} = IN_TABLE_BODY_IM;                  $self->{insertion_mode} = IN_TABLE_BODY_IM;
4384                  ## reprocess in the "in table body" insertion mode...                  ## reprocess in the "in table body" insertion mode...
4385                }                }
# Line 4366  sub _tree_construction_main ($) { Line 4387  sub _tree_construction_main ($) {
4387                if ($self->{insertion_mode} == IN_TABLE_BODY_IM) {                if ($self->{insertion_mode} == IN_TABLE_BODY_IM) {
4388                  unless ($token->{tag_name} eq 'tr') {                  unless ($token->{tag_name} eq 'tr') {
4389                    !!!cp ('t202');                    !!!cp ('t202');
4390                    !!!parse-error (type => 'missing start tag:tr');                    !!!parse-error (type => 'missing start tag:tr', token => $token);
4391                  }                  }
4392                                    
4393                  ## Clear back to table body context                  ## Clear back to table body context
# Line 4381  sub _tree_construction_main ($) { Line 4402  sub _tree_construction_main ($) {
4402                  $self->{insertion_mode} = IN_ROW_IM;                  $self->{insertion_mode} = IN_ROW_IM;
4403                  if ($token->{tag_name} eq 'tr') {                  if ($token->{tag_name} eq 'tr') {
4404                    !!!cp ('t204');                    !!!cp ('t204');
4405                    !!!insert-element ($token->{tag_name}, $token->{attributes});                    !!!insert-element ($token->{tag_name}, $token->{attributes}, $token);
4406                    !!!next-token;                    !!!next-token;
4407                    redo B;                    redo B;
4408                  } else {                  } else {
4409                    !!!cp ('t205');                    !!!cp ('t205');
4410                    !!!insert-element ('tr');                    !!!insert-element ('tr',, $token);
4411                    ## reprocess in the "in row" insertion mode                    ## reprocess in the "in row" insertion mode
4412                  }                  }
4413                } else {                } else {
# Line 4401  sub _tree_construction_main ($) { Line 4422  sub _tree_construction_main ($) {
4422                  pop @{$self->{open_elements}};                  pop @{$self->{open_elements}};
4423                }                }
4424                                
4425                !!!insert-element ($token->{tag_name}, $token->{attributes});                !!!insert-element ($token->{tag_name}, $token->{attributes}, $token);
4426                $self->{insertion_mode} = IN_CELL_IM;                $self->{insertion_mode} = IN_CELL_IM;
4427    
4428                push @$active_formatting_elements, ['#marker', ''];                push @$active_formatting_elements, ['#marker', ''];
# Line 4436  sub _tree_construction_main ($) { Line 4457  sub _tree_construction_main ($) {
4457                  unless (defined $i) {                  unless (defined $i) {
4458                   !!!cp ('t210');                   !!!cp ('t210');
4459  ## TODO: This type is wrong.  ## TODO: This type is wrong.
4460                   !!!parse-error (type => 'unmacthed end tag:'.$token->{tag_name});                   !!!parse-error (type => 'unmacthed end tag:'.$token->{tag_name}, token => $token);
4461                    ## Ignore the token                    ## Ignore the token
4462                    !!!next-token;                    !!!next-token;
4463                    redo B;                    redo B;
# Line 4484  sub _tree_construction_main ($) { Line 4505  sub _tree_construction_main ($) {
4505                  unless (defined $i) {                  unless (defined $i) {
4506                    !!!cp ('t216');                    !!!cp ('t216');
4507  ## TODO: This erorr type ios wrong.  ## TODO: This erorr type ios wrong.
4508                    !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name});                    !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token);
4509                    ## Ignore the token                    ## Ignore the token
4510                    !!!next-token;                    !!!next-token;
4511                    redo B;                    redo B;
# Line 4522  sub _tree_construction_main ($) { Line 4543  sub _tree_construction_main ($) {
4543                    pop @{$self->{open_elements}};                    pop @{$self->{open_elements}};
4544                  }                  }
4545                                    
4546                  !!!insert-element ('colgroup');                  !!!insert-element ('colgroup',, $token);
4547                  $self->{insertion_mode} = IN_COLUMN_GROUP_IM;                  $self->{insertion_mode} = IN_COLUMN_GROUP_IM;
4548                  ## reprocess                  ## reprocess
4549                  redo B;                  redo B;
# Line 4542  sub _tree_construction_main ($) { Line 4563  sub _tree_construction_main ($) {
4563                  push @$active_formatting_elements, ['#marker', '']                  push @$active_formatting_elements, ['#marker', '']
4564                      if $token->{tag_name} eq 'caption';                      if $token->{tag_name} eq 'caption';
4565                                    
4566                  !!!insert-element ($token->{tag_name}, $token->{attributes});                  !!!insert-element ($token->{tag_name}, $token->{attributes}, $token);
4567                  $self->{insertion_mode} = {                  $self->{insertion_mode} = {
4568                                             caption => IN_CAPTION_IM,                                             caption => IN_CAPTION_IM,
4569                                             colgroup => IN_COLUMN_GROUP_IM,                                             colgroup => IN_COLUMN_GROUP_IM,
# Line 4556  sub _tree_construction_main ($) { Line 4577  sub _tree_construction_main ($) {
4577                  die "$0: in table: <>: $token->{tag_name}";                  die "$0: in table: <>: $token->{tag_name}";
4578                }                }
4579              } elsif ($token->{tag_name} eq 'table') {              } elsif ($token->{tag_name} eq 'table') {
4580                !!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]);                !!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1], token => $token);
4581    
4582                ## As if </table>                ## As if </table>
4583                ## have a table element in table scope                ## have a table element in table scope
# Line 4578  sub _tree_construction_main ($) { Line 4599  sub _tree_construction_main ($) {
4599                unless (defined $i) {                unless (defined $i) {
4600                  !!!cp ('t223');                  !!!cp ('t223');
4601  ## TODO: The following is wrong, maybe.  ## TODO: The following is wrong, maybe.
4602                  !!!parse-error (type => 'unmatched end tag:table');                  !!!parse-error (type => 'unmatched end tag:table', token => $token);
4603                  ## Ignore tokens </table><table>                  ## Ignore tokens </table><table>
4604                  !!!next-token;                  !!!next-token;
4605                  redo B;                  redo B;
# Line 4596  sub _tree_construction_main ($) { Line 4617  sub _tree_construction_main ($) {
4617                if ($self->{open_elements}->[-1]->[1] ne 'table') {                if ($self->{open_elements}->[-1]->[1] ne 'table') {
4618                  !!!cp ('t225');                  !!!cp ('t225');
4619  ## ISSUE: Can this case be reached?  ## ISSUE: Can this case be reached?
4620                  !!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]);                  !!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1], token => $token);
4621                } else {                } else {
4622                  !!!cp ('t226');                  !!!cp ('t226');
4623                }                }
# Line 4634  sub _tree_construction_main ($) { Line 4655  sub _tree_construction_main ($) {
4655                my $type = lc $token->{attributes}->{type}->{value};                my $type = lc $token->{attributes}->{type}->{value};
4656                if ($type eq 'hidden') {                if ($type eq 'hidden') {
4657                  !!!cp ('t227.3');                  !!!cp ('t227.3');
4658                  !!!parse-error (type => 'in table:'.$token->{tag_name});                  !!!parse-error (type => 'in table:'.$token->{tag_name}, token => $token);
4659    
4660                  !!!insert-element ($token->{tag_name}, $token->{attributes});                  !!!insert-element ($token->{tag_name}, $token->{attributes}, $token);
4661    
4662                  ## TODO: form element pointer                  ## TODO: form element pointer
4663    
# Line 4661  sub _tree_construction_main ($) { Line 4682  sub _tree_construction_main ($) {
4682            #            #
4683          }          }
4684    
4685          !!!parse-error (type => 'in table:'.$token->{tag_name});          !!!parse-error (type => 'in table:'.$token->{tag_name}, token => $token);
4686    
4687          $insert = $insert_to_foster;          $insert = $insert_to_foster;
4688          #          #
# Line 4685  sub _tree_construction_main ($) { Line 4706  sub _tree_construction_main ($) {
4706                } # INSCOPE                } # INSCOPE
4707                unless (defined $i) {                unless (defined $i) {
4708                  !!!cp ('t230');                  !!!cp ('t230');
4709                  !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name});                  !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token);
4710                  ## Ignore the token                  ## Ignore the token
4711                  !!!next-token;                  !!!next-token;
4712                  redo B;                  redo B;
# Line 4727  sub _tree_construction_main ($) { Line 4748  sub _tree_construction_main ($) {
4748                  unless (defined $i) {                  unless (defined $i) {
4749                    !!!cp ('t235');                    !!!cp ('t235');
4750  ## TODO: The following is wrong.  ## TODO: The following is wrong.
4751                    !!!parse-error (type => 'unmatched end tag:'.$token->{type});                    !!!parse-error (type => 'unmatched end tag:'.$token->{type}, token => $token);
4752                    ## Ignore the token                    ## Ignore the token
4753                    !!!next-token;                    !!!next-token;
4754                    redo B;                    redo B;
# Line 4767  sub _tree_construction_main ($) { Line 4788  sub _tree_construction_main ($) {
4788                  } # INSCOPE                  } # INSCOPE
4789                  unless (defined $i) {                  unless (defined $i) {
4790                    !!!cp ('t239');                    !!!cp ('t239');
4791                    !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name});                    !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token);
4792                    ## Ignore the token                    ## Ignore the token
4793                    !!!next-token;                    !!!next-token;
4794                    redo B;                    redo B;
# Line 4815  sub _tree_construction_main ($) { Line 4836  sub _tree_construction_main ($) {
4836                } # INSCOPE                } # INSCOPE
4837                unless (defined $i) {                unless (defined $i) {
4838                  !!!cp ('t243');                  !!!cp ('t243');
4839                  !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name});                  !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token);
4840                  ## Ignore the token                  ## Ignore the token
4841                  !!!next-token;                  !!!next-token;
4842                  redo B;                  redo B;
# Line 4850  sub _tree_construction_main ($) { Line 4871  sub _tree_construction_main ($) {
4871                  } # INSCOPE                  } # INSCOPE
4872                    unless (defined $i) {                    unless (defined $i) {
4873                      !!!cp ('t249');                      !!!cp ('t249');
4874                      !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name});                      !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token);
4875                      ## Ignore the token                      ## Ignore the token
4876                      !!!next-token;                      !!!next-token;
4877                      redo B;                      redo B;
# Line 4874  sub _tree_construction_main ($) { Line 4895  sub _tree_construction_main ($) {
4895                  } # INSCOPE                  } # INSCOPE
4896                    unless (defined $i) {                    unless (defined $i) {
4897                      !!!cp ('t252');                      !!!cp ('t252');
4898                      !!!parse-error (type => 'unmatched end tag:tr');                      !!!parse-error (type => 'unmatched end tag:tr', token => $token);
4899                      ## Ignore the token                      ## Ignore the token
4900                      !!!next-token;                      !!!next-token;
4901                      redo B;                      redo B;
# Line 4911  sub _tree_construction_main ($) { Line 4932  sub _tree_construction_main ($) {
4932                } # INSCOPE                } # INSCOPE
4933                unless (defined $i) {                unless (defined $i) {
4934                  !!!cp ('t256');                  !!!cp ('t256');
4935                  !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name});                  !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token);
4936                  ## Ignore the token                  ## Ignore the token
4937                  !!!next-token;                  !!!next-token;
4938                  redo B;                  redo B;
# Line 4937  sub _tree_construction_main ($) { Line 4958  sub _tree_construction_main ($) {
4958                        tbody => 1, tfoot => 1, thead => 1, # $self->{insertion_mode} == IN_TABLE_IM                        tbody => 1, tfoot => 1, thead => 1, # $self->{insertion_mode} == IN_TABLE_IM
4959                       }->{$token->{tag_name}}) {                       }->{$token->{tag_name}}) {
4960                !!!cp ('t258');                !!!cp ('t258');
4961                !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name});                !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token);
4962                ## Ignore the token                ## Ignore the token
4963                !!!next-token;                !!!next-token;
4964                redo B;                redo B;
4965          } else {          } else {
4966            !!!cp ('t259');            !!!cp ('t259');
4967            !!!parse-error (type => 'in table:/'.$token->{tag_name});            !!!parse-error (type => 'in table:/'.$token->{tag_name}, token => $token);
4968    
4969            $insert = $insert_to_foster;            $insert = $insert_to_foster;
4970            #            #
# Line 4951  sub _tree_construction_main ($) { Line 4972  sub _tree_construction_main ($) {
4972        } elsif ($token->{type} == END_OF_FILE_TOKEN) {        } elsif ($token->{type} == END_OF_FILE_TOKEN) {
4973          unless ($self->{open_elements}->[-1]->[1] eq 'html' and          unless ($self->{open_elements}->[-1]->[1] eq 'html' and
4974                  @{$self->{open_elements}} == 1) { # redundant, maybe                  @{$self->{open_elements}} == 1) { # redundant, maybe
4975            !!!parse-error (type => 'in body:#eof');            !!!parse-error (type => 'in body:#eof', token => $token);
4976            !!!cp ('t259.1');            !!!cp ('t259.1');
4977            #            #
4978          } else {          } else {
# Line 4980  sub _tree_construction_main ($) { Line 5001  sub _tree_construction_main ($) {
5001            } elsif ($token->{type} == START_TAG_TOKEN) {            } elsif ($token->{type} == START_TAG_TOKEN) {
5002              if ($token->{tag_name} eq 'col') {              if ($token->{tag_name} eq 'col') {
5003                !!!cp ('t262');                !!!cp ('t262');
5004                !!!insert-element ($token->{tag_name}, $token->{attributes});                !!!insert-element ($token->{tag_name}, $token->{attributes}, $token);
5005                pop @{$self->{open_elements}};                pop @{$self->{open_elements}};
5006                !!!next-token;                !!!next-token;
5007                redo B;                redo B;
# Line 4992  sub _tree_construction_main ($) { Line 5013  sub _tree_construction_main ($) {
5013              if ($token->{tag_name} eq 'colgroup') {              if ($token->{tag_name} eq 'colgroup') {
5014                if ($self->{open_elements}->[-1]->[1] eq 'html') {                if ($self->{open_elements}->[-1]->[1] eq 'html') {
5015                  !!!cp ('t264');                  !!!cp ('t264');
5016                  !!!parse-error (type => 'unmatched end tag:colgroup');                  !!!parse-error (type => 'unmatched end tag:colgroup', token => $token);
5017                  ## Ignore the token                  ## Ignore the token
5018                  !!!next-token;                  !!!next-token;
5019                  redo B;                  redo B;
# Line 5005  sub _tree_construction_main ($) { Line 5026  sub _tree_construction_main ($) {
5026                }                }
5027              } elsif ($token->{tag_name} eq 'col') {              } elsif ($token->{tag_name} eq 'col') {
5028                !!!cp ('t266');                !!!cp ('t266');
5029                !!!parse-error (type => 'unmatched end tag:col');                !!!parse-error (type => 'unmatched end tag:col', token => $token);
5030                ## Ignore the token                ## Ignore the token
5031                !!!next-token;                !!!next-token;
5032                redo B;                redo B;
# Line 5035  sub _tree_construction_main ($) { Line 5056  sub _tree_construction_main ($) {
5056            if ($self->{open_elements}->[-1]->[1] eq 'html') {            if ($self->{open_elements}->[-1]->[1] eq 'html') {
5057              !!!cp ('t269');              !!!cp ('t269');
5058  ## TODO: Wrong error type?  ## TODO: Wrong error type?
5059              !!!parse-error (type => 'unmatched end tag:colgroup');              !!!parse-error (type => 'unmatched end tag:colgroup', token => $token);
5060              ## Ignore the token              ## Ignore the token
5061              !!!next-token;              !!!next-token;
5062              redo B;              redo B;
# Line 5062  sub _tree_construction_main ($) { Line 5083  sub _tree_construction_main ($) {
5083                  !!!cp ('t273');                  !!!cp ('t273');
5084                }                }
5085    
5086                !!!insert-element ($token->{tag_name}, $token->{attributes});                !!!insert-element ($token->{tag_name}, $token->{attributes}, $token);
5087                !!!next-token;                !!!next-token;
5088                redo B;                redo B;
5089              } elsif ($token->{tag_name} eq 'optgroup') {              } elsif ($token->{tag_name} eq 'optgroup') {
# Line 5082  sub _tree_construction_main ($) { Line 5103  sub _tree_construction_main ($) {
5103                  !!!cp ('t277');                  !!!cp ('t277');
5104                }                }
5105    
5106                !!!insert-element ($token->{tag_name}, $token->{attributes});                !!!insert-element ($token->{tag_name}, $token->{attributes}, $token);
5107                !!!next-token;                !!!next-token;
5108                redo B;                redo B;
5109          } elsif ($token->{tag_name} eq 'select' or          } elsif ($token->{tag_name} eq 'select' or
# Line 5094  sub _tree_construction_main ($) { Line 5115  sub _tree_construction_main ($) {
5115                     tr => 1, td => 1, th => 1,                     tr => 1, td => 1, th => 1,
5116                    }->{$token->{tag_name}})) {                    }->{$token->{tag_name}})) {
5117            ## TODO: The type below is not good - <select> is replaced by </select>            ## TODO: The type below is not good - <select> is replaced by </select>
5118            !!!parse-error (type => 'not closed:select');            !!!parse-error (type => 'not closed:select', token => $token);
5119            ## NOTE: As if the token were </select> (<select> case) or            ## NOTE: As if the token were </select> (<select> case) or
5120            ## as if there were </select> (otherwise).            ## as if there were </select> (otherwise).
5121                ## have an element in table scope                ## have an element in table scope
# Line 5114  sub _tree_construction_main ($) { Line 5135  sub _tree_construction_main ($) {
5135                } # INSCOPE                } # INSCOPE
5136                unless (defined $i) {                unless (defined $i) {
5137                  !!!cp ('t280');                  !!!cp ('t280');
5138                  !!!parse-error (type => 'unmatched end tag:select');                  !!!parse-error (type => 'unmatched end tag:select', token => $token);
5139                  ## Ignore the token                  ## Ignore the token
5140                  !!!next-token;                  !!!next-token;
5141                  redo B;                  redo B;
# Line 5136  sub _tree_construction_main ($) { Line 5157  sub _tree_construction_main ($) {
5157            }            }
5158          } else {          } else {
5159            !!!cp ('t282');            !!!cp ('t282');
5160            !!!parse-error (type => 'in select:'.$token->{tag_name});            !!!parse-error (type => 'in select:'.$token->{tag_name}, token => $token);
5161            ## Ignore the token            ## Ignore the token
5162            !!!next-token;            !!!next-token;
5163            redo B;            redo B;
# Line 5153  sub _tree_construction_main ($) { Line 5174  sub _tree_construction_main ($) {
5174                  pop @{$self->{open_elements}};                  pop @{$self->{open_elements}};
5175                } else {                } else {
5176                  !!!cp ('t285');                  !!!cp ('t285');
5177                  !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name});                  !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token);
5178                  ## Ignore the token                  ## Ignore the token
5179                }                }
5180                !!!next-token;                !!!next-token;
# Line 5164  sub _tree_construction_main ($) { Line 5185  sub _tree_construction_main ($) {
5185                  pop @{$self->{open_elements}};                  pop @{$self->{open_elements}};
5186                } else {                } else {
5187                  !!!cp ('t287');                  !!!cp ('t287');
5188                  !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name});                  !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token);
5189                  ## Ignore the token                  ## Ignore the token
5190                }                }
5191                !!!next-token;                !!!next-token;
# Line 5187  sub _tree_construction_main ($) { Line 5208  sub _tree_construction_main ($) {
5208                } # INSCOPE                } # INSCOPE
5209                unless (defined $i) {                unless (defined $i) {
5210                  !!!cp ('t290');                  !!!cp ('t290');
5211                  !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name});                  !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token);
5212                  ## Ignore the token                  ## Ignore the token
5213                  !!!next-token;                  !!!next-token;
5214                  redo B;                  redo B;
# Line 5206  sub _tree_construction_main ($) { Line 5227  sub _tree_construction_main ($) {
5227                    tfoot => 1, thead => 1, tr => 1, td => 1, th => 1,                    tfoot => 1, thead => 1, tr => 1, td => 1, th => 1,
5228                   }->{$token->{tag_name}}) {                   }->{$token->{tag_name}}) {
5229  ## TODO: The following is wrong?  ## TODO: The following is wrong?
5230                !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name});                !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token);
5231                                
5232                ## have an element in table scope                ## have an element in table scope
5233                my $i;                my $i;
# Line 5250  sub _tree_construction_main ($) { Line 5271  sub _tree_construction_main ($) {
5271                unless (defined $i) {                unless (defined $i) {
5272                  !!!cp ('t297');                  !!!cp ('t297');
5273  ## TODO: The following error type is correct?  ## TODO: The following error type is correct?
5274                  !!!parse-error (type => 'unmatched end tag:select');                  !!!parse-error (type => 'unmatched end tag:select', token => $token);
5275                  ## Ignore the </select> token                  ## Ignore the </select> token
5276                  !!!next-token; ## TODO: ok?                  !!!next-token; ## TODO: ok?
5277                  redo B;                  redo B;
# Line 5265  sub _tree_construction_main ($) { Line 5286  sub _tree_construction_main ($) {
5286                redo B;                redo B;
5287          } else {          } else {
5288            !!!cp ('t299');            !!!cp ('t299');
5289            !!!parse-error (type => 'in select:/'.$token->{tag_name});            !!!parse-error (type => 'in select:/'.$token->{tag_name}, token => $token);
5290            ## Ignore the token            ## Ignore the token
5291            !!!next-token;            !!!next-token;
5292            redo B;            redo B;
# Line 5274  sub _tree_construction_main ($) { Line 5295  sub _tree_construction_main ($) {
5295          unless ($self->{open_elements}->[-1]->[1] eq 'html' and          unless ($self->{open_elements}->[-1]->[1] eq 'html' and
5296                  @{$self->{open_elements}} == 1) { # redundant, maybe                  @{$self->{open_elements}} == 1) { # redundant, maybe
5297            !!!cp ('t299.1');            !!!cp ('t299.1');
5298            !!!parse-error (type => 'in body:#eof');            !!!parse-error (type => 'in body:#eof', token => $token);
5299          } else {          } else {
5300            !!!cp ('t299.2');            !!!cp ('t299.2');
5301          }          }
# Line 5302  sub _tree_construction_main ($) { Line 5323  sub _tree_construction_main ($) {
5323                    
5324          if ($self->{insertion_mode} == AFTER_HTML_BODY_IM) {          if ($self->{insertion_mode} == AFTER_HTML_BODY_IM) {
5325            !!!cp ('t301');            !!!cp ('t301');
5326            !!!parse-error (type => 'after html:#character');            !!!parse-error (type => 'after html:#character', token => $token);
5327    
5328            ## Reprocess in the "after body" insertion mode.            ## Reprocess in the "after body" insertion mode.
5329          } else {          } else {
# Line 5310  sub _tree_construction_main ($) { Line 5331  sub _tree_construction_main ($) {
5331          }          }
5332                    
5333          ## "after body" insertion mode          ## "after body" insertion mode
5334          !!!parse-error (type => 'after body:#character');          !!!parse-error (type => 'after body:#character', token => $token);
5335    
5336          $self->{insertion_mode} = IN_BODY_IM;          $self->{insertion_mode} = IN_BODY_IM;
5337          ## reprocess          ## reprocess
# Line 5318  sub _tree_construction_main ($) { Line 5339  sub _tree_construction_main ($) {
5339        } elsif ($token->{type} == START_TAG_TOKEN) {        } elsif ($token->{type} == START_TAG_TOKEN) {
5340          if ($self->{insertion_mode} == AFTER_HTML_BODY_IM) {          if ($self->{insertion_mode} == AFTER_HTML_BODY_IM) {
5341            !!!cp ('t303');            !!!cp ('t303');
5342            !!!parse-error (type => 'after html:'.$token->{tag_name});            !!!parse-error (type => 'after html:'.$token->{tag_name}, token => $token);
5343                        
5344            ## Reprocess in the "after body" insertion mode.            ## Reprocess in the "after body" insertion mode.
5345          } else {          } else {
# Line 5326  sub _tree_construction_main ($) { Line 5347  sub _tree_construction_main ($) {
5347          }          }
5348    
5349          ## "after body" insertion mode          ## "after body" insertion mode
5350          !!!parse-error (type => 'after body:'.$token->{tag_name});          !!!parse-error (type => 'after body:'.$token->{tag_name}, token => $token);
5351    
5352          $self->{insertion_mode} = IN_BODY_IM;          $self->{insertion_mode} = IN_BODY_IM;
5353          ## reprocess          ## reprocess
# Line 5334  sub _tree_construction_main ($) { Line 5355  sub _tree_construction_main ($) {
5355        } elsif ($token->{type} == END_TAG_TOKEN) {        } elsif ($token->{type} == END_TAG_TOKEN) {
5356          if ($self->{insertion_mode} == AFTER_HTML_BODY_IM) {          if ($self->{insertion_mode} == AFTER_HTML_BODY_IM) {
5357            !!!cp ('t305');            !!!cp ('t305');
5358            !!!parse-error (type => 'after html:/'.$token->{tag_name});            !!!parse-error (type => 'after html:/'.$token->{tag_name}, token => $token);
5359                        
5360            $self->{insertion_mode} = AFTER_BODY_IM;            $self->{insertion_mode} = AFTER_BODY_IM;
5361            ## Reprocess in the "after body" insertion mode.            ## Reprocess in the "after body" insertion mode.
# Line 5346  sub _tree_construction_main ($) { Line 5367  sub _tree_construction_main ($) {
5367          if ($token->{tag_name} eq 'html') {          if ($token->{tag_name} eq 'html') {
5368            if (defined $self->{inner_html_node}) {            if (defined $self->{inner_html_node}) {
5369              !!!cp ('t307');              !!!cp ('t307');
5370              !!!parse-error (type => 'unmatched end tag:html');              !!!parse-error (type => 'unmatched end tag:html', token => $token);
5371              ## Ignore the token              ## Ignore the token
5372              !!!next-token;              !!!next-token;
5373              redo B;              redo B;
# Line 5358  sub _tree_construction_main ($) { Line 5379  sub _tree_construction_main ($) {
5379            }            }
5380          } else {          } else {
5381            !!!cp ('t309');            !!!cp ('t309');
5382            !!!parse-error (type => 'after body:/'.$token->{tag_name});            !!!parse-error (type => 'after body:/'.$token->{tag_name}, token => $token);
5383    
5384            $self->{insertion_mode} = IN_BODY_IM;            $self->{insertion_mode} = IN_BODY_IM;
5385            ## reprocess            ## reprocess
# Line 5386  sub _tree_construction_main ($) { Line 5407  sub _tree_construction_main ($) {
5407          if ($token->{data} =~ s/^[^\x09\x0A\x0B\x0C\x20]+//) {          if ($token->{data} =~ s/^[^\x09\x0A\x0B\x0C\x20]+//) {
5408            if ($self->{insertion_mode} == IN_FRAMESET_IM) {            if ($self->{insertion_mode} == IN_FRAMESET_IM) {
5409              !!!cp ('t311');              !!!cp ('t311');
5410              !!!parse-error (type => 'in frameset:#character');              !!!parse-error (type => 'in frameset:#character', token => $token);
5411            } elsif ($self->{insertion_mode} == AFTER_FRAMESET_IM) {            } elsif ($self->{insertion_mode} == AFTER_FRAMESET_IM) {
5412              !!!cp ('t312');              !!!cp ('t312');
5413              !!!parse-error (type => 'after frameset:#character');              !!!parse-error (type => 'after frameset:#character', token => $token);
5414            } else { # "after html frameset"            } else { # "after html frameset"
5415              !!!cp ('t313');              !!!cp ('t313');
5416              !!!parse-error (type => 'after html:#character');              !!!parse-error (type => 'after html:#character', token => $token);
5417    
5418              $self->{insertion_mode} = AFTER_FRAMESET_IM;              $self->{insertion_mode} = AFTER_FRAMESET_IM;
5419              ## Reprocess in the "after frameset" insertion mode.              ## Reprocess in the "after frameset" insertion mode.
5420              !!!parse-error (type => 'after frameset:#character');              !!!parse-error (type => 'after frameset:#character', token => $token);
5421            }            }
5422                        
5423            ## Ignore the token.            ## Ignore the token.
# Line 5414  sub _tree_construction_main ($) { Line 5435  sub _tree_construction_main ($) {
5435        } elsif ($token->{type} == START_TAG_TOKEN) {        } elsif ($token->{type} == START_TAG_TOKEN) {
5436          if ($self->{insertion_mode} == AFTER_HTML_FRAMESET_IM) {          if ($self->{insertion_mode} == AFTER_HTML_FRAMESET_IM) {
5437            !!!cp ('t316');            !!!cp ('t316');
5438            !!!parse-error (type => 'after html:'.$token->{tag_name});            !!!parse-error (type => 'after html:'.$token->{tag_name}, token => $token);
5439    
5440            $self->{insertion_mode} = AFTER_FRAMESET_IM;            $self->{insertion_mode} = AFTER_FRAMESET_IM;
5441            ## Process in the "after frameset" insertion mode.            ## Process in the "after frameset" insertion mode.
# Line 5425  sub _tree_construction_main ($) { Line 5446  sub _tree_construction_main ($) {
5446          if ($token->{tag_name} eq 'frameset' and          if ($token->{tag_name} eq 'frameset' and
5447              $self->{insertion_mode} == IN_FRAMESET_IM) {              $self->{insertion_mode} == IN_FRAMESET_IM) {
5448            !!!cp ('t318');            !!!cp ('t318');
5449            !!!insert-element ($token->{tag_name}, $token->{attributes});            !!!insert-element ($token->{tag_name}, $token->{attributes}, $token);
5450            !!!next-token;            !!!next-token;
5451            redo B;            redo B;
5452          } elsif ($token->{tag_name} eq 'frame' and          } elsif ($token->{tag_name} eq 'frame' and
5453                   $self->{insertion_mode} == IN_FRAMESET_IM) {                   $self->{insertion_mode} == IN_FRAMESET_IM) {
5454            !!!cp ('t319');            !!!cp ('t319');
5455            !!!insert-element ($token->{tag_name}, $token->{attributes});            !!!insert-element ($token->{tag_name}, $token->{attributes}, $token);
5456            pop @{$self->{open_elements}};            pop @{$self->{open_elements}};
5457            !!!next-token;            !!!next-token;
5458            redo B;            redo B;
# Line 5443  sub _tree_construction_main ($) { Line 5464  sub _tree_construction_main ($) {
5464          } else {          } else {
5465            if ($self->{insertion_mode} == IN_FRAMESET_IM) {            if ($self->{insertion_mode} == IN_FRAMESET_IM) {
5466              !!!cp ('t321');              !!!cp ('t321');
5467              !!!parse-error (type => 'in frameset:'.$token->{tag_name});              !!!parse-error (type => 'in frameset:'.$token->{tag_name}, token => $token);
5468            } else {            } else {
5469              !!!cp ('t322');              !!!cp ('t322');
5470              !!!parse-error (type => 'after frameset:'.$token->{tag_name});              !!!parse-error (type => 'after frameset:'.$token->{tag_name}, token => $token);
5471            }            }
5472            ## Ignore the token            ## Ignore the token
5473            !!!next-token;            !!!next-token;
# Line 5455  sub _tree_construction_main ($) { Line 5476  sub _tree_construction_main ($) {
5476        } elsif ($token->{type} == END_TAG_TOKEN) {        } elsif ($token->{type} == END_TAG_TOKEN) {
5477          if ($self->{insertion_mode} == AFTER_HTML_FRAMESET_IM) {          if ($self->{insertion_mode} == AFTER_HTML_FRAMESET_IM) {
5478            !!!cp ('t323');            !!!cp ('t323');
5479            !!!parse-error (type => 'after html:/'.$token->{tag_name});            !!!parse-error (type => 'after html:/'.$token->{tag_name}, token => $token);
5480    
5481            $self->{insertion_mode} = AFTER_FRAMESET_IM;            $self->{insertion_mode} = AFTER_FRAMESET_IM;
5482            ## Process in the "after frameset" insertion mode.            ## Process in the "after frameset" insertion mode.
# Line 5468  sub _tree_construction_main ($) { Line 5489  sub _tree_construction_main ($) {
5489            if ($self->{open_elements}->[-1]->[1] eq 'html' and            if ($self->{open_elements}->[-1]->[1] eq 'html' and
5490                @{$self->{open_elements}} == 1) {                @{$self->{open_elements}} == 1) {
5491              !!!cp ('t325');              !!!cp ('t325');
5492              !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name});              !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token);
5493              ## Ignore the token              ## Ignore the token
5494              !!!next-token;              !!!next-token;
5495            } else {            } else {
# Line 5494  sub _tree_construction_main ($) { Line 5515  sub _tree_construction_main ($) {
5515          } else {          } else {
5516            if ($self->{insertion_mode} == IN_FRAMESET_IM) {            if ($self->{insertion_mode} == IN_FRAMESET_IM) {
5517              !!!cp ('t330');              !!!cp ('t330');
5518              !!!parse-error (type => 'in frameset:/'.$token->{tag_name});              !!!parse-error (type => 'in frameset:/'.$token->{tag_name}, token => $token);
5519            } else {            } else {
5520              !!!cp ('t331');              !!!cp ('t331');
5521              !!!parse-error (type => 'after frameset:/'.$token->{tag_name});              !!!parse-error (type => 'after frameset:/'.$token->{tag_name}, token => $token);
5522            }            }
5523            ## Ignore the token            ## Ignore the token
5524            !!!next-token;            !!!next-token;
# Line 5507  sub _tree_construction_main ($) { Line 5528  sub _tree_construction_main ($) {
5528          unless ($self->{open_elements}->[-1]->[1] eq 'html' and          unless ($self->{open_elements}->[-1]->[1] eq 'html' and
5529                  @{$self->{open_elements}} == 1) { # redundant, maybe                  @{$self->{open_elements}} == 1) { # redundant, maybe
5530            !!!cp ('t331.1');            !!!cp ('t331.1');
5531            !!!parse-error (type => 'in body:#eof');            !!!parse-error (type => 'in body:#eof', token => $token);
5532          } else {          } else {
5533            !!!cp ('t331.2');            !!!cp ('t331.2');
5534          }          }
# Line 5540  sub _tree_construction_main ($) { Line 5561  sub _tree_construction_main ($) {
5561                 }->{$token->{tag_name}}) {                 }->{$token->{tag_name}}) {
5562          !!!cp ('t334');          !!!cp ('t334');
5563          ## NOTE: This is an "as if in head" code clone, only "-t" differs          ## NOTE: This is an "as if in head" code clone, only "-t" differs
5564          !!!insert-element-t ($token->{tag_name}, $token->{attributes});          !!!insert-element-t ($token->{tag_name}, $token->{attributes}, $token);
5565          pop @{$self->{open_elements}}; ## ISSUE: This step is missing in the spec.          pop @{$self->{open_elements}}; ## ISSUE: This step is missing in the spec.
5566          !!!next-token;          !!!next-token;
5567          redo B;          redo B;
5568        } elsif ($token->{tag_name} eq 'meta') {        } elsif ($token->{tag_name} eq 'meta') {
5569          ## NOTE: This is an "as if in head" code clone, only "-t" differs          ## NOTE: This is an "as if in head" code clone, only "-t" differs
5570          !!!insert-element-t ($token->{tag_name}, $token->{attributes});          !!!insert-element-t ($token->{tag_name}, $token->{attributes}, $token);
5571          my $meta_el = pop @{$self->{open_elements}}; ## ISSUE: This step is missing in the spec.          my $meta_el = pop @{$self->{open_elements}}; ## ISSUE: This step is missing in the spec.
5572    
5573          unless ($self->{confident}) {          unless ($self->{confident}) {
5574            if ($token->{attributes}->{charset}) { ## TODO: And if supported            if ($token->{attributes}->{charset}) { ## TODO: And if supported
5575              !!!cp ('t335');              !!!cp ('t335');
5576              $self->{change_encoding}              $self->{change_encoding}
5577                  ->($self, $token->{attributes}->{charset}->{value});                  ->($self, $token->{attributes}->{charset}->{value}, $token);
5578                            
5579              $meta_el->[0]->get_attribute_node_ns (undef, 'charset')              $meta_el->[0]->get_attribute_node_ns (undef, 'charset')
5580                  ->set_user_data (manakai_has_reference =>                  ->set_user_data (manakai_has_reference =>
# Line 5568  sub _tree_construction_main ($) { Line 5589  sub _tree_construction_main ($) {
5589                      ([^"'\x09-\x0D\x20][^\x09-\x0D\x20]*))/x) {                      ([^"'\x09-\x0D\x20][^\x09-\x0D\x20]*))/x) {
5590                !!!cp ('t336');                !!!cp ('t336');
5591                $self->{change_encoding}                $self->{change_encoding}
5592                    ->($self, defined $1 ? $1 : defined $2 ? $2 : $3);                    ->($self, defined $1 ? $1 : defined $2 ? $2 : $3, $token);
5593                $meta_el->[0]->get_attribute_node_ns (undef, 'content')                $meta_el->[0]->get_attribute_node_ns (undef, 'content')
5594                    ->set_user_data (manakai_has_reference =>                    ->set_user_data (manakai_has_reference =>
5595                                         $token->{attributes}->{content}                                         $token->{attributes}->{content}
# Line 5600  sub _tree_construction_main ($) { Line 5621  sub _tree_construction_main ($) {
5621          $parse_rcdata->(RCDATA_CONTENT_MODEL);          $parse_rcdata->(RCDATA_CONTENT_MODEL);
5622          redo B;          redo B;
5623        } elsif ($token->{tag_name} eq 'body') {        } elsif ($token->{tag_name} eq 'body') {
5624          !!!parse-error (type => 'in body:body');          !!!parse-error (type => 'in body:body', token => $token);
5625                                
5626          if (@{$self->{open_elements}} == 1 or          if (@{$self->{open_elements}} == 1 or
5627              $self->{open_elements}->[1]->[1] ne 'body') {              $self->{open_elements}->[1]->[1] ne 'body') {
# Line 5631  sub _tree_construction_main ($) { Line 5652  sub _tree_construction_main ($) {
5652                 }->{$token->{tag_name}}) {                 }->{$token->{tag_name}}) {
5653          if ($token->{tag_name} eq 'form' and defined $self->{form_element}) {          if ($token->{tag_name} eq 'form' and defined $self->{form_element}) {
5654            !!!cp ('t350');            !!!cp ('t350');
5655            !!!parse-error (type => 'in form:form');            !!!parse-error (type => 'in form:form', token => $token);
5656            ## Ignore the token            ## Ignore the token
5657            !!!next-token;            !!!next-token;
5658            redo B;            redo B;
# Line 5642  sub _tree_construction_main ($) { Line 5663  sub _tree_construction_main ($) {
5663            if ($_->[1] eq 'p') {            if ($_->[1] eq 'p') {
5664              !!!cp ('t344');              !!!cp ('t344');
5665              !!!back-token;              !!!back-token;
5666              $token = {type => END_TAG_TOKEN, tag_name => 'p'};              $token = {type => END_TAG_TOKEN, tag_name => 'p',
5667                          line => $token->{line}, column => $token->{column}};
5668              redo B;              redo B;
5669            } elsif ({            } elsif ({
5670                      applet => 1, table => 1, caption => 1, td => 1, th => 1,                      applet => 1, table => 1, caption => 1, td => 1, th => 1,
# Line 5653  sub _tree_construction_main ($) { Line 5675  sub _tree_construction_main ($) {
5675            }            }
5676          } # INSCOPE          } # INSCOPE
5677                        
5678          !!!insert-element-t ($token->{tag_name}, $token->{attributes});          !!!insert-element-t ($token->{tag_name}, $token->{attributes}, $token);
5679          if ($token->{tag_name} eq 'pre' or $token->{tag_name} eq 'listing') {          if ($token->{tag_name} eq 'pre' or $token->{tag_name} eq 'listing') {
5680            !!!next-token;            !!!next-token;
5681            if ($token->{type} == CHARACTER_TOKEN) {            if ($token->{type} == CHARACTER_TOKEN) {
# Line 5695  sub _tree_construction_main ($) { Line 5717  sub _tree_construction_main ($) {
5717            if ($_->[1] eq 'p') {            if ($_->[1] eq 'p') {
5718              !!!cp ('t353');              !!!cp ('t353');
5719              !!!back-token;              !!!back-token;
5720              $token = {type => END_TAG_TOKEN, tag_name => 'p'};              $token = {type => END_TAG_TOKEN, tag_name => 'p',
5721                          line => $token->{line}, column => $token->{column}};
5722              redo B;              redo B;
5723            } elsif ({            } elsif ({
5724                      applet => 1, table => 1, caption => 1, td => 1, th => 1,                      applet => 1, table => 1, caption => 1, td => 1, th => 1,
# Line 5718  sub _tree_construction_main ($) { Line 5741  sub _tree_construction_main ($) {
5741              if ($i != -1) {              if ($i != -1) {
5742                !!!cp ('t355');                !!!cp ('t355');
5743                !!!parse-error (type => 'end tag missing:'.                !!!parse-error (type => 'end tag missing:'.
5744                                $self->{open_elements}->[-1]->[1]);                                $self->{open_elements}->[-1]->[1], token => $token);
5745              } else {              } else {
5746                !!!cp ('t356');                !!!cp ('t356');
5747              }              }
# Line 5745  sub _tree_construction_main ($) { Line 5768  sub _tree_construction_main ($) {
5768            redo LI;            redo LI;
5769          } # LI          } # LI
5770                        
5771          !!!insert-element-t ($token->{tag_name}, $token->{attributes});          !!!insert-element-t ($token->{tag_name}, $token->{attributes}, $token);
5772          !!!next-token;          !!!next-token;
5773          redo B;          redo B;
5774        } elsif ($token->{tag_name} eq 'plaintext') {        } elsif ($token->{tag_name} eq 'plaintext') {
# Line 5754  sub _tree_construction_main ($) { Line 5777  sub _tree_construction_main ($) {
5777            if ($_->[1] eq 'p') {            if ($_->[1] eq 'p') {
5778              !!!cp ('t367');              !!!cp ('t367');
5779              !!!back-token;              !!!back-token;
5780              $token = {type => END_TAG_TOKEN, tag_name => 'p'};              $token = {type => END_TAG_TOKEN, tag_name => 'p',
5781                          line => $token->{line}, column => $token->{column}};
5782              redo B;              redo B;
5783            } elsif ({            } elsif ({
5784                      applet => 1, table => 1, caption => 1, td => 1, th => 1,                      applet => 1, table => 1, caption => 1, td => 1, th => 1,
# Line 5765  sub _tree_construction_main ($) { Line 5789  sub _tree_construction_main ($) {
5789            }            }
5790          } # INSCOPE          } # INSCOPE
5791                        
5792          !!!insert-element-t ($token->{tag_name}, $token->{attributes});          !!!insert-element-t ($token->{tag_name}, $token->{attributes}, $token);
5793                        
5794          $self->{content_model} = PLAINTEXT_CONTENT_MODEL;          $self->{content_model} = PLAINTEXT_CONTENT_MODEL;
5795                        
# Line 5776  sub _tree_construction_main ($) { Line 5800  sub _tree_construction_main ($) {
5800            my $node = $active_formatting_elements->[$i];            my $node = $active_formatting_elements->[$i];
5801            if ($node->[1] eq 'a') {            if ($node->[1] eq 'a') {
5802              !!!cp ('t371');              !!!cp ('t371');
5803              !!!parse-error (type => 'in a:a');              !!!parse-error (type => 'in a:a', token => $token);
5804                            
5805              !!!back-token;              !!!back-token;
5806              $token = {type => END_TAG_TOKEN, tag_name => 'a'};              $token = {type => END_TAG_TOKEN, tag_name => 'a',
5807              $formatting_end_tag->($token->{tag_name});                        line => $token->{line}, column => $token->{column}};
5808                $formatting_end_tag->($token);
5809                            
5810              AFE2: for (reverse 0..$#$active_formatting_elements) {              AFE2: for (reverse 0..$#$active_formatting_elements) {
5811                if ($active_formatting_elements->[$_]->[0] eq $node->[0]) {                if ($active_formatting_elements->[$_]->[0] eq $node->[0]) {
# Line 5805  sub _tree_construction_main ($) { Line 5830  sub _tree_construction_main ($) {
5830                        
5831          $reconstruct_active_formatting_elements->($insert_to_current);          $reconstruct_active_formatting_elements->($insert_to_current);
5832    
5833          !!!insert-element-t ($token->{tag_name}, $token->{attributes});          !!!insert-element-t ($token->{tag_name}, $token->{attributes}, $token);
5834          push @$active_formatting_elements, $self->{open_elements}->[-1];          push @$active_formatting_elements, $self->{open_elements}->[-1];
5835    
5836          !!!next-token;          !!!next-token;
# Line 5818  sub _tree_construction_main ($) { Line 5843  sub _tree_construction_main ($) {
5843            my $node = $self->{open_elements}->[$_];            my $node = $self->{open_elements}->[$_];
5844            if ($node->[1] eq 'nobr') {            if ($node->[1] eq 'nobr') {
5845              !!!cp ('t376');              !!!cp ('t376');
5846              !!!parse-error (type => 'in nobr:nobr');              !!!parse-error (type => 'in nobr:nobr', token => $token);
5847              !!!back-token;              !!!back-token;
5848              $token = {type => END_TAG_TOKEN, tag_name => 'nobr'};              $token = {type => END_TAG_TOKEN, tag_name => 'nobr',
5849                          line => $token->{line}, column => $token->{column}};
5850              redo B;              redo B;
5851            } elsif ({            } elsif ({
5852                      applet => 1, table => 1, caption => 1, td => 1, th => 1,                      applet => 1, table => 1, caption => 1, td => 1, th => 1,
# Line 5831  sub _tree_construction_main ($) { Line 5857  sub _tree_construction_main ($) {
5857            }            }
5858          } # INSCOPE          } # INSCOPE
5859                    
5860          !!!insert-element-t ($token->{tag_name}, $token->{attributes});          !!!insert-element-t ($token->{tag_name}, $token->{attributes}, $token);
5861          push @$active_formatting_elements, $self->{open_elements}->[-1];          push @$active_formatting_elements, $self->{open_elements}->[-1];
5862                    
5863          !!!next-token;          !!!next-token;
# Line 5842  sub _tree_construction_main ($) { Line 5868  sub _tree_construction_main ($) {
5868            my $node = $self->{open_elements}->[$_];            my $node = $self->{open_elements}->[$_];
5869            if ($node->[1] eq 'button') {            if ($node->[1] eq 'button') {
5870              !!!cp ('t378');              !!!cp ('t378');
5871              !!!parse-error (type => 'in button:button');              !!!parse-error (type => 'in button:button', token => $token);
5872              !!!back-token;              !!!back-token;
5873              $token = {type => END_TAG_TOKEN, tag_name => 'button'};              $token = {type => END_TAG_TOKEN, tag_name => 'button',
5874                          line => $token->{line}, column => $token->{column}};
5875              redo B;              redo B;
5876            } elsif ({            } elsif ({
5877                      applet => 1, table => 1, caption => 1, td => 1, th => 1,                      applet => 1, table => 1, caption => 1, td => 1, th => 1,
# Line 5857  sub _tree_construction_main ($) { Line 5884  sub _tree_construction_main ($) {
5884                        
5885          $reconstruct_active_formatting_elements->($insert_to_current);          $reconstruct_active_formatting_elements->($insert_to_current);
5886                        
5887          !!!insert-element-t ($token->{tag_name}, $token->{attributes});          !!!insert-element-t ($token->{tag_name}, $token->{attributes}, $token);
5888    
5889          ## TODO: associate with $self->{form_element} if defined          ## TODO: associate with $self->{form_element} if defined
5890    
# Line 5882  sub _tree_construction_main ($) { Line 5909  sub _tree_construction_main ($) {
5909          $parse_rcdata->(CDATA_CONTENT_MODEL);          $parse_rcdata->(CDATA_CONTENT_MODEL);
5910          redo B;          redo B;
5911        } elsif ($token->{tag_name} eq 'isindex') {        } elsif ($token->{tag_name} eq 'isindex') {
5912          !!!parse-error (type => 'isindex');          !!!parse-error (type => 'isindex', token => $token);
5913                    
5914          if (defined $self->{form_element}) {          if (defined $self->{form_element}) {
5915            !!!cp ('t389');            !!!cp ('t389');
# Line 5899  sub _tree_construction_main ($) { Line 5926  sub _tree_construction_main ($) {
5926            delete $at->{prompt};            delete $at->{prompt};
5927            my @tokens = (            my @tokens = (
5928                          {type => START_TAG_TOKEN, tag_name => 'form',                          {type => START_TAG_TOKEN, tag_name => 'form',
5929                           attributes => $form_attrs},                           attributes => $form_attrs,
5930                          {type => START_TAG_TOKEN, tag_name => 'hr'},                           line => $token->{line}, column => $token->{column}},
5931                          {type => START_TAG_TOKEN, tag_name => 'p'},                          {type => START_TAG_TOKEN, tag_name => 'hr',
5932                          {type => START_TAG_TOKEN, tag_name => 'label'},                           line => $token->{line}, column => $token->{column}},
5933                            {type => START_TAG_TOKEN, tag_name => 'p',
5934                             line => $token->{line}, column => $token->{column}},
5935                            {type => START_TAG_TOKEN, tag_name => 'label',
5936                             line => $token->{line}, column => $token->{column}},
5937                         );                         );
5938            if ($prompt_attr) {            if ($prompt_attr) {
5939              !!!cp ('t390');              !!!cp ('t390');
5940              push @tokens, {type => CHARACTER_TOKEN, data => $prompt_attr->{value}};              push @tokens, {type => CHARACTER_TOKEN, data => $prompt_attr->{value},
5941                               line => $token->{line}, column => $token->{column}};
5942            } else {            } else {
5943              !!!cp ('t391');              !!!cp ('t391');
5944              push @tokens, {type => CHARACTER_TOKEN,              push @tokens, {type => CHARACTER_TOKEN,
5945                             data => 'This is a searchable index. Insert your search keywords here: '}; # SHOULD                             data => 'This is a searchable index. Insert your search keywords here: ',
5946                               line => $token->{line}, column => $token->{column}}; # SHOULD
5947              ## TODO: make this configurable              ## TODO: make this configurable
5948            }            }
5949            push @tokens,            push @tokens,
5950                          {type => START_TAG_TOKEN, tag_name => 'input', attributes => $at},                          {type => START_TAG_TOKEN, tag_name => 'input', attributes => $at,
5951                             line => $token->{line}, column => $token->{column}},
5952                          #{type => CHARACTER_TOKEN, data => ''}, # SHOULD                          #{type => CHARACTER_TOKEN, data => ''}, # SHOULD
5953                          {type => END_TAG_TOKEN, tag_name => 'label'},                          {type => END_TAG_TOKEN, tag_name => 'label',
5954                          {type => END_TAG_TOKEN, tag_name => 'p'},                           line => $token->{line}, column => $token->{column}},
5955                          {type => START_TAG_TOKEN, tag_name => 'hr'},                          {type => END_TAG_TOKEN, tag_name => 'p',
5956                          {type => END_TAG_TOKEN, tag_name => 'form'};                           line => $token->{line}, column => $token->{column}},
5957                            {type => START_TAG_TOKEN, tag_name => 'hr',
5958                             line => $token->{line}, column => $token->{column}},
5959                            {type => END_TAG_TOKEN, tag_name => 'form',
5960                             line => $token->{line}, column => $token->{column}};
5961            $token = shift @tokens;            $token = shift @tokens;
5962            !!!back-token (@tokens);            !!!back-token (@tokens);
5963            redo B;            redo B;
# Line 5927  sub _tree_construction_main ($) { Line 5965  sub _tree_construction_main ($) {
5965        } elsif ($token->{tag_name} eq 'textarea') {        } elsif ($token->{tag_name} eq 'textarea') {
5966          my $tag_name = $token->{tag_name};          my $tag_name = $token->{tag_name};
5967          my $el;          my $el;
5968          !!!create-element ($el, $token->{tag_name}, $token->{attributes});          !!!create-element ($el, $token->{tag_name}, $token->{attributes}, $token);
5969                    
5970          ## TODO: $self->{form_element} if defined          ## TODO: $self->{form_element} if defined
5971          $self->{content_model} = RCDATA_CONTENT_MODEL;          $self->{content_model} = RCDATA_CONTENT_MODEL;
# Line 5966  sub _tree_construction_main ($) { Line 6004  sub _tree_construction_main ($) {
6004            ## Ignore the token            ## Ignore the token
6005          } else {          } else {
6006            !!!cp ('t398');            !!!cp ('t398');
6007            !!!parse-error (type => 'in RCDATA:#'.$token->{type});            !!!parse-error (type => 'in RCDATA:#'.$token->{type}, token => $token);
6008          }          }
6009          !!!next-token;          !!!next-token;
6010          redo B;          redo B;
# Line 5977  sub _tree_construction_main ($) { Line 6015  sub _tree_construction_main ($) {
6015                  thead => 1, tr => 1,                  thead => 1, tr => 1,
6016                 }->{$token->{tag_name}}) {                 }->{$token->{tag_name}}) {
6017          !!!cp ('t401');          !!!cp ('t401');
6018          !!!parse-error (type => 'in body:'.$token->{tag_name});          !!!parse-error (type => 'in body:'.$token->{tag_name}, token => $token);
6019          ## Ignore the token          ## Ignore the token
6020          !!!next-token;          !!!next-token;
6021          redo B;          redo B;
# Line 5986  sub _tree_construction_main ($) { Line 6024  sub _tree_construction_main ($) {
6024        } else {        } else {
6025          if ($token->{tag_name} eq 'image') {          if ($token->{tag_name} eq 'image') {
6026            !!!cp ('t384');            !!!cp ('t384');
6027            !!!parse-error (type => 'image');            !!!parse-error (type => 'image', token => $token);
6028            $token->{tag_name} = 'img';            $token->{tag_name} = 'img';
6029          } else {          } else {
6030            !!!cp ('t385');            !!!cp ('t385');
# Line 5995  sub _tree_construction_main ($) { Line 6033  sub _tree_construction_main ($) {
6033          ## NOTE: There is an "as if <br>" code clone.          ## NOTE: There is an "as if <br>" code clone.
6034          $reconstruct_active_formatting_elements->($insert_to_current);          $reconstruct_active_formatting_elements->($insert_to_current);
6035                    
6036          !!!insert-element-t ($token->{tag_name}, $token->{attributes});          !!!insert-element-t ($token->{tag_name}, $token->{attributes}, $token);
6037    
6038          if ({          if ({
6039               applet => 1, marquee => 1, object => 1,               applet => 1, marquee => 1, object => 1,
# Line 6059  sub _tree_construction_main ($) { Line 6097  sub _tree_construction_main ($) {
6097            }            }
6098    
6099            !!!parse-error (type => 'start tag not allowed',            !!!parse-error (type => 'start tag not allowed',
6100                            value => $token->{tag_name});                            value => $token->{tag_name}, token => $token);
6101            ## NOTE: Ignore the token.            ## NOTE: Ignore the token.
6102            !!!next-token;            !!!next-token;
6103            redo B;            redo B;
# Line 6072  sub _tree_construction_main ($) { Line 6110  sub _tree_construction_main ($) {
6110                     tbody => 1, tfoot => 1, thead => 1,                     tbody => 1, tfoot => 1, thead => 1,
6111                    }->{$_->[1]}) {                    }->{$_->[1]}) {
6112              !!!cp ('t403');              !!!cp ('t403');
6113              !!!parse-error (type => 'not closed:'.$_->[1]);              !!!parse-error (type => 'not closed:'.$_->[1], token => $token);
6114              last;              last;
6115            } else {            } else {
6116              !!!cp ('t404');              !!!cp ('t404');
# Line 6087  sub _tree_construction_main ($) { Line 6125  sub _tree_construction_main ($) {
6125            ## ISSUE: There is an issue in the spec.            ## ISSUE: There is an issue in the spec.
6126            if ($self->{open_elements}->[-1]->[1] ne 'body') {            if ($self->{open_elements}->[-1]->[1] ne 'body') {
6127              !!!cp ('t406');              !!!cp ('t406');
6128              !!!parse-error (type => 'not closed:'.$self->{open_elements}->[1]->[1]);              !!!parse-error (type => 'not closed:'.$self->{open_elements}->[1]->[1], token => $token);
6129            } else {            } else {
6130              !!!cp ('t407');              !!!cp ('t407');
6131            }            }
# Line 6096  sub _tree_construction_main ($) { Line 6134  sub _tree_construction_main ($) {
6134            redo B;            redo B;
6135          } else {          } else {
6136            !!!cp ('t408');            !!!cp ('t408');
6137            !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name});            !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token);
6138            ## Ignore the token            ## Ignore the token
6139            !!!next-token;            !!!next-token;
6140            redo B;            redo B;
# Line 6127  sub _tree_construction_main ($) { Line 6165  sub _tree_construction_main ($) {
6165    
6166          unless (defined $i) { # has an element in scope          unless (defined $i) { # has an element in scope
6167            !!!cp ('t413');            !!!cp ('t413');
6168            !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name});            !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token);
6169          } else {          } else {
6170            ## Step 1. generate implied end tags            ## Step 1. generate implied end tags
6171            while ({            while ({
# Line 6143  sub _tree_construction_main ($) { Line 6181  sub _tree_construction_main ($) {
6181            ## Step 2.            ## Step 2.
6182            if ($self->{open_elements}->[-1]->[1] ne $token->{tag_name}) {            if ($self->{open_elements}->[-1]->[1] ne $token->{tag_name}) {
6183              !!!cp ('t412');              !!!cp ('t412');
6184              !!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]);              !!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1], token => $token);
6185            } else {            } else {
6186              !!!cp ('t414');              !!!cp ('t414');
6187            }            }
# Line 6181  sub _tree_construction_main ($) { Line 6219  sub _tree_construction_main ($) {
6219    
6220          unless (defined $i) { # has an element in scope          unless (defined $i) { # has an element in scope
6221            !!!cp ('t421');            !!!cp ('t421');
6222            !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name});            !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token);
6223          } else {          } else {
6224            ## Step 1. generate implied end tags            ## Step 1. generate implied end tags
6225            while ({            while ({
# Line 6194  sub _tree_construction_main ($) { Line 6232  sub _tree_construction_main ($) {
6232            ## Step 2.            ## Step 2.
6233            if ($self->{open_elements}->[-1]->[1] ne $token->{tag_name}) {            if ($self->{open_elements}->[-1]->[1] ne $token->{tag_name}) {
6234              !!!cp ('t417.1');              !!!cp ('t417.1');
6235              !!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]);              !!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1], token => $token);
6236            } else {            } else {
6237              !!!cp ('t420');              !!!cp ('t420');
6238            }              }  
# Line 6229  sub _tree_construction_main ($) { Line 6267  sub _tree_construction_main ($) {
6267    
6268          unless (defined $i) { # has an element in scope          unless (defined $i) { # has an element in scope
6269            !!!cp ('t425.1');            !!!cp ('t425.1');
6270            !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name});            !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token);
6271          } else {          } else {
6272            ## Step 1. generate implied end tags            ## Step 1. generate implied end tags
6273            while ({            while ({
# Line 6242  sub _tree_construction_main ($) { Line 6280  sub _tree_construction_main ($) {
6280            ## Step 2.            ## Step 2.
6281            if ($self->{open_elements}->[-1]->[1] ne $token->{tag_name}) {            if ($self->{open_elements}->[-1]->[1] ne $token->{tag_name}) {
6282              !!!cp ('t425');              !!!cp ('t425');
6283              !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name});              !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token);
6284            } else {            } else {
6285              !!!cp ('t426');              !!!cp ('t426');
6286            }            }
# Line 6274  sub _tree_construction_main ($) { Line 6312  sub _tree_construction_main ($) {
6312          if (defined $i) {          if (defined $i) {
6313            if ($self->{open_elements}->[-1]->[1] ne $token->{tag_name}) {            if ($self->{open_elements}->[-1]->[1] ne $token->{tag_name}) {
6314              !!!cp ('t412.1');              !!!cp ('t412.1');
6315              !!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]);              !!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1], token => $token);
6316            } else {            } else {
6317              !!!cp ('t414.1');              !!!cp ('t414.1');
6318            }            }
# Line 6282  sub _tree_construction_main ($) { Line 6320  sub _tree_construction_main ($) {
6320            splice @{$self->{open_elements}}, $i;            splice @{$self->{open_elements}}, $i;
6321          } else {          } else {
6322            !!!cp ('t413.1');            !!!cp ('t413.1');
6323            !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name});            !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token);
6324    
6325            !!!cp ('t415.1');            !!!cp ('t415.1');
6326            ## As if <p>, then reprocess the current token            ## As if <p>, then reprocess the current token
6327            my $el;            my $el;
6328            !!!create-element ($el, 'p');            !!!create-element ($el, 'p',, $token);
6329            $insert->($el);            $insert->($el);
6330            ## NOTE: Not inserted into |$self->{open_elements}|.            ## NOTE: Not inserted into |$self->{open_elements}|.
6331          }          }
# Line 6301  sub _tree_construction_main ($) { Line 6339  sub _tree_construction_main ($) {
6339                  strong => 1, tt => 1, u => 1,                  strong => 1, tt => 1, u => 1,
6340                 }->{$token->{tag_name}}) {                 }->{$token->{tag_name}}) {
6341          !!!cp ('t427');          !!!cp ('t427');
6342          $formatting_end_tag->($token->{tag_name});          $formatting_end_tag->($token);
6343          redo B;          redo B;
6344        } elsif ($token->{tag_name} eq 'br') {        } elsif ($token->{tag_name} eq 'br') {
6345          !!!cp ('t428');          !!!cp ('t428');
6346          !!!parse-error (type => 'unmatched end tag:br');          !!!parse-error (type => 'unmatched end tag:br', token => $token);
6347    
6348          ## As if <br>          ## As if <br>
6349          $reconstruct_active_formatting_elements->($insert_to_current);          $reconstruct_active_formatting_elements->($insert_to_current);
6350                    
6351          my $el;          my $el;
6352          !!!create-element ($el, 'br');          !!!create-element ($el, 'br',, $token);
6353          $insert->($el);          $insert->($el);
6354                    
6355          ## Ignore the token.          ## Ignore the token.
# Line 6330  sub _tree_construction_main ($) { Line 6368  sub _tree_construction_main ($) {
6368                  noscript => 0, ## TODO: if scripting is enabled                  noscript => 0, ## TODO: if scripting is enabled
6369                 }->{$token->{tag_name}}) {                 }->{$token->{tag_name}}) {
6370          !!!cp ('t429');          !!!cp ('t429');
6371          !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name});          !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token);
6372          ## Ignore the token          ## Ignore the token
6373          !!!next-token;          !!!next-token;
6374          redo B;          redo B;
# Line 6359  sub _tree_construction_main ($) { Line 6397  sub _tree_construction_main ($) {
6397              if ($token->{tag_name} ne $self->{open_elements}->[-1]->[1]) {              if ($token->{tag_name} ne $self->{open_elements}->[-1]->[1]) {
6398                !!!cp ('t431');                !!!cp ('t431');
6399                ## NOTE: <x><y></x>                ## NOTE: <x><y></x>
6400                !!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]);                !!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1], token => $token);
6401              } else {              } else {
6402                !!!cp ('t432');                !!!cp ('t432');
6403              }              }
# Line 6376  sub _tree_construction_main ($) { Line 6414  sub _tree_construction_main ($) {
6414                  ($special_category->{$node->[1]} or                  ($special_category->{$node->[1]} or
6415                   $scoping_category->{$node->[1]})) {                   $scoping_category->{$node->[1]})) {
6416                !!!cp ('t433');                !!!cp ('t433');
6417                !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name});                !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token);
6418                ## Ignore the token                ## Ignore the token
6419                !!!next-token;                !!!next-token;
6420                last S2;                last S2;

Legend:
Removed from v.1.112  
changed lines
  Added in v.1.116

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24