| 66 |
} |
} |
| 67 |
|
|
| 68 |
## NOTE: Used in "generate implied end tags" algorithm. |
## NOTE: Used in "generate implied end tags" algorithm. |
| 69 |
## NOTE: There is a code where a modified version of END_TAG_OPTIONAL_EL |
## NOTE: There is a code where a modified version of |
| 70 |
## is used in "generate implied end tags" implementation (search for the |
## END_TAG_OPTIONAL_EL is used in "generate implied end tags" |
| 71 |
## function mae). |
## implementation (search for the algorithm name). |
| 72 |
sub END_TAG_OPTIONAL_EL () { |
sub END_TAG_OPTIONAL_EL () { |
| 73 |
DD_EL | |
DD_EL | |
| 74 |
DT_EL | |
DT_EL | |
| 75 |
LI_EL | |
LI_EL | |
| 76 |
|
OPTION_EL | |
| 77 |
|
OPTGROUP_EL | |
| 78 |
P_EL | |
P_EL | |
| 79 |
RUBY_COMPONENT_EL |
RUBY_COMPONENT_EL |
| 80 |
} |
} |
| 143 |
address => ADDRESS_EL, |
address => ADDRESS_EL, |
| 144 |
applet => MISC_SCOPING_EL, |
applet => MISC_SCOPING_EL, |
| 145 |
area => MISC_SPECIAL_EL, |
area => MISC_SPECIAL_EL, |
| 146 |
|
article => MISC_SPECIAL_EL, |
| 147 |
|
aside => MISC_SPECIAL_EL, |
| 148 |
b => FORMATTING_EL, |
b => FORMATTING_EL, |
| 149 |
base => MISC_SPECIAL_EL, |
base => MISC_SPECIAL_EL, |
| 150 |
basefont => MISC_SPECIAL_EL, |
basefont => MISC_SPECIAL_EL, |
| 158 |
center => MISC_SPECIAL_EL, |
center => MISC_SPECIAL_EL, |
| 159 |
col => MISC_SPECIAL_EL, |
col => MISC_SPECIAL_EL, |
| 160 |
colgroup => MISC_SPECIAL_EL, |
colgroup => MISC_SPECIAL_EL, |
| 161 |
|
command => MISC_SPECIAL_EL, |
| 162 |
|
datagrid => MISC_SPECIAL_EL, |
| 163 |
dd => DD_EL, |
dd => DD_EL, |
| 164 |
|
details => MISC_SPECIAL_EL, |
| 165 |
|
dialog => MISC_SPECIAL_EL, |
| 166 |
dir => MISC_SPECIAL_EL, |
dir => MISC_SPECIAL_EL, |
| 167 |
div => DIV_EL, |
div => DIV_EL, |
| 168 |
dl => MISC_SPECIAL_EL, |
dl => MISC_SPECIAL_EL, |
| 169 |
dt => DT_EL, |
dt => DT_EL, |
| 170 |
em => FORMATTING_EL, |
em => FORMATTING_EL, |
| 171 |
embed => MISC_SPECIAL_EL, |
embed => MISC_SPECIAL_EL, |
| 172 |
|
eventsource => MISC_SPECIAL_EL, |
| 173 |
fieldset => MISC_SPECIAL_EL, |
fieldset => MISC_SPECIAL_EL, |
| 174 |
|
figure => MISC_SPECIAL_EL, |
| 175 |
font => FORMATTING_EL, |
font => FORMATTING_EL, |
| 176 |
|
footer => MISC_SPECIAL_EL, |
| 177 |
form => FORM_EL, |
form => FORM_EL, |
| 178 |
frame => MISC_SPECIAL_EL, |
frame => MISC_SPECIAL_EL, |
| 179 |
frameset => FRAMESET_EL, |
frameset => FRAMESET_EL, |
| 184 |
h5 => HEADING_EL, |
h5 => HEADING_EL, |
| 185 |
h6 => HEADING_EL, |
h6 => HEADING_EL, |
| 186 |
head => MISC_SPECIAL_EL, |
head => MISC_SPECIAL_EL, |
| 187 |
|
header => MISC_SPECIAL_EL, |
| 188 |
hr => MISC_SPECIAL_EL, |
hr => MISC_SPECIAL_EL, |
| 189 |
html => HTML_EL, |
html => HTML_EL, |
| 190 |
i => FORMATTING_EL, |
i => FORMATTING_EL, |
| 191 |
iframe => MISC_SPECIAL_EL, |
iframe => MISC_SPECIAL_EL, |
| 192 |
img => MISC_SPECIAL_EL, |
img => MISC_SPECIAL_EL, |
| 193 |
|
#image => MISC_SPECIAL_EL, ## NOTE: Commented out in the spec. |
| 194 |
input => MISC_SPECIAL_EL, |
input => MISC_SPECIAL_EL, |
| 195 |
isindex => MISC_SPECIAL_EL, |
isindex => MISC_SPECIAL_EL, |
| 196 |
li => LI_EL, |
li => LI_EL, |
| 199 |
marquee => MISC_SCOPING_EL, |
marquee => MISC_SCOPING_EL, |
| 200 |
menu => MISC_SPECIAL_EL, |
menu => MISC_SPECIAL_EL, |
| 201 |
meta => MISC_SPECIAL_EL, |
meta => MISC_SPECIAL_EL, |
| 202 |
|
nav => MISC_SPECIAL_EL, |
| 203 |
nobr => NOBR_EL | FORMATTING_EL, |
nobr => NOBR_EL | FORMATTING_EL, |
| 204 |
noembed => MISC_SPECIAL_EL, |
noembed => MISC_SPECIAL_EL, |
| 205 |
noframes => MISC_SPECIAL_EL, |
noframes => MISC_SPECIAL_EL, |
| 218 |
s => FORMATTING_EL, |
s => FORMATTING_EL, |
| 219 |
script => MISC_SPECIAL_EL, |
script => MISC_SPECIAL_EL, |
| 220 |
select => SELECT_EL, |
select => SELECT_EL, |
| 221 |
|
section => MISC_SPECIAL_EL, |
| 222 |
small => FORMATTING_EL, |
small => FORMATTING_EL, |
| 223 |
spacer => MISC_SPECIAL_EL, |
spacer => MISC_SPECIAL_EL, |
| 224 |
strike => FORMATTING_EL, |
strike => FORMATTING_EL, |
| 338 |
|
|
| 339 |
## ISSUE: xmlns:xlink="non-xlink-ns" is not an error. |
## ISSUE: xmlns:xlink="non-xlink-ns" is not an error. |
| 340 |
|
|
| 341 |
my $c1_entity_char = { |
my $charref_map = { |
| 342 |
|
0x0D => 0x000A, |
| 343 |
0x80 => 0x20AC, |
0x80 => 0x20AC, |
| 344 |
0x81 => 0xFFFD, |
0x81 => 0xFFFD, |
| 345 |
0x82 => 0x201A, |
0x82 => 0x201A, |
| 372 |
0x9D => 0xFFFD, |
0x9D => 0xFFFD, |
| 373 |
0x9E => 0x017E, |
0x9E => 0x017E, |
| 374 |
0x9F => 0x0178, |
0x9F => 0x0178, |
| 375 |
}; # $c1_entity_char |
}; # $charref_map |
| 376 |
|
$charref_map->{$_} = 0xFFFD |
| 377 |
|
for 0x0000..0x0008, 0x000B, 0x000E..0x001F, 0x007F, |
| 378 |
|
0xD800..0xDFFF, 0xFDD0..0xFDDF, ## ISSUE: 0xFDEF |
| 379 |
|
0xFFFE, 0xFFFF, 0x1FFFE, 0x1FFFF, 0x2FFFE, 0x2FFFF, 0x3FFFE, 0x3FFFF, |
| 380 |
|
0x4FFFE, 0x4FFFF, 0x5FFFE, 0x5FFFF, 0x6FFFE, 0x6FFFF, 0x7FFFE, |
| 381 |
|
0x7FFFF, 0x8FFFE, 0x8FFFF, 0x9FFFE, 0x9FFFF, 0xAFFFE, 0xAFFFF, |
| 382 |
|
0xBFFFE, 0xBFFFF, 0xCFFFE, 0xCFFFF, 0xDFFFE, 0xDFFFF, 0xEFFFE, |
| 383 |
|
0xEFFFF, 0xFFFFE, 0xFFFFF, 0x10FFFE, 0x10FFFF; |
| 384 |
|
|
| 385 |
|
## TODO: Invoke the reset algorithm when a resettable element is |
| 386 |
|
## created (cf. HTML5 revision 2259). |
| 387 |
|
|
| 388 |
sub parse_byte_string ($$$$;$) { |
sub parse_byte_string ($$$$;$) { |
| 389 |
my $self = shift; |
my $self = shift; |
| 3201 |
my $code = $self->{s_kwd}; |
my $code = $self->{s_kwd}; |
| 3202 |
my $l = $self->{line_prev}; |
my $l = $self->{line_prev}; |
| 3203 |
my $c = $self->{column_prev}; |
my $c = $self->{column_prev}; |
| 3204 |
if ($code == 0 or (0xD800 <= $code and $code <= 0xDFFF)) { |
if ($charref_map->{$code}) { |
| 3205 |
!!!cp (1015); |
!!!cp (1015); |
| 3206 |
!!!parse-error (type => 'invalid character reference', |
!!!parse-error (type => 'invalid character reference', |
| 3207 |
text => (sprintf 'U+%04X', $code), |
text => (sprintf 'U+%04X', $code), |
| 3208 |
line => $l, column => $c); |
line => $l, column => $c); |
| 3209 |
$code = 0xFFFD; |
$code = $charref_map->{$code}; |
| 3210 |
} elsif ($code > 0x10FFFF) { |
} elsif ($code > 0x10FFFF) { |
| 3211 |
!!!cp (1016); |
!!!cp (1016); |
| 3212 |
!!!parse-error (type => 'invalid character reference', |
!!!parse-error (type => 'invalid character reference', |
| 3213 |
text => (sprintf 'U-%08X', $code), |
text => (sprintf 'U-%08X', $code), |
| 3214 |
line => $l, column => $c); |
line => $l, column => $c); |
| 3215 |
$code = 0xFFFD; |
$code = 0xFFFD; |
|
} elsif ($code == 0x000D) { |
|
|
!!!cp (1017); |
|
|
!!!parse-error (type => 'CR character reference', |
|
|
line => $l, column => $c); |
|
|
$code = 0x000A; |
|
|
} elsif (0x80 <= $code and $code <= 0x9F) { |
|
|
!!!cp (1018); |
|
|
!!!parse-error (type => 'C1 character reference', |
|
|
text => (sprintf 'U+%04X', $code), |
|
|
line => $l, column => $c); |
|
|
$code = $c1_entity_char->{$code}; |
|
| 3216 |
} |
} |
| 3217 |
|
|
| 3218 |
if ($self->{prev_state} == DATA_STATE) { |
if ($self->{prev_state} == DATA_STATE) { |
| 3309 |
my $code = $self->{s_kwd}; |
my $code = $self->{s_kwd}; |
| 3310 |
my $l = $self->{line_prev}; |
my $l = $self->{line_prev}; |
| 3311 |
my $c = $self->{column_prev}; |
my $c = $self->{column_prev}; |
| 3312 |
if ($code == 0 or (0xD800 <= $code and $code <= 0xDFFF)) { |
if ($charref_map->{$code}) { |
| 3313 |
!!!cp (1008); |
!!!cp (1008); |
| 3314 |
!!!parse-error (type => 'invalid character reference', |
!!!parse-error (type => 'invalid character reference', |
| 3315 |
text => (sprintf 'U+%04X', $code), |
text => (sprintf 'U+%04X', $code), |
| 3316 |
line => $l, column => $c); |
line => $l, column => $c); |
| 3317 |
$code = 0xFFFD; |
$code = $charref_map->{$code}; |
| 3318 |
} elsif ($code > 0x10FFFF) { |
} elsif ($code > 0x10FFFF) { |
| 3319 |
!!!cp (1009); |
!!!cp (1009); |
| 3320 |
!!!parse-error (type => 'invalid character reference', |
!!!parse-error (type => 'invalid character reference', |
| 3321 |
text => (sprintf 'U-%08X', $code), |
text => (sprintf 'U-%08X', $code), |
| 3322 |
line => $l, column => $c); |
line => $l, column => $c); |
| 3323 |
$code = 0xFFFD; |
$code = 0xFFFD; |
|
} elsif ($code == 0x000D) { |
|
|
!!!cp (1010); |
|
|
!!!parse-error (type => 'CR character reference', line => $l, column => $c); |
|
|
$code = 0x000A; |
|
|
} elsif (0x80 <= $code and $code <= 0x9F) { |
|
|
!!!cp (1011); |
|
|
!!!parse-error (type => 'C1 character reference', text => (sprintf 'U+%04X', $code), line => $l, column => $c); |
|
|
$code = $c1_entity_char->{$code}; |
|
| 3324 |
} |
} |
| 3325 |
|
|
| 3326 |
if ($self->{prev_state} == DATA_STATE) { |
if ($self->{prev_state} == DATA_STATE) { |
| 4657 |
!!!cp ('t101'); |
!!!cp ('t101'); |
| 4658 |
} |
} |
| 4659 |
!!!insert-element ($token->{tag_name}, $token->{attributes}, $token); |
!!!insert-element ($token->{tag_name}, $token->{attributes}, $token); |
| 4660 |
pop @{$self->{open_elements}}; ## ISSUE: This step is missing in the spec. |
pop @{$self->{open_elements}}; |
| 4661 |
pop @{$self->{open_elements}} # <head> |
pop @{$self->{open_elements}} # <head> |
| 4662 |
if $self->{insertion_mode} == AFTER_HEAD_IM; |
if $self->{insertion_mode} == AFTER_HEAD_IM; |
| 4663 |
!!!nack ('t101.1'); |
!!!nack ('t101.1'); |
| 4664 |
!!!next-token; |
!!!next-token; |
| 4665 |
next B; |
next B; |
| 4666 |
} elsif ($token->{tag_name} eq 'link') { |
} elsif ($token->{tag_name} eq 'link') { |
| 4667 |
## NOTE: There is a "as if in head" code clone. |
## NOTE: There is a "as if in head" code clone. |
| 4668 |
if ($self->{insertion_mode} == AFTER_HEAD_IM) { |
if ($self->{insertion_mode} == AFTER_HEAD_IM) { |
| 4669 |
!!!cp ('t102'); |
!!!cp ('t102'); |
| 4670 |
!!!parse-error (type => 'after head', |
!!!parse-error (type => 'after head', |
| 4671 |
text => $token->{tag_name}, token => $token); |
text => $token->{tag_name}, token => $token); |
| 4672 |
push @{$self->{open_elements}}, |
push @{$self->{open_elements}}, |
| 4673 |
[$self->{head_element}, $el_category->{head}]; |
[$self->{head_element}, $el_category->{head}]; |
| 4674 |
} else { |
} else { |
| 4675 |
!!!cp ('t103'); |
!!!cp ('t103'); |
| 4676 |
} |
} |
| 4677 |
!!!insert-element ($token->{tag_name}, $token->{attributes}, $token); |
!!!insert-element ($token->{tag_name}, $token->{attributes}, $token); |
| 4678 |
pop @{$self->{open_elements}}; ## ISSUE: This step is missing in the spec. |
pop @{$self->{open_elements}}; |
| 4679 |
pop @{$self->{open_elements}} # <head> |
pop @{$self->{open_elements}} # <head> |
| 4680 |
if $self->{insertion_mode} == AFTER_HEAD_IM; |
if $self->{insertion_mode} == AFTER_HEAD_IM; |
| 4681 |
!!!ack ('t103.1'); |
!!!ack ('t103.1'); |
| 4682 |
!!!next-token; |
!!!next-token; |
| 4683 |
next B; |
next B; |
| 4684 |
|
} elsif ($token->{tag_name} eq 'command' or |
| 4685 |
|
$token->{tag_name} eq 'eventsource') { |
| 4686 |
|
if ($self->{insertion_mode} == IN_HEAD_IM) { |
| 4687 |
|
## NOTE: If the insertion mode at the time of the emission |
| 4688 |
|
## of the token was "before head", $self->{insertion_mode} |
| 4689 |
|
## is already changed to |IN_HEAD_IM|. |
| 4690 |
|
|
| 4691 |
|
## NOTE: There is a "as if in head" code clone. |
| 4692 |
|
!!!insert-element ($token->{tag_name}, $token->{attributes}, $token); |
| 4693 |
|
pop @{$self->{open_elements}}; |
| 4694 |
|
pop @{$self->{open_elements}} # <head> |
| 4695 |
|
if $self->{insertion_mode} == AFTER_HEAD_IM; |
| 4696 |
|
!!!ack ('t103.2'); |
| 4697 |
|
!!!next-token; |
| 4698 |
|
next B; |
| 4699 |
|
} else { |
| 4700 |
|
## NOTE: "in head noscript" or "after head" insertion mode |
| 4701 |
|
## - in these cases, these tags are treated as same as |
| 4702 |
|
## normal in-body tags. |
| 4703 |
|
!!!cp ('t103.3'); |
| 4704 |
|
# |
| 4705 |
|
} |
| 4706 |
} elsif ($token->{tag_name} eq 'meta') { |
} elsif ($token->{tag_name} eq 'meta') { |
| 4707 |
## NOTE: There is a "as if in head" code clone. |
## NOTE: There is a "as if in head" code clone. |
| 4708 |
if ($self->{insertion_mode} == AFTER_HEAD_IM) { |
if ($self->{insertion_mode} == AFTER_HEAD_IM) { |
| 6820 |
$parse_rcdata->(CDATA_CONTENT_MODEL); |
$parse_rcdata->(CDATA_CONTENT_MODEL); |
| 6821 |
next B; |
next B; |
| 6822 |
} elsif ({ |
} elsif ({ |
| 6823 |
base => 1, link => 1, |
base => 1, command => 1, eventsource => 1, link => 1, |
| 6824 |
}->{$token->{tag_name}}) { |
}->{$token->{tag_name}}) { |
| 6825 |
!!!cp ('t334'); |
!!!cp ('t334'); |
| 6826 |
## 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 |
| 6827 |
!!!insert-element-t ($token->{tag_name}, $token->{attributes}, $token); |
!!!insert-element-t ($token->{tag_name}, $token->{attributes}, $token); |
| 6828 |
pop @{$self->{open_elements}}; ## ISSUE: This step is missing in the spec. |
pop @{$self->{open_elements}}; |
| 6829 |
!!!ack ('t334.1'); |
!!!ack ('t334.1'); |
| 6830 |
!!!next-token; |
!!!next-token; |
| 6831 |
next B; |
next B; |
| 6832 |
} elsif ($token->{tag_name} eq 'meta') { |
} elsif ($token->{tag_name} eq 'meta') { |
| 6833 |
## 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 |
| 6834 |
!!!insert-element-t ($token->{tag_name}, $token->{attributes}, $token); |
!!!insert-element-t ($token->{tag_name}, $token->{attributes}, $token); |
| 6835 |
my $meta_el = pop @{$self->{open_elements}}; ## ISSUE: This step is missing in the spec. |
my $meta_el = pop @{$self->{open_elements}}; |
| 6836 |
|
|
| 6837 |
unless ($self->{confident}) { |
unless ($self->{confident}) { |
| 6838 |
if ($token->{attributes}->{charset}) { |
if ($token->{attributes}->{charset}) { |
| 6911 |
!!!next-token; |
!!!next-token; |
| 6912 |
next B; |
next B; |
| 6913 |
} elsif ({ |
} elsif ({ |
| 6914 |
address => 1, blockquote => 1, center => 1, dir => 1, |
## NOTE: Start tags for non-phrasing flow content elements |
| 6915 |
div => 1, dl => 1, fieldset => 1, |
|
| 6916 |
h1 => 1, h2 => 1, h3 => 1, h4 => 1, h5 => 1, h6 => 1, |
## NOTE: The normal one |
| 6917 |
menu => 1, ol => 1, p => 1, ul => 1, |
address => 1, article => 1, aside => 1, blockquote => 1, |
| 6918 |
|
center => 1, datagrid => 1, details => 1, dialog => 1, |
| 6919 |
|
dir => 1, div => 1, dl => 1, fieldset => 1, figure => 1, |
| 6920 |
|
footer => 1, h1 => 1, h2 => 1, h3 => 1, h4 => 1, h5 => 1, |
| 6921 |
|
h6 => 1, header => 1, menu => 1, nav => 1, ol => 1, p => 1, |
| 6922 |
|
section => 1, ul => 1, |
| 6923 |
|
## NOTE: As normal, but drops leading newline |
| 6924 |
pre => 1, listing => 1, |
pre => 1, listing => 1, |
| 6925 |
|
## NOTE: As normal, but interacts with the form element pointer |
| 6926 |
form => 1, |
form => 1, |
| 6927 |
|
|
| 6928 |
table => 1, |
table => 1, |
| 6929 |
hr => 1, |
hr => 1, |
| 6930 |
}->{$token->{tag_name}}) { |
}->{$token->{tag_name}}) { |
| 6991 |
!!!next-token; |
!!!next-token; |
| 6992 |
} |
} |
| 6993 |
next B; |
next B; |
| 6994 |
} elsif ({li => 1, dt => 1, dd => 1}->{$token->{tag_name}}) { |
} elsif ($token->{tag_name} eq 'li') { |
| 6995 |
## has a p element in scope |
## NOTE: As normal, but imply </li> when there's another <li> ... |
| 6996 |
|
|
| 6997 |
|
## NOTE: Special, Scope (<li><foo><li> == <li><foo><li/></foo></li>) |
| 6998 |
|
## Interpreted as <li><foo/></li><li/> (non-conforming) |
| 6999 |
|
## blockquote (O9.27), center (O), dd (Fx3, O, S3.1.2, IE7), |
| 7000 |
|
## dt (Fx, O, S, IE), dl (O), fieldset (O, S, IE), form (Fx, O, S), |
| 7001 |
|
## hn (O), pre (O), applet (O, S), button (O, S), marquee (Fx, O, S), |
| 7002 |
|
## object (Fx) |
| 7003 |
|
## Generate non-tree (non-conforming) |
| 7004 |
|
## basefont (IE7 (where basefont is non-void)), center (IE), |
| 7005 |
|
## form (IE), hn (IE) |
| 7006 |
|
## address, div, p (<li><foo><li> == <li><foo/></li><li/>) |
| 7007 |
|
## Interpreted as <li><foo><li/></foo></li> (non-conforming) |
| 7008 |
|
## div (Fx, S) |
| 7009 |
|
|
| 7010 |
|
my $non_optional; |
| 7011 |
|
my $i = -1; |
| 7012 |
|
|
| 7013 |
|
## 1. |
| 7014 |
|
for my $node (reverse @{$self->{open_elements}}) { |
| 7015 |
|
if ($node->[1] & LI_EL) { |
| 7016 |
|
## 2. (a) As if </li> |
| 7017 |
|
{ |
| 7018 |
|
## If no </li> - not applied |
| 7019 |
|
# |
| 7020 |
|
|
| 7021 |
|
## Otherwise |
| 7022 |
|
|
| 7023 |
|
## 1. generate implied end tags, except for </li> |
| 7024 |
|
# |
| 7025 |
|
|
| 7026 |
|
## 2. If current node != "li", parse error |
| 7027 |
|
if ($non_optional) { |
| 7028 |
|
!!!parse-error (type => 'not closed', |
| 7029 |
|
text => $non_optional->[0]->manakai_local_name, |
| 7030 |
|
token => $token); |
| 7031 |
|
!!!cp ('t355'); |
| 7032 |
|
} else { |
| 7033 |
|
!!!cp ('t356'); |
| 7034 |
|
} |
| 7035 |
|
|
| 7036 |
|
## 3. Pop |
| 7037 |
|
splice @{$self->{open_elements}}, $i; |
| 7038 |
|
} |
| 7039 |
|
|
| 7040 |
|
last; ## 2. (b) goto 5. |
| 7041 |
|
} elsif ( |
| 7042 |
|
## NOTE: not "formatting" and not "phrasing" |
| 7043 |
|
($node->[1] & SPECIAL_EL or |
| 7044 |
|
$node->[1] & SCOPING_EL) and |
| 7045 |
|
## NOTE: "li", "dt", and "dd" are in |SPECIAL_EL|. |
| 7046 |
|
|
| 7047 |
|
(not $node->[1] & ADDRESS_EL) & |
| 7048 |
|
(not $node->[1] & DIV_EL) & |
| 7049 |
|
(not $node->[1] & P_EL)) { |
| 7050 |
|
## 3. |
| 7051 |
|
!!!cp ('t357'); |
| 7052 |
|
last; ## goto 5. |
| 7053 |
|
} elsif ($node->[1] & END_TAG_OPTIONAL_EL) { |
| 7054 |
|
!!!cp ('t358'); |
| 7055 |
|
# |
| 7056 |
|
} else { |
| 7057 |
|
!!!cp ('t359'); |
| 7058 |
|
$non_optional ||= $node; |
| 7059 |
|
# |
| 7060 |
|
} |
| 7061 |
|
## 4. |
| 7062 |
|
## goto 2. |
| 7063 |
|
$i--; |
| 7064 |
|
} |
| 7065 |
|
|
| 7066 |
|
## 5. (a) has a |p| element in scope |
| 7067 |
|
## ISSUE: Is this step really necessary? |
| 7068 |
INSCOPE: for (reverse @{$self->{open_elements}}) { |
INSCOPE: for (reverse @{$self->{open_elements}}) { |
| 7069 |
if ($_->[1] & P_EL) { |
if ($_->[1] & P_EL) { |
| 7070 |
!!!cp ('t353'); |
!!!cp ('t353'); |
| 7077 |
last INSCOPE; |
last INSCOPE; |
| 7078 |
} |
} |
| 7079 |
} # INSCOPE |
} # INSCOPE |
| 7080 |
|
|
| 7081 |
## Step 1 |
## 5. (b) insert |
| 7082 |
|
!!!insert-element-t ($token->{tag_name}, $token->{attributes}, $token); |
| 7083 |
|
!!!nack ('t359.1'); |
| 7084 |
|
!!!next-token; |
| 7085 |
|
next B; |
| 7086 |
|
} elsif ($token->{tag_name} eq 'dt' or |
| 7087 |
|
$token->{tag_name} eq 'dd') { |
| 7088 |
|
## NOTE: As normal, but imply </dt> or </dd> when ... |
| 7089 |
|
|
| 7090 |
|
my $non_optional; |
| 7091 |
my $i = -1; |
my $i = -1; |
| 7092 |
my $node = $self->{open_elements}->[$i]; |
|
| 7093 |
my $li_or_dtdd = {li => {li => 1}, |
## 1. |
| 7094 |
dt => {dt => 1, dd => 1}, |
for my $node (reverse @{$self->{open_elements}}) { |
| 7095 |
dd => {dt => 1, dd => 1}}->{$token->{tag_name}}; |
if ($node->[1] & DT_EL or $node->[1] & DD_EL) { |
| 7096 |
LI: { |
## 2. (a) As if </li> |
| 7097 |
## Step 2 |
{ |
| 7098 |
if ($li_or_dtdd->{$node->[0]->manakai_local_name}) { |
## If no </li> - not applied |
| 7099 |
if ($i != -1) { |
# |
| 7100 |
!!!cp ('t355'); |
|
| 7101 |
!!!parse-error (type => 'not closed', |
## Otherwise |
| 7102 |
text => $self->{open_elements}->[-1]->[0] |
|
| 7103 |
->manakai_local_name, |
## 1. generate implied end tags, except for </dt> or </dd> |
| 7104 |
token => $token); |
# |
| 7105 |
} else { |
|
| 7106 |
!!!cp ('t356'); |
## 2. If current node != "dt"|"dd", parse error |
| 7107 |
|
if ($non_optional) { |
| 7108 |
|
!!!parse-error (type => 'not closed', |
| 7109 |
|
text => $non_optional->[0]->manakai_local_name, |
| 7110 |
|
token => $token); |
| 7111 |
|
!!!cp ('t355.1'); |
| 7112 |
|
} else { |
| 7113 |
|
!!!cp ('t356.1'); |
| 7114 |
|
} |
| 7115 |
|
|
| 7116 |
|
## 3. Pop |
| 7117 |
|
splice @{$self->{open_elements}}, $i; |
| 7118 |
} |
} |
| 7119 |
splice @{$self->{open_elements}}, $i; |
|
| 7120 |
last LI; |
last; ## 2. (b) goto 5. |
| 7121 |
|
} elsif ( |
| 7122 |
|
## NOTE: not "formatting" and not "phrasing" |
| 7123 |
|
($node->[1] & SPECIAL_EL or |
| 7124 |
|
$node->[1] & SCOPING_EL) and |
| 7125 |
|
## NOTE: "li", "dt", and "dd" are in |SPECIAL_EL|. |
| 7126 |
|
|
| 7127 |
|
(not $node->[1] & ADDRESS_EL) & |
| 7128 |
|
(not $node->[1] & DIV_EL) & |
| 7129 |
|
(not $node->[1] & P_EL)) { |
| 7130 |
|
## 3. |
| 7131 |
|
!!!cp ('t357.1'); |
| 7132 |
|
last; ## goto 5. |
| 7133 |
|
} elsif ($node->[1] & END_TAG_OPTIONAL_EL) { |
| 7134 |
|
!!!cp ('t358.1'); |
| 7135 |
|
# |
| 7136 |
} else { |
} else { |
| 7137 |
!!!cp ('t357'); |
!!!cp ('t359.1'); |
| 7138 |
} |
$non_optional ||= $node; |
| 7139 |
|
# |
|
## Step 3 |
|
|
if (not ($node->[1] & FORMATTING_EL) and |
|
|
#not $phrasing_category->{$node->[1]} and |
|
|
($node->[1] & SPECIAL_EL or |
|
|
$node->[1] & SCOPING_EL) and |
|
|
not ($node->[1] & ADDRESS_EL) and |
|
|
not ($node->[1] & DIV_EL)) { |
|
|
!!!cp ('t358'); |
|
|
last LI; |
|
| 7140 |
} |
} |
| 7141 |
|
## 4. |
| 7142 |
!!!cp ('t359'); |
## goto 2. |
|
## Step 4 |
|
| 7143 |
$i--; |
$i--; |
| 7144 |
$node = $self->{open_elements}->[$i]; |
} |
| 7145 |
redo LI; |
|
| 7146 |
} # LI |
## 5. (a) has a |p| element in scope |
| 7147 |
|
## ISSUE: Is this step really necessary? |
| 7148 |
|
INSCOPE: for (reverse @{$self->{open_elements}}) { |
| 7149 |
|
if ($_->[1] & P_EL) { |
| 7150 |
|
!!!cp ('t353.1'); |
| 7151 |
|
!!!back-token; # <x> |
| 7152 |
|
$token = {type => END_TAG_TOKEN, tag_name => 'p', |
| 7153 |
|
line => $token->{line}, column => $token->{column}}; |
| 7154 |
|
next B; |
| 7155 |
|
} elsif ($_->[1] & SCOPING_EL) { |
| 7156 |
|
!!!cp ('t354.1'); |
| 7157 |
|
last INSCOPE; |
| 7158 |
|
} |
| 7159 |
|
} # INSCOPE |
| 7160 |
|
|
| 7161 |
|
## 5. (b) insert |
| 7162 |
!!!insert-element-t ($token->{tag_name}, $token->{attributes}, $token); |
!!!insert-element-t ($token->{tag_name}, $token->{attributes}, $token); |
| 7163 |
!!!nack ('t359.1'); |
!!!nack ('t359.2'); |
| 7164 |
!!!next-token; |
!!!next-token; |
| 7165 |
next B; |
next B; |
| 7166 |
} elsif ($token->{tag_name} eq 'plaintext') { |
} elsif ($token->{tag_name} eq 'plaintext') { |
| 7167 |
|
## NOTE: As normal, but effectively ends parsing |
| 7168 |
|
|
| 7169 |
## has a p element in scope |
## has a p element in scope |
| 7170 |
INSCOPE: for (reverse @{$self->{open_elements}}) { |
INSCOPE: for (reverse @{$self->{open_elements}}) { |
| 7171 |
if ($_->[1] & P_EL) { |
if ($_->[1] & P_EL) { |
| 7498 |
!!!nack ('t380.1'); |
!!!nack ('t380.1'); |
| 7499 |
} elsif ({ |
} elsif ({ |
| 7500 |
b => 1, big => 1, em => 1, font => 1, i => 1, |
b => 1, big => 1, em => 1, font => 1, i => 1, |
| 7501 |
s => 1, small => 1, strile => 1, |
s => 1, small => 1, strike => 1, |
| 7502 |
strong => 1, tt => 1, u => 1, |
strong => 1, tt => 1, u => 1, |
| 7503 |
}->{$token->{tag_name}}) { |
}->{$token->{tag_name}}) { |
| 7504 |
!!!cp ('t375'); |
!!!cp ('t375'); |
| 7602 |
next B; |
next B; |
| 7603 |
} |
} |
| 7604 |
} elsif ({ |
} elsif ({ |
| 7605 |
address => 1, blockquote => 1, center => 1, dir => 1, |
## NOTE: End tags for non-phrasing flow content elements |
| 7606 |
div => 1, dl => 1, fieldset => 1, listing => 1, |
|
| 7607 |
menu => 1, ol => 1, pre => 1, ul => 1, |
## NOTE: The normal ones |
| 7608 |
|
address => 1, article => 1, aside => 1, blockquote => 1, |
| 7609 |
|
center => 1, datagrid => 1, details => 1, dialog => 1, |
| 7610 |
|
dir => 1, div => 1, dl => 1, fieldset => 1, figure => 1, |
| 7611 |
|
footer => 1, header => 1, listing => 1, menu => 1, nav => 1, |
| 7612 |
|
ol => 1, pre => 1, section => 1, ul => 1, |
| 7613 |
|
|
| 7614 |
|
## NOTE: As normal, but ... optional tags |
| 7615 |
dd => 1, dt => 1, li => 1, |
dd => 1, dt => 1, li => 1, |
| 7616 |
|
|
| 7617 |
applet => 1, button => 1, marquee => 1, object => 1, |
applet => 1, button => 1, marquee => 1, object => 1, |
| 7618 |
}->{$token->{tag_name}}) { |
}->{$token->{tag_name}}) { |
| 7619 |
## has an element in scope |
## has an element in scope |
| 7642 |
dd => ($token->{tag_name} ne 'dd'), |
dd => ($token->{tag_name} ne 'dd'), |
| 7643 |
dt => ($token->{tag_name} ne 'dt'), |
dt => ($token->{tag_name} ne 'dt'), |
| 7644 |
li => ($token->{tag_name} ne 'li'), |
li => ($token->{tag_name} ne 'li'), |
| 7645 |
|
option => 1, |
| 7646 |
|
optgroup => 1, |
| 7647 |
p => 1, |
p => 1, |
| 7648 |
rt => 1, |
rt => 1, |
| 7649 |
rp => 1, |
rp => 1, |
| 7676 |
!!!next-token; |
!!!next-token; |
| 7677 |
next B; |
next B; |
| 7678 |
} elsif ($token->{tag_name} eq 'form') { |
} elsif ($token->{tag_name} eq 'form') { |
| 7679 |
|
## NOTE: As normal, but interacts with the form element pointer |
| 7680 |
|
|
| 7681 |
undef $self->{form_element}; |
undef $self->{form_element}; |
| 7682 |
|
|
| 7683 |
## has an element in scope |
## has an element in scope |
| 7725 |
!!!next-token; |
!!!next-token; |
| 7726 |
next B; |
next B; |
| 7727 |
} elsif ({ |
} elsif ({ |
| 7728 |
|
## NOTE: As normal, except acts as a closer for any ... |
| 7729 |
h1 => 1, h2 => 1, h3 => 1, h4 => 1, h5 => 1, h6 => 1, |
h1 => 1, h2 => 1, h3 => 1, h4 => 1, h5 => 1, h6 => 1, |
| 7730 |
}->{$token->{tag_name}}) { |
}->{$token->{tag_name}}) { |
| 7731 |
## has an element in scope |
## has an element in scope |
| 7771 |
!!!next-token; |
!!!next-token; |
| 7772 |
next B; |
next B; |
| 7773 |
} elsif ($token->{tag_name} eq 'p') { |
} elsif ($token->{tag_name} eq 'p') { |
| 7774 |
|
## NOTE: As normal, except </p> implies <p> and ... |
| 7775 |
|
|
| 7776 |
## has an element in scope |
## has an element in scope |
| 7777 |
my $i; |
my $i; |
| 7778 |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
| 7818 |
} elsif ({ |
} elsif ({ |
| 7819 |
a => 1, |
a => 1, |
| 7820 |
b => 1, big => 1, em => 1, font => 1, i => 1, |
b => 1, big => 1, em => 1, font => 1, i => 1, |
| 7821 |
nobr => 1, s => 1, small => 1, strile => 1, |
nobr => 1, s => 1, small => 1, strike => 1, |
| 7822 |
strong => 1, tt => 1, u => 1, |
strong => 1, tt => 1, u => 1, |
| 7823 |
}->{$token->{tag_name}}) { |
}->{$token->{tag_name}}) { |
| 7824 |
!!!cp ('t427'); |
!!!cp ('t427'); |
| 7857 |
## Ignore the token |
## Ignore the token |
| 7858 |
!!!next-token; |
!!!next-token; |
| 7859 |
next B; |
next B; |
|
|
|
|
## ISSUE: Issue on HTML5 new elements in spec |
|
|
|
|
| 7860 |
} else { |
} else { |
| 7861 |
|
if ($token->{tag_name} eq 'sarcasm') { |
| 7862 |
|
sleep 0.001; # take a deep breath |
| 7863 |
|
} |
| 7864 |
|
|
| 7865 |
## Step 1 |
## Step 1 |
| 7866 |
my $node_i = -1; |
my $node_i = -1; |
| 7867 |
my $node = $self->{open_elements}->[$node_i]; |
my $node = $self->{open_elements}->[$node_i]; |
| 7910 |
## Ignore the token |
## Ignore the token |
| 7911 |
!!!next-token; |
!!!next-token; |
| 7912 |
last S2; |
last S2; |
|
} |
|
| 7913 |
|
|
| 7914 |
|
## NOTE: |<span><dd></span>a|: In Safari 3.1.2 and Opera |
| 7915 |
|
## 9.27, "a" is a child of <dd> (conforming). In |
| 7916 |
|
## Firefox 3.0.2, "a" is a child of <body>. In WinIE 7, |
| 7917 |
|
## "a" is a child of both <body> and <dd>. |
| 7918 |
|
} |
| 7919 |
|
|
| 7920 |
!!!cp ('t434'); |
!!!cp ('t434'); |
| 7921 |
} |
} |
| 7922 |
|
|