3886 |
}->{$token->{tag_name}}) { |
}->{$token->{tag_name}}) { |
3887 |
if ($self->{insertion_mode} == IN_CELL_IM) { |
if ($self->{insertion_mode} == IN_CELL_IM) { |
3888 |
## have an element in table scope |
## have an element in table scope |
3889 |
my $tn; |
for (reverse 0..$#{$self->{open_elements}}) { |
|
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
|
3890 |
my $node = $self->{open_elements}->[$_]; |
my $node = $self->{open_elements}->[$_]; |
3891 |
if ($node->[1] eq 'td' or $node->[1] eq 'th') { |
if ($node->[1] eq 'td' or $node->[1] eq 'th') { |
3892 |
!!!cp ('t151'); |
!!!cp ('t151'); |
3893 |
$tn = $node->[1]; |
|
3894 |
last INSCOPE; |
## Close the cell |
3895 |
|
!!!back-token; # <?> |
3896 |
|
$token = {type => END_TAG_TOKEN, tag_name => $node->[1]}; |
3897 |
|
redo B; |
3898 |
} elsif ({ |
} elsif ({ |
3899 |
table => 1, html => 1, |
table => 1, html => 1, |
3900 |
}->{$node->[1]}) { |
}->{$node->[1]}) { |
3901 |
!!!cp ('t152'); |
!!!cp ('t152'); |
3902 |
last INSCOPE; |
## ISSUE: This case can never be reached, maybe. |
3903 |
} |
last; |
|
} # INSCOPE |
|
|
unless (defined $tn) { |
|
|
!!!cp ('t153'); |
|
|
## TODO: This error type is wrong. |
|
|
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
|
|
## Ignore the token |
|
|
!!!next-token; |
|
|
redo B; |
|
3904 |
} |
} |
3905 |
|
} |
3906 |
!!!cp ('t154'); |
|
3907 |
## Close the cell |
!!!cp ('t153'); |
3908 |
!!!back-token; # <?> |
!!!parse-error (type => 'start tag not allowed', |
3909 |
$token = {type => END_TAG_TOKEN, tag_name => $tn}; |
value => $token->{tag_name}); |
3910 |
|
## Ignore the token |
3911 |
|
!!!next-token; |
3912 |
redo B; |
redo B; |
3913 |
} elsif ($self->{insertion_mode} == IN_CAPTION_IM) { |
} elsif ($self->{insertion_mode} == IN_CAPTION_IM) { |
3914 |
!!!parse-error (type => 'not closed:caption'); |
!!!parse-error (type => 'not closed:caption'); |
3915 |
|
|
3916 |
## As if </caption> |
## NOTE: As if </caption>. |
3917 |
## have a table element in table scope |
## have a table element in table scope |
3918 |
my $i; |
my $i; |
3919 |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
INSCOPE: { |
3920 |
my $node = $self->{open_elements}->[$_]; |
for (reverse 0..$#{$self->{open_elements}}) { |
3921 |
if ($node->[1] eq 'caption') { |
my $node = $self->{open_elements}->[$_]; |
3922 |
!!!cp ('t155'); |
if ($node->[1] eq 'caption') { |
3923 |
$i = $_; |
!!!cp ('t155'); |
3924 |
last INSCOPE; |
$i = $_; |
3925 |
} elsif ({ |
last INSCOPE; |
3926 |
table => 1, html => 1, |
} elsif ({ |
3927 |
}->{$node->[1]}) { |
table => 1, html => 1, |
3928 |
!!!cp ('t156'); |
}->{$node->[1]}) { |
3929 |
last INSCOPE; |
!!!cp ('t156'); |
3930 |
|
last; |
3931 |
|
} |
3932 |
} |
} |
3933 |
|
|
3934 |
|
!!!cp ('t157'); |
3935 |
|
!!!parse-error (type => 'start tag not allowed', |
3936 |
|
value => $token->{tag_name}); |
3937 |
|
## Ignore the token |
3938 |
|
!!!next-token; |
3939 |
|
redo B; |
3940 |
} # INSCOPE |
} # INSCOPE |
|
unless (defined $i) { |
|
|
!!!cp ('t157'); |
|
|
## TODO: this type is wrong. |
|
|
!!!parse-error (type => 'unmatched end tag:caption'); |
|
|
## Ignore the token |
|
|
!!!next-token; |
|
|
redo B; |
|
|
} |
|
3941 |
|
|
3942 |
## generate implied end tags |
## generate implied end tags |
3943 |
while ({ |
while ({ |
4033 |
if ($self->{insertion_mode} == IN_CAPTION_IM) { |
if ($self->{insertion_mode} == IN_CAPTION_IM) { |
4034 |
## have a table element in table scope |
## have a table element in table scope |
4035 |
my $i; |
my $i; |
4036 |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
INSCOPE: { |
4037 |
my $node = $self->{open_elements}->[$_]; |
for (reverse 0..$#{$self->{open_elements}}) { |
4038 |
if ($node->[1] eq $token->{tag_name}) { |
my $node = $self->{open_elements}->[$_]; |
4039 |
!!!cp ('t171'); |
if ($node->[1] eq $token->{tag_name}) { |
4040 |
$i = $_; |
!!!cp ('t171'); |
4041 |
last INSCOPE; |
$i = $_; |
4042 |
} elsif ({ |
last INSCOPE; |
4043 |
table => 1, html => 1, |
} elsif ({ |
4044 |
}->{$node->[1]}) { |
table => 1, html => 1, |
4045 |
!!!cp ('t172'); |
}->{$node->[1]}) { |
4046 |
last INSCOPE; |
!!!cp ('t172'); |
4047 |
|
last; |
4048 |
|
} |
4049 |
} |
} |
4050 |
|
|
4051 |
|
!!!cp ('t173'); |
4052 |
|
!!!parse-error (type => 'unmatched end tag', |
4053 |
|
value => $token->{tag_name}); |
4054 |
|
## Ignore the token |
4055 |
|
!!!next-token; |
4056 |
|
redo B; |
4057 |
} # INSCOPE |
} # INSCOPE |
|
unless (defined $i) { |
|
|
!!!cp ('t173'); |
|
|
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
|
|
## Ignore the token |
|
|
!!!next-token; |
|
|
redo B; |
|
|
} |
|
4058 |
|
|
4059 |
## generate implied end tags |
## generate implied end tags |
4060 |
while ({ |
while ({ |
4097 |
## have an element in table scope |
## have an element in table scope |
4098 |
my $i; |
my $i; |
4099 |
my $tn; |
my $tn; |
4100 |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
INSCOPE: { |
4101 |
my $node = $self->{open_elements}->[$_]; |
for (reverse 0..$#{$self->{open_elements}}) { |
4102 |
if ($node->[1] eq $token->{tag_name}) { |
my $node = $self->{open_elements}->[$_]; |
4103 |
!!!cp ('t179'); |
if ($node->[1] eq $token->{tag_name}) { |
4104 |
$i = $_; |
!!!cp ('t179'); |
4105 |
last INSCOPE; |
$i = $_; |
4106 |
} elsif ($node->[1] eq 'td' or $node->[1] eq 'th') { |
|
4107 |
!!!cp ('t180'); |
## Close the cell |
4108 |
$tn = $node->[1]; |
!!!back-token; # </?> |
4109 |
## NOTE: There is exactly one |td| or |th| element |
$token = {type => END_TAG_TOKEN, tag_name => $tn}; |
4110 |
## in scope in the stack of open elements by definition. |
redo B; |
4111 |
} elsif ({ |
} elsif ($node->[1] eq 'td' or $node->[1] eq 'th') { |
4112 |
table => 1, html => 1, |
!!!cp ('t180'); |
4113 |
}->{$node->[1]}) { |
$tn = $node->[1]; |
4114 |
!!!cp ('t181'); |
## NOTE: There is exactly one |td| or |th| element |
4115 |
last INSCOPE; |
## in scope in the stack of open elements by definition. |
4116 |
|
} elsif ({ |
4117 |
|
table => 1, html => 1, |
4118 |
|
}->{$node->[1]}) { |
4119 |
|
## ISSUE: Can this be reached? |
4120 |
|
!!!cp ('t181'); |
4121 |
|
last; |
4122 |
|
} |
4123 |
} |
} |
4124 |
} # INSCOPE |
|
|
unless (defined $i) { |
|
4125 |
!!!cp ('t182'); |
!!!cp ('t182'); |
4126 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
!!!parse-error (type => 'unmatched end tag', |
4127 |
|
value => $token->{tag_name}); |
4128 |
## Ignore the token |
## Ignore the token |
4129 |
!!!next-token; |
!!!next-token; |
4130 |
redo B; |
redo B; |
4131 |
} else { |
} # INSCOPE |
|
!!!cp ('t183'); |
|
|
} |
|
|
|
|
|
## Close the cell |
|
|
!!!back-token; # </?> |
|
|
$token = {type => END_TAG_TOKEN, tag_name => $tn}; |
|
|
redo B; |
|
4132 |
} elsif ($token->{tag_name} eq 'table' and |
} elsif ($token->{tag_name} eq 'table' and |
4133 |
$self->{insertion_mode} == IN_CAPTION_IM) { |
$self->{insertion_mode} == IN_CAPTION_IM) { |
4134 |
!!!parse-error (type => 'not closed:caption'); |
!!!parse-error (type => 'not closed:caption'); |