| 8 |
## doc.write (''); |
## doc.write (''); |
| 9 |
## alert (doc.compatMode); |
## alert (doc.compatMode); |
| 10 |
|
|
| 11 |
## TODO: Control charcters and noncharacters are not allowed (HTML5 revision 1263) |
require IO::Handle; |
|
## TODO: 1252 parse error (revision 1264) |
|
|
## TODO: 8859-11 = 874 (revision 1271) |
|
| 12 |
|
|
| 13 |
my $HTML_NS = q<http://www.w3.org/1999/xhtml>; |
my $HTML_NS = q<http://www.w3.org/1999/xhtml>; |
| 14 |
my $MML_NS = q<http://www.w3.org/1998/Math/MathML>; |
my $MML_NS = q<http://www.w3.org/1998/Math/MathML>; |
| 45 |
sub FOREIGN_EL () { 0b10000000000000000000000000 } |
sub FOREIGN_EL () { 0b10000000000000000000000000 } |
| 46 |
sub FOREIGN_FLOW_CONTENT_EL () { 0b100000000000000000000000000 } |
sub FOREIGN_FLOW_CONTENT_EL () { 0b100000000000000000000000000 } |
| 47 |
sub MML_AXML_EL () { 0b1000000000000000000000000000 } |
sub MML_AXML_EL () { 0b1000000000000000000000000000 } |
| 48 |
|
sub RUBY_EL () { 0b10000000000000000000000000000 } |
| 49 |
|
sub RUBY_COMPONENT_EL () { 0b100000000000000000000000000000 } |
| 50 |
|
|
| 51 |
sub TABLE_ROWS_EL () { |
sub TABLE_ROWS_EL () { |
| 52 |
TABLE_EL | |
TABLE_EL | |
| 54 |
TABLE_ROW_GROUP_EL |
TABLE_ROW_GROUP_EL |
| 55 |
} |
} |
| 56 |
|
|
| 57 |
|
## NOTE: Used in "generate implied end tags" algorithm. |
| 58 |
|
## NOTE: There is a code where a modified version of END_TAG_OPTIONAL_EL |
| 59 |
|
## is used in "generate implied end tags" implementation (search for the |
| 60 |
|
## function mae). |
| 61 |
sub END_TAG_OPTIONAL_EL () { |
sub END_TAG_OPTIONAL_EL () { |
| 62 |
DD_EL | |
DD_EL | |
| 63 |
DT_EL | |
DT_EL | |
| 64 |
LI_EL | |
LI_EL | |
| 65 |
P_EL |
P_EL | |
| 66 |
|
RUBY_COMPONENT_EL |
| 67 |
} |
} |
| 68 |
|
|
| 69 |
|
## NOTE: Used in </body> and EOF algorithms. |
| 70 |
sub ALL_END_TAG_OPTIONAL_EL () { |
sub ALL_END_TAG_OPTIONAL_EL () { |
| 71 |
END_TAG_OPTIONAL_EL | |
DD_EL | |
| 72 |
|
DT_EL | |
| 73 |
|
LI_EL | |
| 74 |
|
P_EL | |
| 75 |
|
|
| 76 |
BODY_EL | |
BODY_EL | |
| 77 |
HTML_EL | |
HTML_EL | |
| 78 |
TABLE_CELL_EL | |
TABLE_CELL_EL | |
| 108 |
ADDRESS_EL | |
ADDRESS_EL | |
| 109 |
BODY_EL | |
BODY_EL | |
| 110 |
DIV_EL | |
DIV_EL | |
| 111 |
END_TAG_OPTIONAL_EL | |
|
| 112 |
|
DD_EL | |
| 113 |
|
DT_EL | |
| 114 |
|
LI_EL | |
| 115 |
|
P_EL | |
| 116 |
|
|
| 117 |
FORM_EL | |
FORM_EL | |
| 118 |
FRAMESET_EL | |
FRAMESET_EL | |
| 119 |
HEADING_EL | |
HEADING_EL | |
| 187 |
param => MISC_SPECIAL_EL, |
param => MISC_SPECIAL_EL, |
| 188 |
plaintext => MISC_SPECIAL_EL, |
plaintext => MISC_SPECIAL_EL, |
| 189 |
pre => MISC_SPECIAL_EL, |
pre => MISC_SPECIAL_EL, |
| 190 |
|
rp => RUBY_COMPONENT_EL, |
| 191 |
|
rt => RUBY_COMPONENT_EL, |
| 192 |
|
ruby => RUBY_EL, |
| 193 |
s => FORMATTING_EL, |
s => FORMATTING_EL, |
| 194 |
script => MISC_SPECIAL_EL, |
script => MISC_SPECIAL_EL, |
| 195 |
select => SELECT_EL, |
select => SELECT_EL, |
| 223 |
mtext => FOREIGN_FLOW_CONTENT_EL, |
mtext => FOREIGN_FLOW_CONTENT_EL, |
| 224 |
}, |
}, |
| 225 |
$SVG_NS => { |
$SVG_NS => { |
| 226 |
foreignobject => FOREIGN_FLOW_CONTENT_EL, ## TODO: case |
foreignObject => FOREIGN_FLOW_CONTENT_EL, |
| 227 |
desc => FOREIGN_FLOW_CONTENT_EL, |
desc => FOREIGN_FLOW_CONTENT_EL, |
| 228 |
title => FOREIGN_FLOW_CONTENT_EL, |
title => FOREIGN_FLOW_CONTENT_EL, |
| 229 |
}, |
}, |
| 230 |
## NOTE: In addition, FOREIGN_EL is set to non-HTML elements. |
## NOTE: In addition, FOREIGN_EL is set to non-HTML elements. |
| 231 |
}; |
}; |
| 232 |
|
|
| 233 |
|
my $svg_attr_name = { |
| 234 |
|
attributename => 'attributeName', |
| 235 |
|
attributetype => 'attributeType', |
| 236 |
|
basefrequency => 'baseFrequency', |
| 237 |
|
baseprofile => 'baseProfile', |
| 238 |
|
calcmode => 'calcMode', |
| 239 |
|
clippathunits => 'clipPathUnits', |
| 240 |
|
contentscripttype => 'contentScriptType', |
| 241 |
|
contentstyletype => 'contentStyleType', |
| 242 |
|
diffuseconstant => 'diffuseConstant', |
| 243 |
|
edgemode => 'edgeMode', |
| 244 |
|
externalresourcesrequired => 'externalResourcesRequired', |
| 245 |
|
filterres => 'filterRes', |
| 246 |
|
filterunits => 'filterUnits', |
| 247 |
|
glyphref => 'glyphRef', |
| 248 |
|
gradienttransform => 'gradientTransform', |
| 249 |
|
gradientunits => 'gradientUnits', |
| 250 |
|
kernelmatrix => 'kernelMatrix', |
| 251 |
|
kernelunitlength => 'kernelUnitLength', |
| 252 |
|
keypoints => 'keyPoints', |
| 253 |
|
keysplines => 'keySplines', |
| 254 |
|
keytimes => 'keyTimes', |
| 255 |
|
lengthadjust => 'lengthAdjust', |
| 256 |
|
limitingconeangle => 'limitingConeAngle', |
| 257 |
|
markerheight => 'markerHeight', |
| 258 |
|
markerunits => 'markerUnits', |
| 259 |
|
markerwidth => 'markerWidth', |
| 260 |
|
maskcontentunits => 'maskContentUnits', |
| 261 |
|
maskunits => 'maskUnits', |
| 262 |
|
numoctaves => 'numOctaves', |
| 263 |
|
pathlength => 'pathLength', |
| 264 |
|
patterncontentunits => 'patternContentUnits', |
| 265 |
|
patterntransform => 'patternTransform', |
| 266 |
|
patternunits => 'patternUnits', |
| 267 |
|
pointsatx => 'pointsAtX', |
| 268 |
|
pointsaty => 'pointsAtY', |
| 269 |
|
pointsatz => 'pointsAtZ', |
| 270 |
|
preservealpha => 'preserveAlpha', |
| 271 |
|
preserveaspectratio => 'preserveAspectRatio', |
| 272 |
|
primitiveunits => 'primitiveUnits', |
| 273 |
|
refx => 'refX', |
| 274 |
|
refy => 'refY', |
| 275 |
|
repeatcount => 'repeatCount', |
| 276 |
|
repeatdur => 'repeatDur', |
| 277 |
|
requiredextensions => 'requiredExtensions', |
| 278 |
|
requiredfeatures => 'requiredFeatures', |
| 279 |
|
specularconstant => 'specularConstant', |
| 280 |
|
specularexponent => 'specularExponent', |
| 281 |
|
spreadmethod => 'spreadMethod', |
| 282 |
|
startoffset => 'startOffset', |
| 283 |
|
stddeviation => 'stdDeviation', |
| 284 |
|
stitchtiles => 'stitchTiles', |
| 285 |
|
surfacescale => 'surfaceScale', |
| 286 |
|
systemlanguage => 'systemLanguage', |
| 287 |
|
tablevalues => 'tableValues', |
| 288 |
|
targetx => 'targetX', |
| 289 |
|
targety => 'targetY', |
| 290 |
|
textlength => 'textLength', |
| 291 |
|
viewbox => 'viewBox', |
| 292 |
|
viewtarget => 'viewTarget', |
| 293 |
|
xchannelselector => 'xChannelSelector', |
| 294 |
|
ychannelselector => 'yChannelSelector', |
| 295 |
|
zoomandpan => 'zoomAndPan', |
| 296 |
|
}; |
| 297 |
|
|
| 298 |
|
my $foreign_attr_xname = { |
| 299 |
|
'xlink:actuate' => [$XLINK_NS, ['xlink', 'actuate']], |
| 300 |
|
'xlink:arcrole' => [$XLINK_NS, ['xlink', 'arcrole']], |
| 301 |
|
'xlink:href' => [$XLINK_NS, ['xlink', 'href']], |
| 302 |
|
'xlink:role' => [$XLINK_NS, ['xlink', 'role']], |
| 303 |
|
'xlink:show' => [$XLINK_NS, ['xlink', 'show']], |
| 304 |
|
'xlink:title' => [$XLINK_NS, ['xlink', 'title']], |
| 305 |
|
'xlink:type' => [$XLINK_NS, ['xlink', 'type']], |
| 306 |
|
'xml:base' => [$XML_NS, ['xml', 'base']], |
| 307 |
|
'xml:lang' => [$XML_NS, ['xml', 'lang']], |
| 308 |
|
'xml:space' => [$XML_NS, ['xml', 'space']], |
| 309 |
|
'xmlns' => [$XMLNS_NS, [undef, 'xmlns']], |
| 310 |
|
'xmlns:xlink' => [$XMLNS_NS, ['xmlns', 'xlink']], |
| 311 |
|
}; |
| 312 |
|
|
| 313 |
|
## ISSUE: xmlns:xlink="non-xlink-ns" is not an error. |
| 314 |
|
|
| 315 |
my $c1_entity_char = { |
my $c1_entity_char = { |
| 316 |
0x80 => 0x20AC, |
0x80 => 0x20AC, |
| 317 |
0x81 => 0xFFFD, |
0x81 => 0xFFFD, |
| 348 |
}; # $c1_entity_char |
}; # $c1_entity_char |
| 349 |
|
|
| 350 |
sub parse_byte_string ($$$$;$) { |
sub parse_byte_string ($$$$;$) { |
| 351 |
|
my $self = shift; |
| 352 |
|
my $charset_name = shift; |
| 353 |
|
open my $input, '<', ref $_[0] ? $_[0] : \($_[0]); |
| 354 |
|
return $self->parse_byte_stream ($charset_name, $input, @_[1..$#_]); |
| 355 |
|
} # parse_byte_string |
| 356 |
|
|
| 357 |
|
sub parse_byte_stream ($$$$;$$) { |
| 358 |
|
# my ($self, $charset_name, $byte_stream, $doc, $onerror, $get_wrapper) = @_; |
| 359 |
my $self = ref $_[0] ? shift : shift->new; |
my $self = ref $_[0] ? shift : shift->new; |
| 360 |
my $charset = shift; |
my $charset_name = shift; |
| 361 |
my $bytes_s = ref $_[0] ? $_[0] : \($_[0]); |
my $byte_stream = $_[0]; |
| 362 |
my $s; |
|
| 363 |
|
my $onerror = $_[2] || sub { |
| 364 |
if (defined $charset) { |
my (%opt) = @_; |
| 365 |
require Encode; ## TODO: decode(utf8) don't delete BOM |
warn "Parse error ($opt{type})\n"; |
| 366 |
$s = \ (Encode::decode ($charset, $$bytes_s)); |
}; |
| 367 |
$self->{input_encoding} = lc $charset; ## TODO: normalize name |
$self->{parse_error} = $onerror; # updated later by parse_char_string |
| 368 |
$self->{confident} = 1; |
|
| 369 |
} else { |
my $get_wrapper = $_[3] || sub ($) { |
| 370 |
## TODO: Implement HTML5 detection algorithm |
return $_[0]; # $_[0] = byte stream handle, returned = arg to char handle |
| 371 |
|
}; |
| 372 |
|
|
| 373 |
|
## HTML5 encoding sniffing algorithm |
| 374 |
|
require Message::Charset::Info; |
| 375 |
|
my $charset; |
| 376 |
|
my $buffer; |
| 377 |
|
my ($char_stream, $e_status); |
| 378 |
|
|
| 379 |
|
SNIFFING: { |
| 380 |
|
## NOTE: By setting |allow_fallback| option true when the |
| 381 |
|
## |get_decode_handle| method is invoked, we ignore what the HTML5 |
| 382 |
|
## spec requires, i.e. unsupported encoding should be ignored. |
| 383 |
|
## TODO: We should not do this unless the parser is invoked |
| 384 |
|
## in the conformance checking mode, in which this behavior |
| 385 |
|
## would be useful. |
| 386 |
|
|
| 387 |
|
## Step 1 |
| 388 |
|
if (defined $charset_name) { |
| 389 |
|
$charset = Message::Charset::Info->get_by_html_name ($charset_name); |
| 390 |
|
## TODO: Is this ok? Transfer protocol's parameter should be |
| 391 |
|
## interpreted in its semantics? |
| 392 |
|
|
| 393 |
|
## ISSUE: Unsupported encoding is not ignored according to the spec. |
| 394 |
|
($char_stream, $e_status) = $charset->get_decode_handle |
| 395 |
|
($byte_stream, allow_error_reporting => 1, |
| 396 |
|
allow_fallback => 1); |
| 397 |
|
if ($char_stream) { |
| 398 |
|
$self->{confident} = 1; |
| 399 |
|
last SNIFFING; |
| 400 |
|
} else { |
| 401 |
|
## TODO: unsupported error |
| 402 |
|
} |
| 403 |
|
} |
| 404 |
|
|
| 405 |
|
## Step 2 |
| 406 |
|
my $byte_buffer = ''; |
| 407 |
|
for (1..1024) { |
| 408 |
|
my $char = $byte_stream->getc; |
| 409 |
|
last unless defined $char; |
| 410 |
|
$byte_buffer .= $char; |
| 411 |
|
} ## TODO: timeout |
| 412 |
|
|
| 413 |
|
## Step 3 |
| 414 |
|
if ($byte_buffer =~ /^\xFE\xFF/) { |
| 415 |
|
$charset = Message::Charset::Info->get_by_html_name ('utf-16be'); |
| 416 |
|
($char_stream, $e_status) = $charset->get_decode_handle |
| 417 |
|
($byte_stream, allow_error_reporting => 1, |
| 418 |
|
allow_fallback => 1, byte_buffer => \$byte_buffer); |
| 419 |
|
$self->{confident} = 1; |
| 420 |
|
last SNIFFING; |
| 421 |
|
} elsif ($byte_buffer =~ /^\xFF\xFE/) { |
| 422 |
|
$charset = Message::Charset::Info->get_by_html_name ('utf-16le'); |
| 423 |
|
($char_stream, $e_status) = $charset->get_decode_handle |
| 424 |
|
($byte_stream, allow_error_reporting => 1, |
| 425 |
|
allow_fallback => 1, byte_buffer => \$byte_buffer); |
| 426 |
|
$self->{confident} = 1; |
| 427 |
|
last SNIFFING; |
| 428 |
|
} elsif ($byte_buffer =~ /^\xEF\xBB\xBF/) { |
| 429 |
|
$charset = Message::Charset::Info->get_by_html_name ('utf-8'); |
| 430 |
|
($char_stream, $e_status) = $charset->get_decode_handle |
| 431 |
|
($byte_stream, allow_error_reporting => 1, |
| 432 |
|
allow_fallback => 1, byte_buffer => \$byte_buffer); |
| 433 |
|
$self->{confident} = 1; |
| 434 |
|
last SNIFFING; |
| 435 |
|
} |
| 436 |
|
|
| 437 |
|
## Step 4 |
| 438 |
|
## TODO: <meta charset> |
| 439 |
|
|
| 440 |
|
## Step 5 |
| 441 |
|
## TODO: from history |
| 442 |
|
|
| 443 |
|
## Step 6 |
| 444 |
require Whatpm::Charset::UniversalCharDet; |
require Whatpm::Charset::UniversalCharDet; |
| 445 |
$charset = Whatpm::Charset::UniversalCharDet->detect_byte_string |
$charset_name = Whatpm::Charset::UniversalCharDet->detect_byte_string |
| 446 |
(substr ($$bytes_s, 0, 1024)); |
($byte_buffer); |
| 447 |
$charset ||= 'windows-1252'; |
if (defined $charset_name) { |
| 448 |
$s = \ (Encode::decode ($charset, $$bytes_s)); |
$charset = Message::Charset::Info->get_by_html_name ($charset_name); |
| 449 |
$self->{input_encoding} = $charset; |
|
| 450 |
|
## ISSUE: Unsupported encoding is not ignored according to the spec. |
| 451 |
|
require Whatpm::Charset::DecodeHandle; |
| 452 |
|
$buffer = Whatpm::Charset::DecodeHandle::ByteBuffer->new |
| 453 |
|
($byte_stream); |
| 454 |
|
($char_stream, $e_status) = $charset->get_decode_handle |
| 455 |
|
($buffer, allow_error_reporting => 1, |
| 456 |
|
allow_fallback => 1, byte_buffer => \$byte_buffer); |
| 457 |
|
if ($char_stream) { |
| 458 |
|
$buffer->{buffer} = $byte_buffer; |
| 459 |
|
!!!parse-error (type => 'sniffing:chardet', |
| 460 |
|
text => $charset_name, |
| 461 |
|
level => $self->{level}->{info}, |
| 462 |
|
layer => 'encode', |
| 463 |
|
line => 1, column => 1); |
| 464 |
|
$self->{confident} = 0; |
| 465 |
|
last SNIFFING; |
| 466 |
|
} |
| 467 |
|
} |
| 468 |
|
|
| 469 |
|
## Step 7: default |
| 470 |
|
## TODO: Make this configurable. |
| 471 |
|
$charset = Message::Charset::Info->get_by_html_name ('windows-1252'); |
| 472 |
|
## NOTE: We choose |windows-1252| here, since |utf-8| should be |
| 473 |
|
## detectable in the step 6. |
| 474 |
|
require Whatpm::Charset::DecodeHandle; |
| 475 |
|
$buffer = Whatpm::Charset::DecodeHandle::ByteBuffer->new |
| 476 |
|
($byte_stream); |
| 477 |
|
($char_stream, $e_status) |
| 478 |
|
= $charset->get_decode_handle ($buffer, |
| 479 |
|
allow_error_reporting => 1, |
| 480 |
|
allow_fallback => 1, |
| 481 |
|
byte_buffer => \$byte_buffer); |
| 482 |
|
$buffer->{buffer} = $byte_buffer; |
| 483 |
|
!!!parse-error (type => 'sniffing:default', |
| 484 |
|
text => 'windows-1252', |
| 485 |
|
level => $self->{level}->{info}, |
| 486 |
|
line => 1, column => 1, |
| 487 |
|
layer => 'encode'); |
| 488 |
$self->{confident} = 0; |
$self->{confident} = 0; |
| 489 |
|
} # SNIFFING |
| 490 |
|
|
| 491 |
|
if ($e_status & Message::Charset::Info::FALLBACK_ENCODING_IMPL ()) { |
| 492 |
|
$self->{input_encoding} = $charset->get_iana_name; ## TODO: Should we set actual charset decoder's encoding name? |
| 493 |
|
!!!parse-error (type => 'chardecode:fallback', |
| 494 |
|
#text => $self->{input_encoding}, |
| 495 |
|
level => $self->{level}->{uncertain}, |
| 496 |
|
line => 1, column => 1, |
| 497 |
|
layer => 'encode'); |
| 498 |
|
} elsif (not ($e_status & |
| 499 |
|
Message::Charset::Info::ERROR_REPORTING_ENCODING_IMPL())) { |
| 500 |
|
$self->{input_encoding} = $charset->get_iana_name; |
| 501 |
|
!!!parse-error (type => 'chardecode:no error', |
| 502 |
|
text => $self->{input_encoding}, |
| 503 |
|
level => $self->{level}->{uncertain}, |
| 504 |
|
line => 1, column => 1, |
| 505 |
|
layer => 'encode'); |
| 506 |
|
} else { |
| 507 |
|
$self->{input_encoding} = $charset->get_iana_name; |
| 508 |
} |
} |
| 509 |
|
|
| 510 |
$self->{change_encoding} = sub { |
$self->{change_encoding} = sub { |
| 511 |
my $self = shift; |
my $self = shift; |
| 512 |
my $charset = lc shift; |
$charset_name = shift; |
| 513 |
my $token = shift; |
my $token = shift; |
|
## TODO: if $charset is supported |
|
|
## TODO: normalize charset name |
|
| 514 |
|
|
| 515 |
## "Change the encoding" algorithm: |
$charset = Message::Charset::Info->get_by_html_name ($charset_name); |
| 516 |
|
($char_stream, $e_status) = $charset->get_decode_handle |
| 517 |
|
($byte_stream, allow_error_reporting => 1, allow_fallback => 1, |
| 518 |
|
byte_buffer => \ $buffer->{buffer}); |
| 519 |
|
|
| 520 |
|
if ($char_stream) { # if supported |
| 521 |
|
## "Change the encoding" algorithm: |
| 522 |
|
|
| 523 |
## Step 1 |
## Step 1 |
| 524 |
if ($charset eq 'utf-16') { ## ISSUE: UTF-16BE -> UTF-8? UTF-16LE -> UTF-8? |
if ($charset->{category} & |
| 525 |
$charset = 'utf-8'; |
Message::Charset::Info::CHARSET_CATEGORY_UTF16 ()) { |
| 526 |
} |
$charset = Message::Charset::Info->get_by_html_name ('utf-8'); |
| 527 |
|
($char_stream, $e_status) = $charset->get_decode_handle |
| 528 |
|
($byte_stream, |
| 529 |
|
byte_buffer => \ $buffer->{buffer}); |
| 530 |
|
} |
| 531 |
|
$charset_name = $charset->get_iana_name; |
| 532 |
|
|
| 533 |
|
## Step 2 |
| 534 |
|
if (defined $self->{input_encoding} and |
| 535 |
|
$self->{input_encoding} eq $charset_name) { |
| 536 |
|
!!!parse-error (type => 'charset label:matching', |
| 537 |
|
text => $charset_name, |
| 538 |
|
level => $self->{level}->{info}); |
| 539 |
|
$self->{confident} = 1; |
| 540 |
|
return; |
| 541 |
|
} |
| 542 |
|
|
| 543 |
## Step 2 |
!!!parse-error (type => 'charset label detected', |
| 544 |
if (defined $self->{input_encoding} and |
text => $self->{input_encoding}, |
| 545 |
$self->{input_encoding} eq $charset) { |
value => $charset_name, |
| 546 |
$self->{confident} = 1; |
level => $self->{level}->{warn}, |
| 547 |
return; |
token => $token); |
| 548 |
|
|
| 549 |
|
## Step 3 |
| 550 |
|
# if (can) { |
| 551 |
|
## change the encoding on the fly. |
| 552 |
|
#$self->{confident} = 1; |
| 553 |
|
#return; |
| 554 |
|
# } |
| 555 |
|
|
| 556 |
|
## Step 4 |
| 557 |
|
throw Whatpm::HTML::RestartParser (); |
| 558 |
} |
} |
| 559 |
|
}; # $self->{change_encoding} |
| 560 |
|
|
| 561 |
!!!parse-error (type => 'charset label detected:'.$self->{input_encoding}. |
my $char_onerror = sub { |
| 562 |
':'.$charset, level => 'w', token => $token); |
my (undef, $type, %opt) = @_; |
| 563 |
|
!!!parse-error (layer => 'encode', |
| 564 |
## Step 3 |
%opt, type => $type, |
| 565 |
# if (can) { |
line => $self->{line}, column => $self->{column} + 1); |
| 566 |
## change the encoding on the fly. |
if ($opt{octets}) { |
| 567 |
#$self->{confident} = 1; |
${$opt{octets}} = "\x{FFFD}"; # relacement character |
| 568 |
#return; |
} |
| 569 |
# } |
}; |
| 570 |
|
|
| 571 |
## Step 4 |
my $wrapped_char_stream = $get_wrapper->($char_stream); |
| 572 |
throw Whatpm::HTML::RestartParser (charset => $charset); |
$wrapped_char_stream->onerror ($char_onerror); |
|
}; # $self->{change_encoding} |
|
| 573 |
|
|
| 574 |
my @args = @_; shift @args; # $s |
my @args = @_; shift @args; # $s |
| 575 |
my $return; |
my $return; |
| 576 |
try { |
try { |
| 577 |
$return = $self->parse_char_string ($s, @args); |
$return = $self->parse_char_stream ($wrapped_char_stream, @args); |
| 578 |
} catch Whatpm::HTML::RestartParser with { |
} catch Whatpm::HTML::RestartParser with { |
| 579 |
my $charset = shift->{charset}; |
## NOTE: Invoked after {change_encoding}. |
| 580 |
$s = \ (Encode::decode ($charset, $$bytes_s)); |
|
| 581 |
$self->{input_encoding} = $charset; ## TODO: normalize |
if ($e_status & Message::Charset::Info::FALLBACK_ENCODING_IMPL ()) { |
| 582 |
|
$self->{input_encoding} = $charset->get_iana_name; ## TODO: Should we set actual charset decoder's encoding name? |
| 583 |
|
!!!parse-error (type => 'chardecode:fallback', |
| 584 |
|
level => $self->{level}->{uncertain}, |
| 585 |
|
#text => $self->{input_encoding}, |
| 586 |
|
line => 1, column => 1, |
| 587 |
|
layer => 'encode'); |
| 588 |
|
} elsif (not ($e_status & |
| 589 |
|
Message::Charset::Info::ERROR_REPORTING_ENCODING_IMPL())) { |
| 590 |
|
$self->{input_encoding} = $charset->get_iana_name; |
| 591 |
|
!!!parse-error (type => 'chardecode:no error', |
| 592 |
|
text => $self->{input_encoding}, |
| 593 |
|
level => $self->{level}->{uncertain}, |
| 594 |
|
line => 1, column => 1, |
| 595 |
|
layer => 'encode'); |
| 596 |
|
} else { |
| 597 |
|
$self->{input_encoding} = $charset->get_iana_name; |
| 598 |
|
} |
| 599 |
$self->{confident} = 1; |
$self->{confident} = 1; |
| 600 |
$return = $self->parse_char_string ($s, @args); |
|
| 601 |
|
$wrapped_char_stream = $get_wrapper->($char_stream); |
| 602 |
|
$wrapped_char_stream->onerror ($char_onerror); |
| 603 |
|
|
| 604 |
|
$return = $self->parse_char_stream ($wrapped_char_stream, @args); |
| 605 |
}; |
}; |
| 606 |
return $return; |
return $return; |
| 607 |
} # parse_byte_string |
} # parse_byte_stream |
| 608 |
|
|
| 609 |
## NOTE: HTML5 spec says that the encoding layer MUST NOT strip BOM |
## NOTE: HTML5 spec says that the encoding layer MUST NOT strip BOM |
| 610 |
## and the HTML layer MUST ignore it. However, we does strip BOM in |
## and the HTML layer MUST ignore it. However, we does strip BOM in |
| 615 |
## such as |parse_byte_string| in this module, must ensure that it does |
## such as |parse_byte_string| in this module, must ensure that it does |
| 616 |
## strip the BOM and never strip any ZWNBSP. |
## strip the BOM and never strip any ZWNBSP. |
| 617 |
|
|
| 618 |
*parse_char_string = \&parse_string; |
sub parse_char_string ($$$;$$) { |
| 619 |
|
#my ($self, $s, $doc, $onerror, $get_wrapper) = @_; |
| 620 |
|
my $self = shift; |
| 621 |
|
require utf8; |
| 622 |
|
my $s = ref $_[0] ? $_[0] : \($_[0]); |
| 623 |
|
open my $input, '<' . (utf8::is_utf8 ($$s) ? ':utf8' : ''), $s; |
| 624 |
|
if ($_[3]) { |
| 625 |
|
$input = $_[3]->($input); |
| 626 |
|
} |
| 627 |
|
return $self->parse_char_stream ($input, @_[1..$#_]); |
| 628 |
|
} # parse_char_string |
| 629 |
|
*parse_string = \&parse_char_string; ## NOTE: Alias for backward compatibility. |
| 630 |
|
|
| 631 |
sub parse_string ($$$;$) { |
sub parse_char_stream ($$$;$) { |
| 632 |
my $self = ref $_[0] ? shift : shift->new; |
my $self = ref $_[0] ? shift : shift->new; |
| 633 |
my $s = ref $_[0] ? $_[0] : \($_[0]); |
my $input = $_[0]; |
| 634 |
$self->{document} = $_[1]; |
$self->{document} = $_[1]; |
| 635 |
@{$self->{document}->child_nodes} = (); |
@{$self->{document}->child_nodes} = (); |
| 636 |
|
|
| 649 |
pop @{$self->{prev_char}}; |
pop @{$self->{prev_char}}; |
| 650 |
unshift @{$self->{prev_char}}, $self->{next_char}; |
unshift @{$self->{prev_char}}, $self->{next_char}; |
| 651 |
|
|
| 652 |
$self->{next_char} = -1 and return if $i >= length $$s; |
my $char; |
| 653 |
$self->{next_char} = ord substr $$s, $i++, 1; |
if (defined $self->{next_next_char}) { |
| 654 |
|
$char = $self->{next_next_char}; |
| 655 |
|
delete $self->{next_next_char}; |
| 656 |
|
} else { |
| 657 |
|
$char = $input->getc; |
| 658 |
|
} |
| 659 |
|
$self->{next_char} = -1 and return unless defined $char; |
| 660 |
|
$self->{next_char} = ord $char; |
| 661 |
|
|
| 662 |
($self->{line_prev}, $self->{column_prev}) |
($self->{line_prev}, $self->{column_prev}) |
| 663 |
= ($self->{line}, $self->{column}); |
= ($self->{line}, $self->{column}); |
| 664 |
$self->{column}++; |
$self->{column}++; |
| 665 |
|
|
| 666 |
if ($self->{next_char} == 0x000A) { # LF |
if ($self->{next_char} == 0x000A) { # LF |
| 667 |
|
!!!cp ('j1'); |
| 668 |
$self->{line}++; |
$self->{line}++; |
| 669 |
$self->{column} = 0; |
$self->{column} = 0; |
| 670 |
} elsif ($self->{next_char} == 0x000D) { # CR |
} elsif ($self->{next_char} == 0x000D) { # CR |
| 671 |
$i++ if substr ($$s, $i, 1) eq "\x0A"; |
!!!cp ('j2'); |
| 672 |
|
my $next = $input->getc; |
| 673 |
|
if (defined $next and $next ne "\x0A") { |
| 674 |
|
$self->{next_next_char} = $next; |
| 675 |
|
} |
| 676 |
$self->{next_char} = 0x000A; # LF # MUST |
$self->{next_char} = 0x000A; # LF # MUST |
| 677 |
$self->{line}++; |
$self->{line}++; |
| 678 |
$self->{column} = 0; |
$self->{column} = 0; |
| 679 |
} elsif ($self->{next_char} > 0x10FFFF) { |
} elsif ($self->{next_char} > 0x10FFFF) { |
| 680 |
|
!!!cp ('j3'); |
| 681 |
$self->{next_char} = 0xFFFD; # REPLACEMENT CHARACTER # MUST |
$self->{next_char} = 0xFFFD; # REPLACEMENT CHARACTER # MUST |
| 682 |
} elsif ($self->{next_char} == 0x0000) { # NULL |
} elsif ($self->{next_char} == 0x0000) { # NULL |
| 683 |
|
!!!cp ('j4'); |
| 684 |
!!!parse-error (type => 'NULL'); |
!!!parse-error (type => 'NULL'); |
| 685 |
$self->{next_char} = 0xFFFD; # REPLACEMENT CHARACTER # MUST |
$self->{next_char} = 0xFFFD; # REPLACEMENT CHARACTER # MUST |
| 686 |
|
} elsif ($self->{next_char} <= 0x0008 or |
| 687 |
|
(0x000E <= $self->{next_char} and $self->{next_char} <= 0x001F) or |
| 688 |
|
(0x007F <= $self->{next_char} and $self->{next_char} <= 0x009F) or |
| 689 |
|
(0xD800 <= $self->{next_char} and $self->{next_char} <= 0xDFFF) or |
| 690 |
|
(0xFDD0 <= $self->{next_char} and $self->{next_char} <= 0xFDDF) or |
| 691 |
|
{ |
| 692 |
|
0xFFFE => 1, 0xFFFF => 1, 0x1FFFE => 1, 0x1FFFF => 1, |
| 693 |
|
0x2FFFE => 1, 0x2FFFF => 1, 0x3FFFE => 1, 0x3FFFF => 1, |
| 694 |
|
0x4FFFE => 1, 0x4FFFF => 1, 0x5FFFE => 1, 0x5FFFF => 1, |
| 695 |
|
0x6FFFE => 1, 0x6FFFF => 1, 0x7FFFE => 1, 0x7FFFF => 1, |
| 696 |
|
0x8FFFE => 1, 0x8FFFF => 1, 0x9FFFE => 1, 0x9FFFF => 1, |
| 697 |
|
0xAFFFE => 1, 0xAFFFF => 1, 0xBFFFE => 1, 0xBFFFF => 1, |
| 698 |
|
0xCFFFE => 1, 0xCFFFF => 1, 0xDFFFE => 1, 0xDFFFF => 1, |
| 699 |
|
0xEFFFE => 1, 0xEFFFF => 1, 0xFFFFE => 1, 0xFFFFF => 1, |
| 700 |
|
0x10FFFE => 1, 0x10FFFF => 1, |
| 701 |
|
}->{$self->{next_char}}) { |
| 702 |
|
!!!cp ('j5'); |
| 703 |
|
if ($self->{next_char} < 0x10000) { |
| 704 |
|
!!!parse-error (type => 'control char', |
| 705 |
|
text => (sprintf 'U+%04X', $self->{next_char})); |
| 706 |
|
} else { |
| 707 |
|
!!!parse-error (type => 'control char', |
| 708 |
|
text => (sprintf 'U-%08X', $self->{next_char})); |
| 709 |
|
} |
| 710 |
} |
} |
| 711 |
}; |
}; |
| 712 |
$self->{prev_char} = [-1, -1, -1]; |
$self->{prev_char} = [-1, -1, -1]; |
| 730 |
delete $self->{parse_error}; # remove loop |
delete $self->{parse_error}; # remove loop |
| 731 |
|
|
| 732 |
return $self->{document}; |
return $self->{document}; |
| 733 |
} # parse_string |
} # parse_char_stream |
| 734 |
|
|
| 735 |
sub new ($) { |
sub new ($) { |
| 736 |
my $class = shift; |
my $class = shift; |
| 737 |
my $self = bless {}, $class; |
my $self = bless { |
| 738 |
|
level => {must => 'm', |
| 739 |
|
should => 's', |
| 740 |
|
warn => 'w', |
| 741 |
|
info => 'i', |
| 742 |
|
uncertain => 'u'}, |
| 743 |
|
}, $class; |
| 744 |
$self->{set_next_char} = sub { |
$self->{set_next_char} = sub { |
| 745 |
$self->{next_char} = -1; |
$self->{next_char} = -1; |
| 746 |
}; |
}; |
| 804 |
sub AFTER_ATTRIBUTE_VALUE_QUOTED_STATE () { 33 } |
sub AFTER_ATTRIBUTE_VALUE_QUOTED_STATE () { 33 } |
| 805 |
sub SELF_CLOSING_START_TAG_STATE () { 34 } |
sub SELF_CLOSING_START_TAG_STATE () { 34 } |
| 806 |
sub CDATA_BLOCK_STATE () { 35 } |
sub CDATA_BLOCK_STATE () { 35 } |
| 807 |
|
sub MD_HYPHEN_STATE () { 36 } # "markup declaration open state" in the spec |
| 808 |
|
sub MD_DOCTYPE_STATE () { 37 } # "markup declaration open state" in the spec |
| 809 |
|
sub MD_CDATA_STATE () { 38 } # "markup declaration open state" in the spec |
| 810 |
|
sub CDATA_PCDATA_CLOSE_TAG_STATE () { 39 } # "close tag open state" in the spec |
| 811 |
|
|
| 812 |
sub DOCTYPE_TOKEN () { 1 } |
sub DOCTYPE_TOKEN () { 1 } |
| 813 |
sub COMMENT_TOKEN () { 2 } |
sub COMMENT_TOKEN () { 2 } |
| 860 |
sub _initialize_tokenizer ($) { |
sub _initialize_tokenizer ($) { |
| 861 |
my $self = shift; |
my $self = shift; |
| 862 |
$self->{state} = DATA_STATE; # MUST |
$self->{state} = DATA_STATE; # MUST |
| 863 |
|
#$self->{state_keyword}; # initialized when used |
| 864 |
$self->{content_model} = PCDATA_CONTENT_MODEL; # be |
$self->{content_model} = PCDATA_CONTENT_MODEL; # be |
| 865 |
undef $self->{current_token}; # start tag, end tag, comment, or DOCTYPE |
undef $self->{current_token}; # start tag, end tag, comment, or DOCTYPE |
| 866 |
undef $self->{current_attribute}; |
undef $self->{current_attribute}; |
| 891 |
## |->{self_closing}| is used to save the value of |$self->{self_closing}| |
## |->{self_closing}| is used to save the value of |$self->{self_closing}| |
| 892 |
## while the token is pushed back to the stack. |
## while the token is pushed back to the stack. |
| 893 |
|
|
|
## ISSUE: "When a DOCTYPE token is created, its |
|
|
## <i>self-closing flag</i> must be unset (its other state is that it |
|
|
## be set), and its attributes list must be empty.": Wrong subject? |
|
|
|
|
| 894 |
## Emitted token MUST immediately be handled by the tree construction state. |
## Emitted token MUST immediately be handled by the tree construction state. |
| 895 |
|
|
| 896 |
## Before each step, UA MAY check to see if either one of the scripts in |
## Before each step, UA MAY check to see if either one of the scripts in |
| 1106 |
redo A; |
redo A; |
| 1107 |
} else { |
} else { |
| 1108 |
!!!cp (23); |
!!!cp (23); |
| 1109 |
!!!parse-error (type => 'bare stago'); |
!!!parse-error (type => 'bare stago', |
| 1110 |
|
line => $self->{line_prev}, |
| 1111 |
|
column => $self->{column_prev}); |
| 1112 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
| 1113 |
## reconsume |
## reconsume |
| 1114 |
|
|
| 1123 |
die "$0: $self->{content_model} in tag open"; |
die "$0: $self->{content_model} in tag open"; |
| 1124 |
} |
} |
| 1125 |
} elsif ($self->{state} == CLOSE_TAG_OPEN_STATE) { |
} elsif ($self->{state} == CLOSE_TAG_OPEN_STATE) { |
| 1126 |
|
## NOTE: The "close tag open state" in the spec is implemented as |
| 1127 |
|
## |CLOSE_TAG_OPEN_STATE| and |CDATA_PCDATA_CLOSE_TAG_STATE|. |
| 1128 |
|
|
| 1129 |
my ($l, $c) = ($self->{line_prev}, $self->{column_prev} - 1); # "<"of"</" |
my ($l, $c) = ($self->{line_prev}, $self->{column_prev} - 1); # "<"of"</" |
| 1130 |
if ($self->{content_model} & CM_LIMITED_MARKUP) { # RCDATA | CDATA |
if ($self->{content_model} & CM_LIMITED_MARKUP) { # RCDATA | CDATA |
| 1131 |
if (defined $self->{last_emitted_start_tag_name}) { |
if (defined $self->{last_emitted_start_tag_name}) { |
| 1132 |
|
$self->{state} = CDATA_PCDATA_CLOSE_TAG_STATE; |
| 1133 |
## NOTE: <http://krijnhoetmer.nl/irc-logs/whatwg/20070626#l-564> |
$self->{state_keyword} = ''; |
| 1134 |
my @next_char; |
## Reconsume. |
| 1135 |
TAGNAME: for (my $i = 0; $i < length $self->{last_emitted_start_tag_name}; $i++) { |
redo A; |
|
push @next_char, $self->{next_char}; |
|
|
my $c = ord substr ($self->{last_emitted_start_tag_name}, $i, 1); |
|
|
my $C = 0x0061 <= $c && $c <= 0x007A ? $c - 0x0020 : $c; |
|
|
if ($self->{next_char} == $c or $self->{next_char} == $C) { |
|
|
!!!cp (24); |
|
|
!!!next-input-character; |
|
|
next TAGNAME; |
|
|
} else { |
|
|
!!!cp (25); |
|
|
$self->{next_char} = shift @next_char; # reconsume |
|
|
!!!back-next-input-character (@next_char); |
|
|
$self->{state} = DATA_STATE; |
|
|
|
|
|
!!!emit ({type => CHARACTER_TOKEN, data => '</', |
|
|
line => $l, column => $c, |
|
|
}); |
|
|
|
|
|
redo A; |
|
|
} |
|
|
} |
|
|
push @next_char, $self->{next_char}; |
|
|
|
|
|
unless ($self->{next_char} == 0x0009 or # HT |
|
|
$self->{next_char} == 0x000A or # LF |
|
|
$self->{next_char} == 0x000B or # VT |
|
|
$self->{next_char} == 0x000C or # FF |
|
|
$self->{next_char} == 0x0020 or # SP |
|
|
$self->{next_char} == 0x003E or # > |
|
|
$self->{next_char} == 0x002F or # / |
|
|
$self->{next_char} == -1) { |
|
|
!!!cp (26); |
|
|
$self->{next_char} = shift @next_char; # reconsume |
|
|
!!!back-next-input-character (@next_char); |
|
|
$self->{state} = DATA_STATE; |
|
|
!!!emit ({type => CHARACTER_TOKEN, data => '</', |
|
|
line => $l, column => $c, |
|
|
}); |
|
|
redo A; |
|
|
} else { |
|
|
!!!cp (27); |
|
|
$self->{next_char} = shift @next_char; |
|
|
!!!back-next-input-character (@next_char); |
|
|
# and consume... |
|
|
} |
|
| 1136 |
} else { |
} else { |
| 1137 |
## No start tag token has ever been emitted |
## No start tag token has ever been emitted |
| 1138 |
|
## NOTE: See <http://krijnhoetmer.nl/irc-logs/whatwg/20070626#l-564>. |
| 1139 |
!!!cp (28); |
!!!cp (28); |
|
# next-input-character is already done |
|
| 1140 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
| 1141 |
|
## Reconsume. |
| 1142 |
!!!emit ({type => CHARACTER_TOKEN, data => '</', |
!!!emit ({type => CHARACTER_TOKEN, data => '</', |
| 1143 |
line => $l, column => $c, |
line => $l, column => $c, |
| 1144 |
}); |
}); |
| 1145 |
redo A; |
redo A; |
| 1146 |
} |
} |
| 1147 |
} |
} |
| 1148 |
|
|
| 1149 |
if (0x0041 <= $self->{next_char} and |
if (0x0041 <= $self->{next_char} and |
| 1150 |
$self->{next_char} <= 0x005A) { # A..Z |
$self->{next_char} <= 0x005A) { # A..Z |
| 1151 |
!!!cp (29); |
!!!cp (29); |
| 1192 |
line => $self->{line_prev}, # "<" of "</" |
line => $self->{line_prev}, # "<" of "</" |
| 1193 |
column => $self->{column_prev} - 1, |
column => $self->{column_prev} - 1, |
| 1194 |
}; |
}; |
| 1195 |
## $self->{next_char} is intentionally left as is |
## NOTE: $self->{next_char} is intentionally left as is. |
| 1196 |
redo A; |
## Although the "anything else" case of the spec not explicitly |
| 1197 |
|
## states that the next input character is to be reconsumed, |
| 1198 |
|
## it will be included to the |data| of the comment token |
| 1199 |
|
## generated from the bogus end tag, as defined in the |
| 1200 |
|
## "bogus comment state" entry. |
| 1201 |
|
redo A; |
| 1202 |
|
} |
| 1203 |
|
} elsif ($self->{state} == CDATA_PCDATA_CLOSE_TAG_STATE) { |
| 1204 |
|
my $ch = substr $self->{last_emitted_start_tag_name}, length $self->{state_keyword}, 1; |
| 1205 |
|
if (length $ch) { |
| 1206 |
|
my $CH = $ch; |
| 1207 |
|
$ch =~ tr/a-z/A-Z/; |
| 1208 |
|
my $nch = chr $self->{next_char}; |
| 1209 |
|
if ($nch eq $ch or $nch eq $CH) { |
| 1210 |
|
!!!cp (24); |
| 1211 |
|
## Stay in the state. |
| 1212 |
|
$self->{state_keyword} .= $nch; |
| 1213 |
|
!!!next-input-character; |
| 1214 |
|
redo A; |
| 1215 |
|
} else { |
| 1216 |
|
!!!cp (25); |
| 1217 |
|
$self->{state} = DATA_STATE; |
| 1218 |
|
## Reconsume. |
| 1219 |
|
!!!emit ({type => CHARACTER_TOKEN, |
| 1220 |
|
data => '</' . $self->{state_keyword}, |
| 1221 |
|
line => $self->{line_prev}, |
| 1222 |
|
column => $self->{column_prev} - 1 - length $self->{state_keyword}, |
| 1223 |
|
}); |
| 1224 |
|
redo A; |
| 1225 |
|
} |
| 1226 |
|
} else { # after "<{tag-name}" |
| 1227 |
|
unless ({ |
| 1228 |
|
0x0009 => 1, # HT |
| 1229 |
|
0x000A => 1, # LF |
| 1230 |
|
0x000B => 1, # VT |
| 1231 |
|
0x000C => 1, # FF |
| 1232 |
|
0x0020 => 1, # SP |
| 1233 |
|
0x003E => 1, # > |
| 1234 |
|
0x002F => 1, # / |
| 1235 |
|
-1 => 1, # EOF |
| 1236 |
|
}->{$self->{next_char}}) { |
| 1237 |
|
!!!cp (26); |
| 1238 |
|
## Reconsume. |
| 1239 |
|
$self->{state} = DATA_STATE; |
| 1240 |
|
!!!emit ({type => CHARACTER_TOKEN, |
| 1241 |
|
data => '</' . $self->{state_keyword}, |
| 1242 |
|
line => $self->{line_prev}, |
| 1243 |
|
column => $self->{column_prev} - 1 - length $self->{state_keyword}, |
| 1244 |
|
}); |
| 1245 |
|
redo A; |
| 1246 |
|
} else { |
| 1247 |
|
!!!cp (27); |
| 1248 |
|
$self->{current_token} |
| 1249 |
|
= {type => END_TAG_TOKEN, |
| 1250 |
|
tag_name => $self->{last_emitted_start_tag_name}, |
| 1251 |
|
line => $self->{line_prev}, |
| 1252 |
|
column => $self->{column_prev} - 1 - length $self->{state_keyword}}; |
| 1253 |
|
$self->{state} = TAG_NAME_STATE; |
| 1254 |
|
## Reconsume. |
| 1255 |
|
redo A; |
| 1256 |
|
} |
| 1257 |
} |
} |
| 1258 |
} elsif ($self->{state} == TAG_NAME_STATE) { |
} elsif ($self->{state} == TAG_NAME_STATE) { |
| 1259 |
if ($self->{next_char} == 0x0009 or # HT |
if ($self->{next_char} == 0x0009 or # HT |
| 1423 |
if (exists $self->{current_token}->{attributes} # start tag or end tag |
if (exists $self->{current_token}->{attributes} # start tag or end tag |
| 1424 |
->{$self->{current_attribute}->{name}}) { # MUST |
->{$self->{current_attribute}->{name}}) { # MUST |
| 1425 |
!!!cp (57); |
!!!cp (57); |
| 1426 |
!!!parse-error (type => 'duplicate attribute:'.$self->{current_attribute}->{name}, line => $self->{current_attribute}->{line}, column => $self->{current_attribute}->{column}); |
!!!parse-error (type => 'duplicate attribute', text => $self->{current_attribute}->{name}, line => $self->{current_attribute}->{line}, column => $self->{current_attribute}->{column}); |
| 1427 |
## Discard $self->{current_attribute} # MUST |
## Discard $self->{current_attribute} # MUST |
| 1428 |
} else { |
} else { |
| 1429 |
!!!cp (58); |
!!!cp (58); |
| 1594 |
|
|
| 1595 |
redo A; |
redo A; |
| 1596 |
} else { |
} else { |
| 1597 |
!!!cp (82); |
if ($self->{next_char} == 0x0022 or # " |
| 1598 |
|
$self->{next_char} == 0x0027) { # ' |
| 1599 |
|
!!!cp (78); |
| 1600 |
|
!!!parse-error (type => 'bad attribute name'); |
| 1601 |
|
} else { |
| 1602 |
|
!!!cp (82); |
| 1603 |
|
} |
| 1604 |
$self->{current_attribute} |
$self->{current_attribute} |
| 1605 |
= {name => chr ($self->{next_char}), |
= {name => chr ($self->{next_char}), |
| 1606 |
value => '', |
value => '', |
| 1635 |
!!!next-input-character; |
!!!next-input-character; |
| 1636 |
redo A; |
redo A; |
| 1637 |
} elsif ($self->{next_char} == 0x003E) { # > |
} elsif ($self->{next_char} == 0x003E) { # > |
| 1638 |
|
!!!parse-error (type => 'empty unquoted attribute value'); |
| 1639 |
if ($self->{current_token}->{type} == START_TAG_TOKEN) { |
if ($self->{current_token}->{type} == START_TAG_TOKEN) { |
| 1640 |
!!!cp (87); |
!!!cp (87); |
| 1641 |
$self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name}; |
$self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name}; |
| 1912 |
$self->{state} = SELF_CLOSING_START_TAG_STATE; |
$self->{state} = SELF_CLOSING_START_TAG_STATE; |
| 1913 |
!!!next-input-character; |
!!!next-input-character; |
| 1914 |
redo A; |
redo A; |
| 1915 |
|
} elsif ($self->{next_char} == -1) { |
| 1916 |
|
!!!parse-error (type => 'unclosed tag'); |
| 1917 |
|
if ($self->{current_token}->{type} == START_TAG_TOKEN) { |
| 1918 |
|
!!!cp (122.3); |
| 1919 |
|
$self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name}; |
| 1920 |
|
} elsif ($self->{current_token}->{type} == END_TAG_TOKEN) { |
| 1921 |
|
if ($self->{current_token}->{attributes}) { |
| 1922 |
|
!!!cp (122.1); |
| 1923 |
|
!!!parse-error (type => 'end tag attribute'); |
| 1924 |
|
} else { |
| 1925 |
|
## NOTE: This state should never be reached. |
| 1926 |
|
!!!cp (122.2); |
| 1927 |
|
} |
| 1928 |
|
} else { |
| 1929 |
|
die "$0: $self->{current_token}->{type}: Unknown token type"; |
| 1930 |
|
} |
| 1931 |
|
$self->{state} = DATA_STATE; |
| 1932 |
|
## Reconsume. |
| 1933 |
|
!!!emit ($self->{current_token}); # start tag or end tag |
| 1934 |
|
redo A; |
| 1935 |
} else { |
} else { |
| 1936 |
!!!cp ('124.1'); |
!!!cp ('124.1'); |
| 1937 |
!!!parse-error (type => 'no space between attributes'); |
!!!parse-error (type => 'no space between attributes'); |
| 1964 |
!!!emit ($self->{current_token}); # start tag or end tag |
!!!emit ($self->{current_token}); # start tag or end tag |
| 1965 |
|
|
| 1966 |
redo A; |
redo A; |
| 1967 |
|
} elsif ($self->{next_char} == -1) { |
| 1968 |
|
!!!parse-error (type => 'unclosed tag'); |
| 1969 |
|
if ($self->{current_token}->{type} == START_TAG_TOKEN) { |
| 1970 |
|
!!!cp (124.7); |
| 1971 |
|
$self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name}; |
| 1972 |
|
} elsif ($self->{current_token}->{type} == END_TAG_TOKEN) { |
| 1973 |
|
if ($self->{current_token}->{attributes}) { |
| 1974 |
|
!!!cp (124.5); |
| 1975 |
|
!!!parse-error (type => 'end tag attribute'); |
| 1976 |
|
} else { |
| 1977 |
|
## NOTE: This state should never be reached. |
| 1978 |
|
!!!cp (124.6); |
| 1979 |
|
} |
| 1980 |
|
} else { |
| 1981 |
|
die "$0: $self->{current_token}->{type}: Unknown token type"; |
| 1982 |
|
} |
| 1983 |
|
$self->{state} = DATA_STATE; |
| 1984 |
|
## Reconsume. |
| 1985 |
|
!!!emit ($self->{current_token}); # start tag or end tag |
| 1986 |
|
redo A; |
| 1987 |
} else { |
} else { |
| 1988 |
!!!cp ('124.4'); |
!!!cp ('124.4'); |
| 1989 |
!!!parse-error (type => 'nestc'); |
!!!parse-error (type => 'nestc'); |
| 2026 |
die "$0: _get_next_token: unexpected case [BC]"; |
die "$0: _get_next_token: unexpected case [BC]"; |
| 2027 |
} elsif ($self->{state} == MARKUP_DECLARATION_OPEN_STATE) { |
} elsif ($self->{state} == MARKUP_DECLARATION_OPEN_STATE) { |
| 2028 |
## (only happen if PCDATA state) |
## (only happen if PCDATA state) |
|
|
|
|
my ($l, $c) = ($self->{line_prev}, $self->{column_prev} - 1); |
|
|
|
|
|
my @next_char; |
|
|
push @next_char, $self->{next_char}; |
|
| 2029 |
|
|
| 2030 |
if ($self->{next_char} == 0x002D) { # - |
if ($self->{next_char} == 0x002D) { # - |
| 2031 |
|
!!!cp (133); |
| 2032 |
|
$self->{state} = MD_HYPHEN_STATE; |
| 2033 |
!!!next-input-character; |
!!!next-input-character; |
| 2034 |
push @next_char, $self->{next_char}; |
redo A; |
|
if ($self->{next_char} == 0x002D) { # - |
|
|
!!!cp (127); |
|
|
$self->{current_token} = {type => COMMENT_TOKEN, data => '', |
|
|
line => $l, column => $c, |
|
|
}; |
|
|
$self->{state} = COMMENT_START_STATE; |
|
|
!!!next-input-character; |
|
|
redo A; |
|
|
} else { |
|
|
!!!cp (128); |
|
|
} |
|
| 2035 |
} elsif ($self->{next_char} == 0x0044 or # D |
} elsif ($self->{next_char} == 0x0044 or # D |
| 2036 |
$self->{next_char} == 0x0064) { # d |
$self->{next_char} == 0x0064) { # d |
| 2037 |
|
## ASCII case-insensitive. |
| 2038 |
|
!!!cp (130); |
| 2039 |
|
$self->{state} = MD_DOCTYPE_STATE; |
| 2040 |
|
$self->{state_keyword} = chr $self->{next_char}; |
| 2041 |
!!!next-input-character; |
!!!next-input-character; |
| 2042 |
push @next_char, $self->{next_char}; |
redo A; |
|
if ($self->{next_char} == 0x004F or # O |
|
|
$self->{next_char} == 0x006F) { # o |
|
|
!!!next-input-character; |
|
|
push @next_char, $self->{next_char}; |
|
|
if ($self->{next_char} == 0x0043 or # C |
|
|
$self->{next_char} == 0x0063) { # c |
|
|
!!!next-input-character; |
|
|
push @next_char, $self->{next_char}; |
|
|
if ($self->{next_char} == 0x0054 or # T |
|
|
$self->{next_char} == 0x0074) { # t |
|
|
!!!next-input-character; |
|
|
push @next_char, $self->{next_char}; |
|
|
if ($self->{next_char} == 0x0059 or # Y |
|
|
$self->{next_char} == 0x0079) { # y |
|
|
!!!next-input-character; |
|
|
push @next_char, $self->{next_char}; |
|
|
if ($self->{next_char} == 0x0050 or # P |
|
|
$self->{next_char} == 0x0070) { # p |
|
|
!!!next-input-character; |
|
|
push @next_char, $self->{next_char}; |
|
|
if ($self->{next_char} == 0x0045 or # E |
|
|
$self->{next_char} == 0x0065) { # e |
|
|
!!!cp (129); |
|
|
## TODO: What a stupid code this is! |
|
|
$self->{state} = DOCTYPE_STATE; |
|
|
$self->{current_token} = {type => DOCTYPE_TOKEN, |
|
|
quirks => 1, |
|
|
line => $l, column => $c, |
|
|
}; |
|
|
!!!next-input-character; |
|
|
redo A; |
|
|
} else { |
|
|
!!!cp (130); |
|
|
} |
|
|
} else { |
|
|
!!!cp (131); |
|
|
} |
|
|
} else { |
|
|
!!!cp (132); |
|
|
} |
|
|
} else { |
|
|
!!!cp (133); |
|
|
} |
|
|
} else { |
|
|
!!!cp (134); |
|
|
} |
|
|
} else { |
|
|
!!!cp (135); |
|
|
} |
|
| 2043 |
} elsif ($self->{insertion_mode} & IN_FOREIGN_CONTENT_IM and |
} elsif ($self->{insertion_mode} & IN_FOREIGN_CONTENT_IM and |
| 2044 |
$self->{open_elements}->[-1]->[1] & FOREIGN_EL and |
$self->{open_elements}->[-1]->[1] & FOREIGN_EL and |
| 2045 |
$self->{next_char} == 0x005B) { # [ |
$self->{next_char} == 0x005B) { # [ |
| 2046 |
|
!!!cp (135.4); |
| 2047 |
|
$self->{state} = MD_CDATA_STATE; |
| 2048 |
|
$self->{state_keyword} = '['; |
| 2049 |
!!!next-input-character; |
!!!next-input-character; |
| 2050 |
push @next_char, $self->{next_char}; |
redo A; |
|
if ($self->{next_char} == 0x0043) { # C |
|
|
!!!next-input-character; |
|
|
push @next_char, $self->{next_char}; |
|
|
if ($self->{next_char} == 0x0044) { # D |
|
|
!!!next-input-character; |
|
|
push @next_char, $self->{next_char}; |
|
|
if ($self->{next_char} == 0x0041) { # A |
|
|
!!!next-input-character; |
|
|
push @next_char, $self->{next_char}; |
|
|
if ($self->{next_char} == 0x0054) { # T |
|
|
!!!next-input-character; |
|
|
push @next_char, $self->{next_char}; |
|
|
if ($self->{next_char} == 0x0041) { # A |
|
|
!!!next-input-character; |
|
|
push @next_char, $self->{next_char}; |
|
|
if ($self->{next_char} == 0x005B) { # [ |
|
|
!!!cp (135.1); |
|
|
$self->{state} = CDATA_BLOCK_STATE; |
|
|
!!!next-input-character; |
|
|
redo A; |
|
|
} else { |
|
|
!!!cp (135.2); |
|
|
} |
|
|
} else { |
|
|
!!!cp (135.3); |
|
|
} |
|
|
} else { |
|
|
!!!cp (135.4); |
|
|
} |
|
|
} else { |
|
|
!!!cp (135.5); |
|
|
} |
|
|
} else { |
|
|
!!!cp (135.6); |
|
|
} |
|
|
} else { |
|
|
!!!cp (135.7); |
|
|
} |
|
| 2051 |
} else { |
} else { |
| 2052 |
!!!cp (136); |
!!!cp (136); |
| 2053 |
} |
} |
| 2054 |
|
|
| 2055 |
!!!parse-error (type => 'bogus comment'); |
!!!parse-error (type => 'bogus comment', |
| 2056 |
$self->{next_char} = shift @next_char; |
line => $self->{line_prev}, |
| 2057 |
!!!back-next-input-character (@next_char); |
column => $self->{column_prev} - 1); |
| 2058 |
|
## Reconsume. |
| 2059 |
$self->{state} = BOGUS_COMMENT_STATE; |
$self->{state} = BOGUS_COMMENT_STATE; |
| 2060 |
$self->{current_token} = {type => COMMENT_TOKEN, data => '', |
$self->{current_token} = {type => COMMENT_TOKEN, data => '', |
| 2061 |
line => $l, column => $c, |
line => $self->{line_prev}, |
| 2062 |
|
column => $self->{column_prev} - 1, |
| 2063 |
}; |
}; |
| 2064 |
redo A; |
redo A; |
| 2065 |
|
} elsif ($self->{state} == MD_HYPHEN_STATE) { |
| 2066 |
## ISSUE: typos in spec: chacacters, is is a parse error |
if ($self->{next_char} == 0x002D) { # - |
| 2067 |
## ISSUE: spec is somewhat unclear on "is the first character that will be in the comment"; what is "that will be in the comment" is what the algorithm defines, isn't it? |
!!!cp (127); |
| 2068 |
|
$self->{current_token} = {type => COMMENT_TOKEN, data => '', |
| 2069 |
|
line => $self->{line_prev}, |
| 2070 |
|
column => $self->{column_prev} - 2, |
| 2071 |
|
}; |
| 2072 |
|
$self->{state} = COMMENT_START_STATE; |
| 2073 |
|
!!!next-input-character; |
| 2074 |
|
redo A; |
| 2075 |
|
} else { |
| 2076 |
|
!!!cp (128); |
| 2077 |
|
!!!parse-error (type => 'bogus comment', |
| 2078 |
|
line => $self->{line_prev}, |
| 2079 |
|
column => $self->{column_prev} - 2); |
| 2080 |
|
$self->{state} = BOGUS_COMMENT_STATE; |
| 2081 |
|
## Reconsume. |
| 2082 |
|
$self->{current_token} = {type => COMMENT_TOKEN, |
| 2083 |
|
data => '-', |
| 2084 |
|
line => $self->{line_prev}, |
| 2085 |
|
column => $self->{column_prev} - 2, |
| 2086 |
|
}; |
| 2087 |
|
redo A; |
| 2088 |
|
} |
| 2089 |
|
} elsif ($self->{state} == MD_DOCTYPE_STATE) { |
| 2090 |
|
## ASCII case-insensitive. |
| 2091 |
|
if ($self->{next_char} == [ |
| 2092 |
|
undef, |
| 2093 |
|
0x004F, # O |
| 2094 |
|
0x0043, # C |
| 2095 |
|
0x0054, # T |
| 2096 |
|
0x0059, # Y |
| 2097 |
|
0x0050, # P |
| 2098 |
|
]->[length $self->{state_keyword}] or |
| 2099 |
|
$self->{next_char} == [ |
| 2100 |
|
undef, |
| 2101 |
|
0x006F, # o |
| 2102 |
|
0x0063, # c |
| 2103 |
|
0x0074, # t |
| 2104 |
|
0x0079, # y |
| 2105 |
|
0x0070, # p |
| 2106 |
|
]->[length $self->{state_keyword}]) { |
| 2107 |
|
!!!cp (131); |
| 2108 |
|
## Stay in the state. |
| 2109 |
|
$self->{state_keyword} .= chr $self->{next_char}; |
| 2110 |
|
!!!next-input-character; |
| 2111 |
|
redo A; |
| 2112 |
|
} elsif ((length $self->{state_keyword}) == 6 and |
| 2113 |
|
($self->{next_char} == 0x0045 or # E |
| 2114 |
|
$self->{next_char} == 0x0065)) { # e |
| 2115 |
|
!!!cp (129); |
| 2116 |
|
$self->{state} = DOCTYPE_STATE; |
| 2117 |
|
$self->{current_token} = {type => DOCTYPE_TOKEN, |
| 2118 |
|
quirks => 1, |
| 2119 |
|
line => $self->{line_prev}, |
| 2120 |
|
column => $self->{column_prev} - 7, |
| 2121 |
|
}; |
| 2122 |
|
!!!next-input-character; |
| 2123 |
|
redo A; |
| 2124 |
|
} else { |
| 2125 |
|
!!!cp (132); |
| 2126 |
|
!!!parse-error (type => 'bogus comment', |
| 2127 |
|
line => $self->{line_prev}, |
| 2128 |
|
column => $self->{column_prev} - 1 - length $self->{state_keyword}); |
| 2129 |
|
$self->{state} = BOGUS_COMMENT_STATE; |
| 2130 |
|
## Reconsume. |
| 2131 |
|
$self->{current_token} = {type => COMMENT_TOKEN, |
| 2132 |
|
data => $self->{state_keyword}, |
| 2133 |
|
line => $self->{line_prev}, |
| 2134 |
|
column => $self->{column_prev} - 1 - length $self->{state_keyword}, |
| 2135 |
|
}; |
| 2136 |
|
redo A; |
| 2137 |
|
} |
| 2138 |
|
} elsif ($self->{state} == MD_CDATA_STATE) { |
| 2139 |
|
if ($self->{next_char} == { |
| 2140 |
|
'[' => 0x0043, # C |
| 2141 |
|
'[C' => 0x0044, # D |
| 2142 |
|
'[CD' => 0x0041, # A |
| 2143 |
|
'[CDA' => 0x0054, # T |
| 2144 |
|
'[CDAT' => 0x0041, # A |
| 2145 |
|
}->{$self->{state_keyword}}) { |
| 2146 |
|
!!!cp (135.1); |
| 2147 |
|
## Stay in the state. |
| 2148 |
|
$self->{state_keyword} .= chr $self->{next_char}; |
| 2149 |
|
!!!next-input-character; |
| 2150 |
|
redo A; |
| 2151 |
|
} elsif ($self->{state_keyword} eq '[CDATA' and |
| 2152 |
|
$self->{next_char} == 0x005B) { # [ |
| 2153 |
|
!!!cp (135.2); |
| 2154 |
|
$self->{state} = CDATA_BLOCK_STATE; |
| 2155 |
|
!!!next-input-character; |
| 2156 |
|
redo A; |
| 2157 |
|
} else { |
| 2158 |
|
!!!cp (135.3); |
| 2159 |
|
!!!parse-error (type => 'bogus comment', |
| 2160 |
|
line => $self->{line_prev}, |
| 2161 |
|
column => $self->{column_prev} - 1 - length $self->{state_keyword}); |
| 2162 |
|
$self->{state} = BOGUS_COMMENT_STATE; |
| 2163 |
|
## Reconsume. |
| 2164 |
|
$self->{current_token} = {type => COMMENT_TOKEN, |
| 2165 |
|
data => $self->{state_keyword}, |
| 2166 |
|
line => $self->{line_prev}, |
| 2167 |
|
column => $self->{column_prev} - 1 - length $self->{state_keyword}, |
| 2168 |
|
}; |
| 2169 |
|
redo A; |
| 2170 |
|
} |
| 2171 |
} elsif ($self->{state} == COMMENT_START_STATE) { |
} elsif ($self->{state} == COMMENT_START_STATE) { |
| 2172 |
if ($self->{next_char} == 0x002D) { # - |
if ($self->{next_char} == 0x002D) { # - |
| 2173 |
!!!cp (137); |
!!!cp (137); |
| 2752 |
redo A; |
redo A; |
| 2753 |
} elsif ($self->{next_char} == 0x003E) { # > |
} elsif ($self->{next_char} == 0x003E) { # > |
| 2754 |
!!!cp (208); |
!!!cp (208); |
| 2755 |
!!!parse-error (type => 'unclosed PUBLIC literal'); |
!!!parse-error (type => 'unclosed SYSTEM literal'); |
| 2756 |
|
|
| 2757 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
| 2758 |
!!!next-input-character; |
!!!next-input-character; |
| 2788 |
redo A; |
redo A; |
| 2789 |
} elsif ($self->{next_char} == 0x003E) { # > |
} elsif ($self->{next_char} == 0x003E) { # > |
| 2790 |
!!!cp (212); |
!!!cp (212); |
| 2791 |
!!!parse-error (type => 'unclosed PUBLIC literal'); |
!!!parse-error (type => 'unclosed SYSTEM literal'); |
| 2792 |
|
|
| 2793 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
| 2794 |
!!!next-input-character; |
!!!next-input-character; |
| 2836 |
} elsif ($self->{next_char} == -1) { |
} elsif ($self->{next_char} == -1) { |
| 2837 |
!!!cp (217); |
!!!cp (217); |
| 2838 |
!!!parse-error (type => 'unclosed DOCTYPE'); |
!!!parse-error (type => 'unclosed DOCTYPE'); |
|
|
|
| 2839 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
| 2840 |
## reconsume |
## reconsume |
| 2841 |
|
|
| 2997 |
|
|
| 2998 |
if ($code == 0 or (0xD800 <= $code and $code <= 0xDFFF)) { |
if ($code == 0 or (0xD800 <= $code and $code <= 0xDFFF)) { |
| 2999 |
!!!cp (1008); |
!!!cp (1008); |
| 3000 |
!!!parse-error (type => (sprintf 'invalid character reference:U+%04X', $code), line => $l, column => $c); |
!!!parse-error (type => 'invalid character reference', |
| 3001 |
|
text => (sprintf 'U+%04X', $code), |
| 3002 |
|
line => $l, column => $c); |
| 3003 |
$code = 0xFFFD; |
$code = 0xFFFD; |
| 3004 |
} elsif ($code > 0x10FFFF) { |
} elsif ($code > 0x10FFFF) { |
| 3005 |
!!!cp (1009); |
!!!cp (1009); |
| 3006 |
!!!parse-error (type => (sprintf 'invalid character reference:U-%08X', $code), line => $l, column => $c); |
!!!parse-error (type => 'invalid character reference', |
| 3007 |
|
text => (sprintf 'U-%08X', $code), |
| 3008 |
|
line => $l, column => $c); |
| 3009 |
$code = 0xFFFD; |
$code = 0xFFFD; |
| 3010 |
} elsif ($code == 0x000D) { |
} elsif ($code == 0x000D) { |
| 3011 |
!!!cp (1010); |
!!!cp (1010); |
| 3013 |
$code = 0x000A; |
$code = 0x000A; |
| 3014 |
} elsif (0x80 <= $code and $code <= 0x9F) { |
} elsif (0x80 <= $code and $code <= 0x9F) { |
| 3015 |
!!!cp (1011); |
!!!cp (1011); |
| 3016 |
!!!parse-error (type => (sprintf 'C1 character reference:U+%04X', $code), line => $l, column => $c); |
!!!parse-error (type => 'C1 character reference', text => (sprintf 'U+%04X', $code), line => $l, column => $c); |
| 3017 |
$code = $c1_entity_char->{$code}; |
$code = $c1_entity_char->{$code}; |
| 3018 |
} |
} |
| 3019 |
|
|
| 3046 |
|
|
| 3047 |
if ($code == 0 or (0xD800 <= $code and $code <= 0xDFFF)) { |
if ($code == 0 or (0xD800 <= $code and $code <= 0xDFFF)) { |
| 3048 |
!!!cp (1015); |
!!!cp (1015); |
| 3049 |
!!!parse-error (type => (sprintf 'invalid character reference:U+%04X', $code), line => $l, column => $c); |
!!!parse-error (type => 'invalid character reference', |
| 3050 |
|
text => (sprintf 'U+%04X', $code), |
| 3051 |
|
line => $l, column => $c); |
| 3052 |
$code = 0xFFFD; |
$code = 0xFFFD; |
| 3053 |
} elsif ($code > 0x10FFFF) { |
} elsif ($code > 0x10FFFF) { |
| 3054 |
!!!cp (1016); |
!!!cp (1016); |
| 3055 |
!!!parse-error (type => (sprintf 'invalid character reference:U-%08X', $code), line => $l, column => $c); |
!!!parse-error (type => 'invalid character reference', |
| 3056 |
|
text => (sprintf 'U-%08X', $code), |
| 3057 |
|
line => $l, column => $c); |
| 3058 |
$code = 0xFFFD; |
$code = 0xFFFD; |
| 3059 |
} elsif ($code == 0x000D) { |
} elsif ($code == 0x000D) { |
| 3060 |
!!!cp (1017); |
!!!cp (1017); |
| 3061 |
!!!parse-error (type => 'CR character reference', line => $l, column => $c); |
!!!parse-error (type => 'CR character reference', |
| 3062 |
|
line => $l, column => $c); |
| 3063 |
$code = 0x000A; |
$code = 0x000A; |
| 3064 |
} elsif (0x80 <= $code and $code <= 0x9F) { |
} elsif (0x80 <= $code and $code <= 0x9F) { |
| 3065 |
!!!cp (1018); |
!!!cp (1018); |
| 3066 |
!!!parse-error (type => (sprintf 'C1 character reference:U+%04X', $code), line => $l, column => $c); |
!!!parse-error (type => 'C1 character reference', |
| 3067 |
|
text => (sprintf 'U+%04X', $code), |
| 3068 |
|
line => $l, column => $c); |
| 3069 |
$code = $c1_entity_char->{$code}; |
$code = $c1_entity_char->{$code}; |
| 3070 |
} |
} |
| 3071 |
|
|
| 3163 |
## TODO: Turn mutation events off # MUST |
## TODO: Turn mutation events off # MUST |
| 3164 |
## TODO: Turn loose Document option (manakai extension) on |
## TODO: Turn loose Document option (manakai extension) on |
| 3165 |
$self->{document}->manakai_is_html (1); # MUST |
$self->{document}->manakai_is_html (1); # MUST |
| 3166 |
|
$self->{document}->set_user_data (manakai_source_line => 1); |
| 3167 |
|
$self->{document}->set_user_data (manakai_source_column => 1); |
| 3168 |
} # _initialize_tree_constructor |
} # _initialize_tree_constructor |
| 3169 |
|
|
| 3170 |
sub _terminate_tree_constructor ($) { |
sub _terminate_tree_constructor ($) { |
| 3219 |
## language. |
## language. |
| 3220 |
my $doctype_name = $token->{name}; |
my $doctype_name = $token->{name}; |
| 3221 |
$doctype_name = '' unless defined $doctype_name; |
$doctype_name = '' unless defined $doctype_name; |
| 3222 |
$doctype_name =~ tr/a-z/A-Z/; |
$doctype_name =~ tr/a-z/A-Z/; # ASCII case-insensitive |
| 3223 |
if (not defined $token->{name} or # <!DOCTYPE> |
if (not defined $token->{name} or # <!DOCTYPE> |
|
defined $token->{public_identifier} or |
|
| 3224 |
defined $token->{system_identifier}) { |
defined $token->{system_identifier}) { |
| 3225 |
!!!cp ('t1'); |
!!!cp ('t1'); |
| 3226 |
!!!parse-error (type => 'not HTML5', token => $token); |
!!!parse-error (type => 'not HTML5', token => $token); |
| 3227 |
} elsif ($doctype_name ne 'HTML') { |
} elsif ($doctype_name ne 'HTML') { |
| 3228 |
!!!cp ('t2'); |
!!!cp ('t2'); |
|
## ISSUE: ASCII case-insensitive? (in fact it does not matter) |
|
| 3229 |
!!!parse-error (type => 'not HTML5', token => $token); |
!!!parse-error (type => 'not HTML5', token => $token); |
| 3230 |
|
} elsif (defined $token->{public_identifier}) { |
| 3231 |
|
if ($token->{public_identifier} eq 'XSLT-compat') { |
| 3232 |
|
!!!cp ('t1.2'); |
| 3233 |
|
!!!parse-error (type => 'XSLT-compat', token => $token, |
| 3234 |
|
level => $self->{level}->{should}); |
| 3235 |
|
} else { |
| 3236 |
|
!!!parse-error (type => 'not HTML5', token => $token); |
| 3237 |
|
} |
| 3238 |
} else { |
} else { |
| 3239 |
!!!cp ('t3'); |
!!!cp ('t3'); |
| 3240 |
|
# |
| 3241 |
} |
} |
| 3242 |
|
|
| 3243 |
my $doctype = $self->{document}->create_document_type_definition |
my $doctype = $self->{document}->create_document_type_definition |
| 3258 |
} elsif (defined $token->{public_identifier}) { |
} elsif (defined $token->{public_identifier}) { |
| 3259 |
my $pubid = $token->{public_identifier}; |
my $pubid = $token->{public_identifier}; |
| 3260 |
$pubid =~ tr/a-z/A-z/; |
$pubid =~ tr/a-z/A-z/; |
| 3261 |
if ({ |
my $prefix = [ |
| 3262 |
"+//SILMARIL//DTD HTML PRO V0R11 19970101//EN" => 1, |
"+//SILMARIL//DTD HTML PRO V0R11 19970101//", |
| 3263 |
"-//ADVASOFT LTD//DTD HTML 3.0 ASWEDIT + EXTENSIONS//EN" => 1, |
"-//ADVASOFT LTD//DTD HTML 3.0 ASWEDIT + EXTENSIONS//", |
| 3264 |
"-//AS//DTD HTML 3.0 ASWEDIT + EXTENSIONS//EN" => 1, |
"-//AS//DTD HTML 3.0 ASWEDIT + EXTENSIONS//", |
| 3265 |
"-//IETF//DTD HTML 2.0 LEVEL 1//EN" => 1, |
"-//IETF//DTD HTML 2.0 LEVEL 1//", |
| 3266 |
"-//IETF//DTD HTML 2.0 LEVEL 2//EN" => 1, |
"-//IETF//DTD HTML 2.0 LEVEL 2//", |
| 3267 |
"-//IETF//DTD HTML 2.0 STRICT LEVEL 1//EN" => 1, |
"-//IETF//DTD HTML 2.0 STRICT LEVEL 1//", |
| 3268 |
"-//IETF//DTD HTML 2.0 STRICT LEVEL 2//EN" => 1, |
"-//IETF//DTD HTML 2.0 STRICT LEVEL 2//", |
| 3269 |
"-//IETF//DTD HTML 2.0 STRICT//EN" => 1, |
"-//IETF//DTD HTML 2.0 STRICT//", |
| 3270 |
"-//IETF//DTD HTML 2.0//EN" => 1, |
"-//IETF//DTD HTML 2.0//", |
| 3271 |
"-//IETF//DTD HTML 2.1E//EN" => 1, |
"-//IETF//DTD HTML 2.1E//", |
| 3272 |
"-//IETF//DTD HTML 3.0//EN" => 1, |
"-//IETF//DTD HTML 3.0//", |
| 3273 |
"-//IETF//DTD HTML 3.0//EN//" => 1, |
"-//IETF//DTD HTML 3.2 FINAL//", |
| 3274 |
"-//IETF//DTD HTML 3.2 FINAL//EN" => 1, |
"-//IETF//DTD HTML 3.2//", |
| 3275 |
"-//IETF//DTD HTML 3.2//EN" => 1, |
"-//IETF//DTD HTML 3//", |
| 3276 |
"-//IETF//DTD HTML 3//EN" => 1, |
"-//IETF//DTD HTML LEVEL 0//", |
| 3277 |
"-//IETF//DTD HTML LEVEL 0//EN" => 1, |
"-//IETF//DTD HTML LEVEL 1//", |
| 3278 |
"-//IETF//DTD HTML LEVEL 0//EN//2.0" => 1, |
"-//IETF//DTD HTML LEVEL 2//", |
| 3279 |
"-//IETF//DTD HTML LEVEL 1//EN" => 1, |
"-//IETF//DTD HTML LEVEL 3//", |
| 3280 |
"-//IETF//DTD HTML LEVEL 1//EN//2.0" => 1, |
"-//IETF//DTD HTML STRICT LEVEL 0//", |
| 3281 |
"-//IETF//DTD HTML LEVEL 2//EN" => 1, |
"-//IETF//DTD HTML STRICT LEVEL 1//", |
| 3282 |
"-//IETF//DTD HTML LEVEL 2//EN//2.0" => 1, |
"-//IETF//DTD HTML STRICT LEVEL 2//", |
| 3283 |
"-//IETF//DTD HTML LEVEL 3//EN" => 1, |
"-//IETF//DTD HTML STRICT LEVEL 3//", |
| 3284 |
"-//IETF//DTD HTML LEVEL 3//EN//3.0" => 1, |
"-//IETF//DTD HTML STRICT//", |
| 3285 |
"-//IETF//DTD HTML STRICT LEVEL 0//EN" => 1, |
"-//IETF//DTD HTML//", |
| 3286 |
"-//IETF//DTD HTML STRICT LEVEL 0//EN//2.0" => 1, |
"-//METRIUS//DTD METRIUS PRESENTATIONAL//", |
| 3287 |
"-//IETF//DTD HTML STRICT LEVEL 1//EN" => 1, |
"-//MICROSOFT//DTD INTERNET EXPLORER 2.0 HTML STRICT//", |
| 3288 |
"-//IETF//DTD HTML STRICT LEVEL 1//EN//2.0" => 1, |
"-//MICROSOFT//DTD INTERNET EXPLORER 2.0 HTML//", |
| 3289 |
"-//IETF//DTD HTML STRICT LEVEL 2//EN" => 1, |
"-//MICROSOFT//DTD INTERNET EXPLORER 2.0 TABLES//", |
| 3290 |
"-//IETF//DTD HTML STRICT LEVEL 2//EN//2.0" => 1, |
"-//MICROSOFT//DTD INTERNET EXPLORER 3.0 HTML STRICT//", |
| 3291 |
"-//IETF//DTD HTML STRICT LEVEL 3//EN" => 1, |
"-//MICROSOFT//DTD INTERNET EXPLORER 3.0 HTML//", |
| 3292 |
"-//IETF//DTD HTML STRICT LEVEL 3//EN//3.0" => 1, |
"-//MICROSOFT//DTD INTERNET EXPLORER 3.0 TABLES//", |
| 3293 |
"-//IETF//DTD HTML STRICT//EN" => 1, |
"-//NETSCAPE COMM. CORP.//DTD HTML//", |
| 3294 |
"-//IETF//DTD HTML STRICT//EN//2.0" => 1, |
"-//NETSCAPE COMM. CORP.//DTD STRICT HTML//", |
| 3295 |
"-//IETF//DTD HTML STRICT//EN//3.0" => 1, |
"-//O'REILLY AND ASSOCIATES//DTD HTML 2.0//", |
| 3296 |
"-//IETF//DTD HTML//EN" => 1, |
"-//O'REILLY AND ASSOCIATES//DTD HTML EXTENDED 1.0//", |
| 3297 |
"-//IETF//DTD HTML//EN//2.0" => 1, |
"-//O'REILLY AND ASSOCIATES//DTD HTML EXTENDED RELAXED 1.0//", |
| 3298 |
"-//IETF//DTD HTML//EN//3.0" => 1, |
"-//SOFTQUAD SOFTWARE//DTD HOTMETAL PRO 6.0::19990601::EXTENSIONS TO HTML 4.0//", |
| 3299 |
"-//METRIUS//DTD METRIUS PRESENTATIONAL//EN" => 1, |
"-//SOFTQUAD//DTD HOTMETAL PRO 4.0::19971010::EXTENSIONS TO HTML 4.0//", |
| 3300 |
"-//MICROSOFT//DTD INTERNET EXPLORER 2.0 HTML STRICT//EN" => 1, |
"-//SPYGLASS//DTD HTML 2.0 EXTENDED//", |
| 3301 |
"-//MICROSOFT//DTD INTERNET EXPLORER 2.0 HTML//EN" => 1, |
"-//SQ//DTD HTML 2.0 HOTMETAL + EXTENSIONS//", |
| 3302 |
"-//MICROSOFT//DTD INTERNET EXPLORER 2.0 TABLES//EN" => 1, |
"-//SUN MICROSYSTEMS CORP.//DTD HOTJAVA HTML//", |
| 3303 |
"-//MICROSOFT//DTD INTERNET EXPLORER 3.0 HTML STRICT//EN" => 1, |
"-//SUN MICROSYSTEMS CORP.//DTD HOTJAVA STRICT HTML//", |
| 3304 |
"-//MICROSOFT//DTD INTERNET EXPLORER 3.0 HTML//EN" => 1, |
"-//W3C//DTD HTML 3 1995-03-24//", |
| 3305 |
"-//MICROSOFT//DTD INTERNET EXPLORER 3.0 TABLES//EN" => 1, |
"-//W3C//DTD HTML 3.2 DRAFT//", |
| 3306 |
"-//NETSCAPE COMM. CORP.//DTD HTML//EN" => 1, |
"-//W3C//DTD HTML 3.2 FINAL//", |
| 3307 |
"-//NETSCAPE COMM. CORP.//DTD STRICT HTML//EN" => 1, |
"-//W3C//DTD HTML 3.2//", |
| 3308 |
"-//O'REILLY AND ASSOCIATES//DTD HTML 2.0//EN" => 1, |
"-//W3C//DTD HTML 3.2S DRAFT//", |
| 3309 |
"-//O'REILLY AND ASSOCIATES//DTD HTML EXTENDED 1.0//EN" => 1, |
"-//W3C//DTD HTML 4.0 FRAMESET//", |
| 3310 |
"-//O'REILLY AND ASSOCIATES//DTD HTML EXTENDED RELAXED 1.0//EN" => 1, |
"-//W3C//DTD HTML 4.0 TRANSITIONAL//", |
| 3311 |
"-//SOFTQUAD SOFTWARE//DTD HOTMETAL PRO 6.0::19990601::EXTENSIONS TO HTML 4.0//EN" => 1, |
"-//W3C//DTD HTML EXPERIMETNAL 19960712//", |
| 3312 |
"-//SOFTQUAD//DTD HOTMETAL PRO 4.0::19971010::EXTENSIONS TO HTML 4.0//EN" => 1, |
"-//W3C//DTD HTML EXPERIMENTAL 970421//", |
| 3313 |
"-//SPYGLASS//DTD HTML 2.0 EXTENDED//EN" => 1, |
"-//W3C//DTD W3 HTML//", |
| 3314 |
"-//SQ//DTD HTML 2.0 HOTMETAL + EXTENSIONS//EN" => 1, |
"-//W3O//DTD W3 HTML 3.0//", |
| 3315 |
"-//SUN MICROSYSTEMS CORP.//DTD HOTJAVA HTML//EN" => 1, |
"-//WEBTECHS//DTD MOZILLA HTML 2.0//", |
| 3316 |
"-//SUN MICROSYSTEMS CORP.//DTD HOTJAVA STRICT HTML//EN" => 1, |
"-//WEBTECHS//DTD MOZILLA HTML//", |
| 3317 |
"-//W3C//DTD HTML 3 1995-03-24//EN" => 1, |
]; # $prefix |
| 3318 |
"-//W3C//DTD HTML 3.2 DRAFT//EN" => 1, |
my $match; |
| 3319 |
"-//W3C//DTD HTML 3.2 FINAL//EN" => 1, |
for (@$prefix) { |
| 3320 |
"-//W3C//DTD HTML 3.2//EN" => 1, |
if (substr ($prefix, 0, length $_) eq $_) { |
| 3321 |
"-//W3C//DTD HTML 3.2S DRAFT//EN" => 1, |
$match = 1; |
| 3322 |
"-//W3C//DTD HTML 4.0 FRAMESET//EN" => 1, |
last; |
| 3323 |
"-//W3C//DTD HTML 4.0 TRANSITIONAL//EN" => 1, |
} |
| 3324 |
"-//W3C//DTD HTML EXPERIMETNAL 19960712//EN" => 1, |
} |
| 3325 |
"-//W3C//DTD HTML EXPERIMENTAL 970421//EN" => 1, |
if ($match or |
| 3326 |
"-//W3C//DTD W3 HTML//EN" => 1, |
$pubid eq "-//W3O//DTD W3 HTML STRICT 3.0//EN//" or |
| 3327 |
"-//W3O//DTD W3 HTML 3.0//EN" => 1, |
$pubid eq "-/W3C/DTD HTML 4.0 TRANSITIONAL/EN" or |
| 3328 |
"-//W3O//DTD W3 HTML 3.0//EN//" => 1, |
$pubid eq "HTML") { |
|
"-//W3O//DTD W3 HTML STRICT 3.0//EN//" => 1, |
|
|
"-//WEBTECHS//DTD MOZILLA HTML 2.0//EN" => 1, |
|
|
"-//WEBTECHS//DTD MOZILLA HTML//EN" => 1, |
|
|
"-/W3C/DTD HTML 4.0 TRANSITIONAL/EN" => 1, |
|
|
"HTML" => 1, |
|
|
}->{$pubid}) { |
|
| 3329 |
!!!cp ('t5'); |
!!!cp ('t5'); |
| 3330 |
$self->{document}->manakai_compat_mode ('quirks'); |
$self->{document}->manakai_compat_mode ('quirks'); |
| 3331 |
} elsif ($pubid eq "-//W3C//DTD HTML 4.01 FRAMESET//EN" or |
} elsif ($pubid =~ m[^-//W3C//DTD HTML 4.01 FRAMESET//] or |
| 3332 |
$pubid eq "-//W3C//DTD HTML 4.01 TRANSITIONAL//EN") { |
$pubid =~ m[^-//W3C//DTD HTML 4.01 TRANSITIONAL//]) { |
| 3333 |
if (defined $token->{system_identifier}) { |
if (defined $token->{system_identifier}) { |
| 3334 |
!!!cp ('t6'); |
!!!cp ('t6'); |
| 3335 |
$self->{document}->manakai_compat_mode ('quirks'); |
$self->{document}->manakai_compat_mode ('quirks'); |
| 3337 |
!!!cp ('t7'); |
!!!cp ('t7'); |
| 3338 |
$self->{document}->manakai_compat_mode ('limited quirks'); |
$self->{document}->manakai_compat_mode ('limited quirks'); |
| 3339 |
} |
} |
| 3340 |
} elsif ($pubid eq "-//W3C//DTD XHTML 1.0 FRAMESET//EN" or |
} elsif ($pubid =~ m[^-//W3C//DTD XHTML 1.0 FRAMESET//] or |
| 3341 |
$pubid eq "-//W3C//DTD XHTML 1.0 TRANSITIONAL//EN") { |
$pubid =~ m[^-//W3C//DTD XHTML 1.0 TRANSITIONAL//]) { |
| 3342 |
!!!cp ('t8'); |
!!!cp ('t8'); |
| 3343 |
$self->{document}->manakai_compat_mode ('limited quirks'); |
$self->{document}->manakai_compat_mode ('limited quirks'); |
| 3344 |
} else { |
} else { |
| 3351 |
my $sysid = $token->{system_identifier}; |
my $sysid = $token->{system_identifier}; |
| 3352 |
$sysid =~ tr/A-Z/a-z/; |
$sysid =~ tr/A-Z/a-z/; |
| 3353 |
if ($sysid eq "http://www.ibm.com/data/dtd/v11/ibmxhtml1-transitional.dtd") { |
if ($sysid eq "http://www.ibm.com/data/dtd/v11/ibmxhtml1-transitional.dtd") { |
| 3354 |
## TODO: Check the spec: PUBLIC "(limited quirks)" "(quirks)" |
## NOTE: Ensure that |PUBLIC "(limited quirks)" "(quirks)"| is |
| 3355 |
|
## marked as quirks. |
| 3356 |
$self->{document}->manakai_compat_mode ('quirks'); |
$self->{document}->manakai_compat_mode ('quirks'); |
| 3357 |
!!!cp ('t11'); |
!!!cp ('t11'); |
| 3358 |
} else { |
} else { |
| 3524 |
if ($self->{open_elements}->[0]->[0] eq $node->[0]) { |
if ($self->{open_elements}->[0]->[0] eq $node->[0]) { |
| 3525 |
$last = 1; |
$last = 1; |
| 3526 |
if (defined $self->{inner_html_node}) { |
if (defined $self->{inner_html_node}) { |
| 3527 |
if ($self->{inner_html_node}->[1] & TABLE_CELL_EL) { |
!!!cp ('t28'); |
| 3528 |
!!!cp ('t27'); |
$node = $self->{inner_html_node}; |
| 3529 |
# |
} else { |
| 3530 |
} else { |
die "_reset_insertion_mode: t27"; |
|
!!!cp ('t28'); |
|
|
$node = $self->{inner_html_node}; |
|
|
} |
|
| 3531 |
} |
} |
| 3532 |
} |
} |
| 3533 |
|
|
| 3534 |
## Step 4..14 |
## Step 4..14 |
| 3535 |
my $new_mode; |
my $new_mode; |
| 3536 |
if ($node->[1] & FOREIGN_EL) { |
if ($node->[1] & FOREIGN_EL) { |
| 3537 |
## NOTE: Strictly spaking, the line below only applies to MathML and |
!!!cp ('t28.1'); |
| 3538 |
## SVG elements. Currently the HTML syntax supports only MathML and |
## NOTE: Strictly spaking, the line below only applies to MathML and |
| 3539 |
## SVG elements as foreigners. |
## SVG elements. Currently the HTML syntax supports only MathML and |
| 3540 |
$new_mode = $self->{insertion_mode} | IN_FOREIGN_CONTENT_IM; |
## SVG elements as foreigners. |
| 3541 |
## ISSUE: What is set as the secondary insertion mode? |
$new_mode = IN_BODY_IM | IN_FOREIGN_CONTENT_IM; |
| 3542 |
} else { |
} elsif ($node->[1] & TABLE_CELL_EL) { |
| 3543 |
$new_mode = { |
if ($last) { |
| 3544 |
|
!!!cp ('t28.2'); |
| 3545 |
|
# |
| 3546 |
|
} else { |
| 3547 |
|
!!!cp ('t28.3'); |
| 3548 |
|
$new_mode = IN_CELL_IM; |
| 3549 |
|
} |
| 3550 |
|
} else { |
| 3551 |
|
!!!cp ('t28.4'); |
| 3552 |
|
$new_mode = { |
| 3553 |
select => IN_SELECT_IM, |
select => IN_SELECT_IM, |
| 3554 |
## NOTE: |option| and |optgroup| do not set |
## NOTE: |option| and |optgroup| do not set |
| 3555 |
## insertion mode to "in select" by themselves. |
## insertion mode to "in select" by themselves. |
|
td => IN_CELL_IM, |
|
|
th => IN_CELL_IM, |
|
| 3556 |
tr => IN_ROW_IM, |
tr => IN_ROW_IM, |
| 3557 |
tbody => IN_TABLE_BODY_IM, |
tbody => IN_TABLE_BODY_IM, |
| 3558 |
thead => IN_TABLE_BODY_IM, |
thead => IN_TABLE_BODY_IM, |
| 3564 |
body => IN_BODY_IM, |
body => IN_BODY_IM, |
| 3565 |
frameset => IN_FRAMESET_IM, |
frameset => IN_FRAMESET_IM, |
| 3566 |
}->{$node->[0]->manakai_local_name}; |
}->{$node->[0]->manakai_local_name}; |
| 3567 |
} |
} |
| 3568 |
$self->{insertion_mode} = $new_mode and return if defined $new_mode; |
$self->{insertion_mode} = $new_mode and return if defined $new_mode; |
| 3569 |
|
|
| 3570 |
## Step 15 |
## Step 15 |
| 3571 |
if ($node->[1] & HTML_EL) { |
if ($node->[1] & HTML_EL) { |
| 3739 |
## NOTE: An end-of-file token. |
## NOTE: An end-of-file token. |
| 3740 |
if ($content_model_flag == CDATA_CONTENT_MODEL) { |
if ($content_model_flag == CDATA_CONTENT_MODEL) { |
| 3741 |
!!!cp ('t43'); |
!!!cp ('t43'); |
| 3742 |
!!!parse-error (type => 'in CDATA:#'.$token->{type}, token => $token); |
!!!parse-error (type => 'in CDATA:#eof', token => $token); |
| 3743 |
} elsif ($content_model_flag == RCDATA_CONTENT_MODEL) { |
} elsif ($content_model_flag == RCDATA_CONTENT_MODEL) { |
| 3744 |
!!!cp ('t44'); |
!!!cp ('t44'); |
| 3745 |
!!!parse-error (type => 'in RCDATA:#'.$token->{type}, token => $token); |
!!!parse-error (type => 'in RCDATA:#eof', token => $token); |
| 3746 |
} else { |
} else { |
| 3747 |
die "$0: $content_model_flag in parse_rcdata"; |
die "$0: $content_model_flag in parse_rcdata"; |
| 3748 |
} |
} |
| 3779 |
## Ignore the token |
## Ignore the token |
| 3780 |
} else { |
} else { |
| 3781 |
!!!cp ('t48'); |
!!!cp ('t48'); |
| 3782 |
!!!parse-error (type => 'in CDATA:#'.$token->{type}, token => $token); |
!!!parse-error (type => 'in CDATA:#eof', token => $token); |
| 3783 |
## ISSUE: And ignore? |
## ISSUE: And ignore? |
| 3784 |
## TODO: mark as "already executed" |
## TODO: mark as "already executed" |
| 3785 |
} |
} |
| 3830 |
} # AFE |
} # AFE |
| 3831 |
unless (defined $formatting_element) { |
unless (defined $formatting_element) { |
| 3832 |
!!!cp ('t53'); |
!!!cp ('t53'); |
| 3833 |
!!!parse-error (type => 'unmatched end tag:'.$tag_name, token => $end_tag_token); |
!!!parse-error (type => 'unmatched end tag', text => $tag_name, token => $end_tag_token); |
| 3834 |
## Ignore the token |
## Ignore the token |
| 3835 |
!!!next-token; |
!!!next-token; |
| 3836 |
return; |
return; |
| 3847 |
last INSCOPE; |
last INSCOPE; |
| 3848 |
} else { # in open elements but not in scope |
} else { # in open elements but not in scope |
| 3849 |
!!!cp ('t55'); |
!!!cp ('t55'); |
| 3850 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, |
!!!parse-error (type => 'unmatched end tag', |
| 3851 |
|
text => $token->{tag_name}, |
| 3852 |
token => $end_tag_token); |
token => $end_tag_token); |
| 3853 |
## Ignore the token |
## Ignore the token |
| 3854 |
!!!next-token; |
!!!next-token; |
| 3861 |
} # INSCOPE |
} # INSCOPE |
| 3862 |
unless (defined $formatting_element_i_in_open) { |
unless (defined $formatting_element_i_in_open) { |
| 3863 |
!!!cp ('t57'); |
!!!cp ('t57'); |
| 3864 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, |
!!!parse-error (type => 'unmatched end tag', |
| 3865 |
|
text => $token->{tag_name}, |
| 3866 |
token => $end_tag_token); |
token => $end_tag_token); |
| 3867 |
pop @$active_formatting_elements; # $formatting_element |
pop @$active_formatting_elements; # $formatting_element |
| 3868 |
!!!next-token; ## TODO: ok? |
!!!next-token; ## TODO: ok? |
| 3871 |
if (not $self->{open_elements}->[-1]->[0] eq $formatting_element->[0]) { |
if (not $self->{open_elements}->[-1]->[0] eq $formatting_element->[0]) { |
| 3872 |
!!!cp ('t58'); |
!!!cp ('t58'); |
| 3873 |
!!!parse-error (type => 'not closed', |
!!!parse-error (type => 'not closed', |
| 3874 |
value => $self->{open_elements}->[-1]->[0] |
text => $self->{open_elements}->[-1]->[0] |
| 3875 |
->manakai_local_name, |
->manakai_local_name, |
| 3876 |
token => $end_tag_token); |
token => $end_tag_token); |
| 3877 |
} |
} |
| 4080 |
B: while (1) { |
B: while (1) { |
| 4081 |
if ($token->{type} == DOCTYPE_TOKEN) { |
if ($token->{type} == DOCTYPE_TOKEN) { |
| 4082 |
!!!cp ('t73'); |
!!!cp ('t73'); |
| 4083 |
!!!parse-error (type => 'DOCTYPE in the middle', token => $token); |
!!!parse-error (type => 'in html:#DOCTYPE', token => $token); |
| 4084 |
## Ignore the token |
## Ignore the token |
| 4085 |
## Stay in the phase |
## Stay in the phase |
| 4086 |
!!!next-token; |
!!!next-token; |
| 4089 |
$token->{tag_name} eq 'html') { |
$token->{tag_name} eq 'html') { |
| 4090 |
if ($self->{insertion_mode} == AFTER_HTML_BODY_IM) { |
if ($self->{insertion_mode} == AFTER_HTML_BODY_IM) { |
| 4091 |
!!!cp ('t79'); |
!!!cp ('t79'); |
| 4092 |
!!!parse-error (type => 'after html:html', token => $token); |
!!!parse-error (type => 'after html', text => 'html', token => $token); |
| 4093 |
$self->{insertion_mode} = AFTER_BODY_IM; |
$self->{insertion_mode} = AFTER_BODY_IM; |
| 4094 |
} elsif ($self->{insertion_mode} == AFTER_HTML_FRAMESET_IM) { |
} elsif ($self->{insertion_mode} == AFTER_HTML_FRAMESET_IM) { |
| 4095 |
!!!cp ('t80'); |
!!!cp ('t80'); |
| 4096 |
!!!parse-error (type => 'after html:html', token => $token); |
!!!parse-error (type => 'after html', text => 'html', token => $token); |
| 4097 |
$self->{insertion_mode} = AFTER_FRAMESET_IM; |
$self->{insertion_mode} = AFTER_FRAMESET_IM; |
| 4098 |
} else { |
} else { |
| 4099 |
!!!cp ('t81'); |
!!!cp ('t81'); |
| 4143 |
!!!cp ('t87.2'); |
!!!cp ('t87.2'); |
| 4144 |
# |
# |
| 4145 |
} elsif ({ |
} elsif ({ |
| 4146 |
## TODO: |
b => 1, big => 1, blockquote => 1, body => 1, br => 1, |
| 4147 |
|
center => 1, code => 1, dd => 1, div => 1, dl => 1, dt => 1, |
| 4148 |
|
em => 1, embed => 1, font => 1, h1 => 1, h2 => 1, h3 => 1, |
| 4149 |
|
h4 => 1, h5 => 1, h6 => 1, head => 1, hr => 1, i => 1, |
| 4150 |
|
img => 1, li => 1, listing => 1, menu => 1, meta => 1, |
| 4151 |
|
nobr => 1, ol => 1, p => 1, pre => 1, ruby => 1, s => 1, |
| 4152 |
|
small => 1, span => 1, strong => 1, strike => 1, sub => 1, |
| 4153 |
|
sup => 1, table => 1, tt => 1, u => 1, ul => 1, var => 1, |
| 4154 |
}->{$token->{tag_name}}) { |
}->{$token->{tag_name}}) { |
| 4155 |
!!!cp ('t87.2'); |
!!!cp ('t87.2'); |
| 4156 |
!!!parse-error (type => 'not closed', |
!!!parse-error (type => 'not closed', |
| 4157 |
value => $self->{open_elements}->[-1]->[0] |
text => $self->{open_elements}->[-1]->[0] |
| 4158 |
->manakai_local_name, |
->manakai_local_name, |
| 4159 |
token => $token); |
token => $token); |
| 4160 |
|
|
| 4161 |
pop @{$self->{open_elements}} |
pop @{$self->{open_elements}} |
| 4162 |
while $self->{open_elements}->[-1]->[1] & FOREIGN_EL; |
while $self->{open_elements}->[-1]->[1] & FOREIGN_EL; |
| 4163 |
|
|
| 4164 |
$self->{insertion_mode} &= ~ $self->{insertion_mode}; |
$self->{insertion_mode} &= ~ IN_FOREIGN_CONTENT_IM; |
| 4165 |
## Reprocess. |
## Reprocess. |
| 4166 |
next B; |
next B; |
| 4167 |
} else { |
} else { |
| 4168 |
## TODO: case fixup |
my $nsuri = $self->{open_elements}->[-1]->[0]->namespace_uri; |
| 4169 |
|
my $tag_name = $token->{tag_name}; |
| 4170 |
|
if ($nsuri eq $SVG_NS) { |
| 4171 |
|
$tag_name = { |
| 4172 |
|
altglyph => 'altGlyph', |
| 4173 |
|
altglyphdef => 'altGlyphDef', |
| 4174 |
|
altglyphitem => 'altGlyphItem', |
| 4175 |
|
animatecolor => 'animateColor', |
| 4176 |
|
animatemotion => 'animateMotion', |
| 4177 |
|
animatetransform => 'animateTransform', |
| 4178 |
|
clippath => 'clipPath', |
| 4179 |
|
feblend => 'feBlend', |
| 4180 |
|
fecolormatrix => 'feColorMatrix', |
| 4181 |
|
fecomponenttransfer => 'feComponentTransfer', |
| 4182 |
|
fecomposite => 'feComposite', |
| 4183 |
|
feconvolvematrix => 'feConvolveMatrix', |
| 4184 |
|
fediffuselighting => 'feDiffuseLighting', |
| 4185 |
|
fedisplacementmap => 'feDisplacementMap', |
| 4186 |
|
fedistantlight => 'feDistantLight', |
| 4187 |
|
feflood => 'feFlood', |
| 4188 |
|
fefunca => 'feFuncA', |
| 4189 |
|
fefuncb => 'feFuncB', |
| 4190 |
|
fefuncg => 'feFuncG', |
| 4191 |
|
fefuncr => 'feFuncR', |
| 4192 |
|
fegaussianblur => 'feGaussianBlur', |
| 4193 |
|
feimage => 'feImage', |
| 4194 |
|
femerge => 'feMerge', |
| 4195 |
|
femergenode => 'feMergeNode', |
| 4196 |
|
femorphology => 'feMorphology', |
| 4197 |
|
feoffset => 'feOffset', |
| 4198 |
|
fepointlight => 'fePointLight', |
| 4199 |
|
fespecularlighting => 'feSpecularLighting', |
| 4200 |
|
fespotlight => 'feSpotLight', |
| 4201 |
|
fetile => 'feTile', |
| 4202 |
|
feturbulence => 'feTurbulence', |
| 4203 |
|
foreignobject => 'foreignObject', |
| 4204 |
|
glyphref => 'glyphRef', |
| 4205 |
|
lineargradient => 'linearGradient', |
| 4206 |
|
radialgradient => 'radialGradient', |
| 4207 |
|
#solidcolor => 'solidColor', ## NOTE: Commented in spec (SVG1.2) |
| 4208 |
|
textpath => 'textPath', |
| 4209 |
|
}->{$tag_name} || $tag_name; |
| 4210 |
|
} |
| 4211 |
|
|
| 4212 |
|
## "adjust SVG attributes" (SVG only) - done in insert-element-f |
| 4213 |
|
|
| 4214 |
!!!insert-element-f ($self->{open_elements}->[-1]->[0]->namespace_uri, $token); |
## "adjust foreign attributes" - done in insert-element-f |
| 4215 |
|
|
| 4216 |
|
!!!insert-element-f ($nsuri, $tag_name, $token->{attributes}, $token); |
| 4217 |
|
|
| 4218 |
if ($self->{self_closing}) { |
if ($self->{self_closing}) { |
| 4219 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 4230 |
!!!cp ('t87.5'); |
!!!cp ('t87.5'); |
| 4231 |
# |
# |
| 4232 |
} elsif ($token->{type} == END_OF_FILE_TOKEN) { |
} elsif ($token->{type} == END_OF_FILE_TOKEN) { |
|
## NOTE: "using the rules for secondary insertion mode" then "continue" |
|
| 4233 |
!!!cp ('t87.6'); |
!!!cp ('t87.6'); |
| 4234 |
# |
!!!parse-error (type => 'not closed', |
| 4235 |
## TODO: ... |
text => $self->{open_elements}->[-1]->[0] |
| 4236 |
|
->manakai_local_name, |
| 4237 |
|
token => $token); |
| 4238 |
|
|
| 4239 |
|
pop @{$self->{open_elements}} |
| 4240 |
|
while $self->{open_elements}->[-1]->[1] & FOREIGN_EL; |
| 4241 |
|
|
| 4242 |
|
$self->{insertion_mode} &= ~ IN_FOREIGN_CONTENT_IM; |
| 4243 |
|
## Reprocess. |
| 4244 |
|
next B; |
| 4245 |
} else { |
} else { |
| 4246 |
die "$0: $token->{type}: Unknown token type"; |
die "$0: $token->{type}: Unknown token type"; |
| 4247 |
} |
} |
| 4282 |
!!!cp ('t90'); |
!!!cp ('t90'); |
| 4283 |
## As if </noscript> |
## As if </noscript> |
| 4284 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 4285 |
!!!parse-error (type => 'in noscript:#character', token => $token); |
!!!parse-error (type => 'in noscript:#text', token => $token); |
| 4286 |
|
|
| 4287 |
## Reprocess in the "in head" insertion mode... |
## Reprocess in the "in head" insertion mode... |
| 4288 |
## As if </head> |
## As if </head> |
| 4318 |
!!!next-token; |
!!!next-token; |
| 4319 |
next B; |
next B; |
| 4320 |
} elsif ($self->{insertion_mode} == AFTER_HEAD_IM) { |
} elsif ($self->{insertion_mode} == AFTER_HEAD_IM) { |
| 4321 |
!!!cp ('t94'); |
!!!cp ('t93.2'); |
| 4322 |
# |
!!!parse-error (type => 'after head', text => 'head', |
| 4323 |
|
token => $token); |
| 4324 |
|
## Ignore the token |
| 4325 |
|
!!!nack ('t93.3'); |
| 4326 |
|
!!!next-token; |
| 4327 |
|
next B; |
| 4328 |
} else { |
} else { |
| 4329 |
!!!cp ('t95'); |
!!!cp ('t95'); |
| 4330 |
!!!parse-error (type => 'in head:head', token => $token); # or in head noscript |
!!!parse-error (type => 'in head:head', |
| 4331 |
|
token => $token); # or in head noscript |
| 4332 |
## Ignore the token |
## Ignore the token |
| 4333 |
!!!nack ('t95.1'); |
!!!nack ('t95.1'); |
| 4334 |
!!!next-token; |
!!!next-token; |
| 4353 |
!!!cp ('t98'); |
!!!cp ('t98'); |
| 4354 |
## As if </noscript> |
## As if </noscript> |
| 4355 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 4356 |
!!!parse-error (type => 'in noscript:base', token => $token); |
!!!parse-error (type => 'in noscript', text => 'base', |
| 4357 |
|
token => $token); |
| 4358 |
|
|
| 4359 |
$self->{insertion_mode} = IN_HEAD_IM; |
$self->{insertion_mode} = IN_HEAD_IM; |
| 4360 |
## Reprocess in the "in head" insertion mode... |
## Reprocess in the "in head" insertion mode... |
| 4365 |
## NOTE: There is a "as if in head" code clone. |
## NOTE: There is a "as if in head" code clone. |
| 4366 |
if ($self->{insertion_mode} == AFTER_HEAD_IM) { |
if ($self->{insertion_mode} == AFTER_HEAD_IM) { |
| 4367 |
!!!cp ('t100'); |
!!!cp ('t100'); |
| 4368 |
!!!parse-error (type => 'after head:'.$token->{tag_name}, token => $token); |
!!!parse-error (type => 'after head', |
| 4369 |
|
text => $token->{tag_name}, token => $token); |
| 4370 |
push @{$self->{open_elements}}, |
push @{$self->{open_elements}}, |
| 4371 |
[$self->{head_element}, $el_category->{head}]; |
[$self->{head_element}, $el_category->{head}]; |
| 4372 |
} else { |
} else { |
| 4383 |
## NOTE: There is a "as if in head" code clone. |
## NOTE: There is a "as if in head" code clone. |
| 4384 |
if ($self->{insertion_mode} == AFTER_HEAD_IM) { |
if ($self->{insertion_mode} == AFTER_HEAD_IM) { |
| 4385 |
!!!cp ('t102'); |
!!!cp ('t102'); |
| 4386 |
!!!parse-error (type => 'after head:'.$token->{tag_name}, token => $token); |
!!!parse-error (type => 'after head', |
| 4387 |
|
text => $token->{tag_name}, token => $token); |
| 4388 |
push @{$self->{open_elements}}, |
push @{$self->{open_elements}}, |
| 4389 |
[$self->{head_element}, $el_category->{head}]; |
[$self->{head_element}, $el_category->{head}]; |
| 4390 |
} else { |
} else { |
| 4401 |
## NOTE: There is a "as if in head" code clone. |
## NOTE: There is a "as if in head" code clone. |
| 4402 |
if ($self->{insertion_mode} == AFTER_HEAD_IM) { |
if ($self->{insertion_mode} == AFTER_HEAD_IM) { |
| 4403 |
!!!cp ('t104'); |
!!!cp ('t104'); |
| 4404 |
!!!parse-error (type => 'after head:'.$token->{tag_name}, token => $token); |
!!!parse-error (type => 'after head', |
| 4405 |
|
text => $token->{tag_name}, token => $token); |
| 4406 |
push @{$self->{open_elements}}, |
push @{$self->{open_elements}}, |
| 4407 |
[$self->{head_element}, $el_category->{head}]; |
[$self->{head_element}, $el_category->{head}]; |
| 4408 |
} else { |
} else { |
| 4412 |
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. |
| 4413 |
|
|
| 4414 |
unless ($self->{confident}) { |
unless ($self->{confident}) { |
| 4415 |
if ($token->{attributes}->{charset}) { ## TODO: And if supported |
if ($token->{attributes}->{charset}) { |
| 4416 |
!!!cp ('t106'); |
!!!cp ('t106'); |
| 4417 |
|
## NOTE: Whether the encoding is supported or not is handled |
| 4418 |
|
## in the {change_encoding} callback. |
| 4419 |
$self->{change_encoding} |
$self->{change_encoding} |
| 4420 |
->($self, $token->{attributes}->{charset}->{value}, |
->($self, $token->{attributes}->{charset}->{value}, |
| 4421 |
$token); |
$token); |
| 4425 |
$token->{attributes}->{charset} |
$token->{attributes}->{charset} |
| 4426 |
->{has_reference}); |
->{has_reference}); |
| 4427 |
} elsif ($token->{attributes}->{content}) { |
} elsif ($token->{attributes}->{content}) { |
|
## ISSUE: Algorithm name in the spec was incorrect so that not linked to the definition. |
|
| 4428 |
if ($token->{attributes}->{content}->{value} |
if ($token->{attributes}->{content}->{value} |
| 4429 |
=~ /\A[^;]*;[\x09-\x0D\x20]*[Cc][Hh][Aa][Rr][Ss][Ee][Tt] |
=~ /[Cc][Hh][Aa][Rr][Ss][Ee][Tt] |
| 4430 |
[\x09-\x0D\x20]*= |
[\x09-\x0D\x20]*= |
| 4431 |
[\x09-\x0D\x20]*(?>"([^"]*)"|'([^']*)'| |
[\x09-\x0D\x20]*(?>"([^"]*)"|'([^']*)'| |
| 4432 |
([^"'\x09-\x0D\x20][^\x09-\x0D\x20]*))/x) { |
([^"'\x09-\x0D\x20][^\x09-\x0D\x20\x3B]*))/x) { |
| 4433 |
!!!cp ('t107'); |
!!!cp ('t107'); |
| 4434 |
|
## NOTE: Whether the encoding is supported or not is handled |
| 4435 |
|
## in the {change_encoding} callback. |
| 4436 |
$self->{change_encoding} |
$self->{change_encoding} |
| 4437 |
->($self, defined $1 ? $1 : defined $2 ? $2 : $3, |
->($self, defined $1 ? $1 : defined $2 ? $2 : $3, |
| 4438 |
$token); |
$token); |
| 4471 |
!!!cp ('t111'); |
!!!cp ('t111'); |
| 4472 |
## As if </noscript> |
## As if </noscript> |
| 4473 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 4474 |
!!!parse-error (type => 'in noscript:title', token => $token); |
!!!parse-error (type => 'in noscript', text => 'title', |
| 4475 |
|
token => $token); |
| 4476 |
|
|
| 4477 |
$self->{insertion_mode} = IN_HEAD_IM; |
$self->{insertion_mode} = IN_HEAD_IM; |
| 4478 |
## Reprocess in the "in head" insertion mode... |
## Reprocess in the "in head" insertion mode... |
| 4479 |
} elsif ($self->{insertion_mode} == AFTER_HEAD_IM) { |
} elsif ($self->{insertion_mode} == AFTER_HEAD_IM) { |
| 4480 |
!!!cp ('t112'); |
!!!cp ('t112'); |
| 4481 |
!!!parse-error (type => 'after head:'.$token->{tag_name}, token => $token); |
!!!parse-error (type => 'after head', |
| 4482 |
|
text => $token->{tag_name}, token => $token); |
| 4483 |
push @{$self->{open_elements}}, |
push @{$self->{open_elements}}, |
| 4484 |
[$self->{head_element}, $el_category->{head}]; |
[$self->{head_element}, $el_category->{head}]; |
| 4485 |
} else { |
} else { |
| 4493 |
pop @{$self->{open_elements}} # <head> |
pop @{$self->{open_elements}} # <head> |
| 4494 |
if $self->{insertion_mode} == AFTER_HEAD_IM; |
if $self->{insertion_mode} == AFTER_HEAD_IM; |
| 4495 |
next B; |
next B; |
| 4496 |
} elsif ($token->{tag_name} eq 'style') { |
} elsif ($token->{tag_name} eq 'style' or |
| 4497 |
|
$token->{tag_name} eq 'noframes') { |
| 4498 |
## NOTE: Or (scripting is enabled and tag_name eq 'noscript' and |
## NOTE: Or (scripting is enabled and tag_name eq 'noscript' and |
| 4499 |
## insertion mode IN_HEAD_IM) |
## insertion mode IN_HEAD_IM) |
| 4500 |
## NOTE: There is a "as if in head" code clone. |
## NOTE: There is a "as if in head" code clone. |
| 4501 |
if ($self->{insertion_mode} == AFTER_HEAD_IM) { |
if ($self->{insertion_mode} == AFTER_HEAD_IM) { |
| 4502 |
!!!cp ('t114'); |
!!!cp ('t114'); |
| 4503 |
!!!parse-error (type => 'after head:'.$token->{tag_name}, token => $token); |
!!!parse-error (type => 'after head', |
| 4504 |
|
text => $token->{tag_name}, token => $token); |
| 4505 |
push @{$self->{open_elements}}, |
push @{$self->{open_elements}}, |
| 4506 |
[$self->{head_element}, $el_category->{head}]; |
[$self->{head_element}, $el_category->{head}]; |
| 4507 |
} else { |
} else { |
| 4522 |
next B; |
next B; |
| 4523 |
} elsif ($self->{insertion_mode} == IN_HEAD_NOSCRIPT_IM) { |
} elsif ($self->{insertion_mode} == IN_HEAD_NOSCRIPT_IM) { |
| 4524 |
!!!cp ('t117'); |
!!!cp ('t117'); |
| 4525 |
!!!parse-error (type => 'in noscript:noscript', token => $token); |
!!!parse-error (type => 'in noscript', text => 'noscript', |
| 4526 |
|
token => $token); |
| 4527 |
## Ignore the token |
## Ignore the token |
| 4528 |
!!!nack ('t117.1'); |
!!!nack ('t117.1'); |
| 4529 |
!!!next-token; |
!!!next-token; |
| 4537 |
!!!cp ('t119'); |
!!!cp ('t119'); |
| 4538 |
## As if </noscript> |
## As if </noscript> |
| 4539 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 4540 |
!!!parse-error (type => 'in noscript:script', token => $token); |
!!!parse-error (type => 'in noscript', text => 'script', |
| 4541 |
|
token => $token); |
| 4542 |
|
|
| 4543 |
$self->{insertion_mode} = IN_HEAD_IM; |
$self->{insertion_mode} = IN_HEAD_IM; |
| 4544 |
## Reprocess in the "in head" insertion mode... |
## Reprocess in the "in head" insertion mode... |
| 4545 |
} elsif ($self->{insertion_mode} == AFTER_HEAD_IM) { |
} elsif ($self->{insertion_mode} == AFTER_HEAD_IM) { |
| 4546 |
!!!cp ('t120'); |
!!!cp ('t120'); |
| 4547 |
!!!parse-error (type => 'after head:'.$token->{tag_name}, token => $token); |
!!!parse-error (type => 'after head', |
| 4548 |
|
text => $token->{tag_name}, token => $token); |
| 4549 |
push @{$self->{open_elements}}, |
push @{$self->{open_elements}}, |
| 4550 |
[$self->{head_element}, $el_category->{head}]; |
[$self->{head_element}, $el_category->{head}]; |
| 4551 |
} else { |
} else { |
| 4563 |
!!!cp ('t122'); |
!!!cp ('t122'); |
| 4564 |
## As if </noscript> |
## As if </noscript> |
| 4565 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 4566 |
!!!parse-error (type => 'in noscript:'.$token->{tag_name}, token => $token); |
!!!parse-error (type => 'in noscript', |
| 4567 |
|
text => $token->{tag_name}, token => $token); |
| 4568 |
|
|
| 4569 |
## Reprocess in the "in head" insertion mode... |
## Reprocess in the "in head" insertion mode... |
| 4570 |
## As if </head> |
## As if </head> |
| 4603 |
!!!cp ('t129'); |
!!!cp ('t129'); |
| 4604 |
## As if </noscript> |
## As if </noscript> |
| 4605 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 4606 |
!!!parse-error (type => 'in noscript:/'.$token->{tag_name}, token => $token); |
!!!parse-error (type => 'in noscript:/', |
| 4607 |
|
text => $token->{tag_name}, token => $token); |
| 4608 |
|
|
| 4609 |
## Reprocess in the "in head" insertion mode... |
## Reprocess in the "in head" insertion mode... |
| 4610 |
## As if </head> |
## As if </head> |
| 4647 |
!!!cp ('t133'); |
!!!cp ('t133'); |
| 4648 |
## As if </noscript> |
## As if </noscript> |
| 4649 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 4650 |
!!!parse-error (type => 'in noscript:/head', token => $token); |
!!!parse-error (type => 'in noscript:/', |
| 4651 |
|
text => 'head', token => $token); |
| 4652 |
|
|
| 4653 |
## Reprocess in the "in head" insertion mode... |
## Reprocess in the "in head" insertion mode... |
| 4654 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 4661 |
$self->{insertion_mode} = AFTER_HEAD_IM; |
$self->{insertion_mode} = AFTER_HEAD_IM; |
| 4662 |
!!!next-token; |
!!!next-token; |
| 4663 |
next B; |
next B; |
| 4664 |
|
} elsif ($self->{insertion_mode} == AFTER_HEAD_IM) { |
| 4665 |
|
!!!cp ('t134.1'); |
| 4666 |
|
!!!parse-error (type => 'unmatched end tag', text => 'head', |
| 4667 |
|
token => $token); |
| 4668 |
|
## Ignore the token |
| 4669 |
|
!!!next-token; |
| 4670 |
|
next B; |
| 4671 |
} else { |
} else { |
| 4672 |
!!!cp ('t135'); |
die "$0: $self->{insertion_mode}: Unknown insertion mode"; |
|
# |
|
| 4673 |
} |
} |
| 4674 |
} elsif ($token->{tag_name} eq 'noscript') { |
} elsif ($token->{tag_name} eq 'noscript') { |
| 4675 |
if ($self->{insertion_mode} == IN_HEAD_NOSCRIPT_IM) { |
if ($self->{insertion_mode} == IN_HEAD_NOSCRIPT_IM) { |
| 4678 |
$self->{insertion_mode} = IN_HEAD_IM; |
$self->{insertion_mode} = IN_HEAD_IM; |
| 4679 |
!!!next-token; |
!!!next-token; |
| 4680 |
next B; |
next B; |
| 4681 |
} elsif ($self->{insertion_mode} == BEFORE_HEAD_IM) { |
} elsif ($self->{insertion_mode} == BEFORE_HEAD_IM or |
| 4682 |
|
$self->{insertion_mode} == AFTER_HEAD_IM) { |
| 4683 |
!!!cp ('t137'); |
!!!cp ('t137'); |
| 4684 |
!!!parse-error (type => 'unmatched end tag:noscript', token => $token); |
!!!parse-error (type => 'unmatched end tag', |
| 4685 |
|
text => 'noscript', token => $token); |
| 4686 |
## Ignore the token ## ISSUE: An issue in the spec. |
## Ignore the token ## ISSUE: An issue in the spec. |
| 4687 |
!!!next-token; |
!!!next-token; |
| 4688 |
next B; |
next B; |
| 4693 |
} elsif ({ |
} elsif ({ |
| 4694 |
body => 1, html => 1, |
body => 1, html => 1, |
| 4695 |
}->{$token->{tag_name}}) { |
}->{$token->{tag_name}}) { |
| 4696 |
if ($self->{insertion_mode} == BEFORE_HEAD_IM) { |
if ($self->{insertion_mode} == BEFORE_HEAD_IM or |
| 4697 |
!!!cp ('t139'); |
$self->{insertion_mode} == IN_HEAD_IM or |
| 4698 |
## As if <head> |
$self->{insertion_mode} == IN_HEAD_NOSCRIPT_IM) { |
|
!!!create-element ($self->{head_element}, $HTML_NS, 'head',, $token); |
|
|
$self->{open_elements}->[-1]->[0]->append_child ($self->{head_element}); |
|
|
push @{$self->{open_elements}}, |
|
|
[$self->{head_element}, $el_category->{head}]; |
|
|
|
|
|
$self->{insertion_mode} = IN_HEAD_IM; |
|
|
## Reprocess in the "in head" insertion mode... |
|
|
} elsif ($self->{insertion_mode} == IN_HEAD_NOSCRIPT_IM) { |
|
| 4699 |
!!!cp ('t140'); |
!!!cp ('t140'); |
| 4700 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
!!!parse-error (type => 'unmatched end tag', |
| 4701 |
|
text => $token->{tag_name}, token => $token); |
| 4702 |
|
## Ignore the token |
| 4703 |
|
!!!next-token; |
| 4704 |
|
next B; |
| 4705 |
|
} elsif ($self->{insertion_mode} == AFTER_HEAD_IM) { |
| 4706 |
|
!!!cp ('t140.1'); |
| 4707 |
|
!!!parse-error (type => 'unmatched end tag', |
| 4708 |
|
text => $token->{tag_name}, token => $token); |
| 4709 |
## Ignore the token |
## Ignore the token |
| 4710 |
!!!next-token; |
!!!next-token; |
| 4711 |
next B; |
next B; |
| 4712 |
} else { |
} else { |
| 4713 |
!!!cp ('t141'); |
die "$0: $self->{insertion_mode}: Unknown insertion mode"; |
| 4714 |
} |
} |
| 4715 |
|
} elsif ($token->{tag_name} eq 'p') { |
| 4716 |
# |
!!!cp ('t142'); |
| 4717 |
} elsif ({ |
!!!parse-error (type => 'unmatched end tag', |
| 4718 |
p => 1, br => 1, |
text => $token->{tag_name}, token => $token); |
| 4719 |
}->{$token->{tag_name}}) { |
## Ignore the token |
| 4720 |
|
!!!next-token; |
| 4721 |
|
next B; |
| 4722 |
|
} elsif ($token->{tag_name} eq 'br') { |
| 4723 |
if ($self->{insertion_mode} == BEFORE_HEAD_IM) { |
if ($self->{insertion_mode} == BEFORE_HEAD_IM) { |
| 4724 |
!!!cp ('t142'); |
!!!cp ('t142.2'); |
| 4725 |
## As if <head> |
## (before head) as if <head>, (in head) as if </head> |
| 4726 |
!!!create-element ($self->{head_element}, $HTML_NS, 'head',, $token); |
!!!create-element ($self->{head_element}, $HTML_NS, 'head',, $token); |
| 4727 |
$self->{open_elements}->[-1]->[0]->append_child ($self->{head_element}); |
$self->{open_elements}->[-1]->[0]->append_child ($self->{head_element}); |
| 4728 |
push @{$self->{open_elements}}, |
$self->{insertion_mode} = AFTER_HEAD_IM; |
| 4729 |
[$self->{head_element}, $el_category->{head}]; |
|
| 4730 |
|
## Reprocess in the "after head" insertion mode... |
| 4731 |
|
} elsif ($self->{insertion_mode} == IN_HEAD_IM) { |
| 4732 |
|
!!!cp ('t143.2'); |
| 4733 |
|
## As if </head> |
| 4734 |
|
pop @{$self->{open_elements}}; |
| 4735 |
|
$self->{insertion_mode} = AFTER_HEAD_IM; |
| 4736 |
|
|
| 4737 |
|
## Reprocess in the "after head" insertion mode... |
| 4738 |
|
} elsif ($self->{insertion_mode} == IN_HEAD_NOSCRIPT_IM) { |
| 4739 |
|
!!!cp ('t143.3'); |
| 4740 |
|
## ISSUE: Two parse errors for <head><noscript></br> |
| 4741 |
|
!!!parse-error (type => 'unmatched end tag', |
| 4742 |
|
text => 'br', token => $token); |
| 4743 |
|
## As if </noscript> |
| 4744 |
|
pop @{$self->{open_elements}}; |
| 4745 |
$self->{insertion_mode} = IN_HEAD_IM; |
$self->{insertion_mode} = IN_HEAD_IM; |
| 4746 |
|
|
| 4747 |
## Reprocess in the "in head" insertion mode... |
## Reprocess in the "in head" insertion mode... |
| 4748 |
} else { |
## As if </head> |
| 4749 |
!!!cp ('t143'); |
pop @{$self->{open_elements}}; |
| 4750 |
} |
$self->{insertion_mode} = AFTER_HEAD_IM; |
| 4751 |
|
|
| 4752 |
# |
## Reprocess in the "after head" insertion mode... |
| 4753 |
} else { |
} elsif ($self->{insertion_mode} == AFTER_HEAD_IM) { |
| 4754 |
if ($self->{insertion_mode} == AFTER_HEAD_IM) { |
!!!cp ('t143.4'); |
|
!!!cp ('t144'); |
|
| 4755 |
# |
# |
| 4756 |
} else { |
} else { |
| 4757 |
!!!cp ('t145'); |
die "$0: $self->{insertion_mode}: Unknown insertion mode"; |
|
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
|
|
## Ignore the token |
|
|
!!!next-token; |
|
|
next B; |
|
| 4758 |
} |
} |
| 4759 |
|
|
| 4760 |
|
## ISSUE: does not agree with IE7 - it doesn't ignore </br>. |
| 4761 |
|
!!!parse-error (type => 'unmatched end tag', |
| 4762 |
|
text => 'br', token => $token); |
| 4763 |
|
## Ignore the token |
| 4764 |
|
!!!next-token; |
| 4765 |
|
next B; |
| 4766 |
|
} else { |
| 4767 |
|
!!!cp ('t145'); |
| 4768 |
|
!!!parse-error (type => 'unmatched end tag', |
| 4769 |
|
text => $token->{tag_name}, token => $token); |
| 4770 |
|
## Ignore the token |
| 4771 |
|
!!!next-token; |
| 4772 |
|
next B; |
| 4773 |
} |
} |
| 4774 |
|
|
| 4775 |
if ($self->{insertion_mode} == IN_HEAD_NOSCRIPT_IM) { |
if ($self->{insertion_mode} == IN_HEAD_NOSCRIPT_IM) { |
| 4776 |
!!!cp ('t146'); |
!!!cp ('t146'); |
| 4777 |
## As if </noscript> |
## As if </noscript> |
| 4778 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 4779 |
!!!parse-error (type => 'in noscript:/'.$token->{tag_name}, token => $token); |
!!!parse-error (type => 'in noscript:/', |
| 4780 |
|
text => $token->{tag_name}, token => $token); |
| 4781 |
|
|
| 4782 |
## Reprocess in the "in head" insertion mode... |
## Reprocess in the "in head" insertion mode... |
| 4783 |
## As if </head> |
## As if </head> |
| 4793 |
} elsif ($self->{insertion_mode} == BEFORE_HEAD_IM) { |
} elsif ($self->{insertion_mode} == BEFORE_HEAD_IM) { |
| 4794 |
## ISSUE: This case cannot be reached? |
## ISSUE: This case cannot be reached? |
| 4795 |
!!!cp ('t148'); |
!!!cp ('t148'); |
| 4796 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
!!!parse-error (type => 'unmatched end tag', |
| 4797 |
|
text => $token->{tag_name}, token => $token); |
| 4798 |
## Ignore the token ## ISSUE: An issue in the spec. |
## Ignore the token ## ISSUE: An issue in the spec. |
| 4799 |
!!!next-token; |
!!!next-token; |
| 4800 |
next B; |
next B; |
| 4905 |
|
|
| 4906 |
!!!cp ('t153'); |
!!!cp ('t153'); |
| 4907 |
!!!parse-error (type => 'start tag not allowed', |
!!!parse-error (type => 'start tag not allowed', |
| 4908 |
value => $token->{tag_name}, token => $token); |
text => $token->{tag_name}, token => $token); |
| 4909 |
## Ignore the token |
## Ignore the token |
| 4910 |
!!!nack ('t153.1'); |
!!!nack ('t153.1'); |
| 4911 |
!!!next-token; |
!!!next-token; |
| 4912 |
next B; |
next B; |
| 4913 |
} elsif ($self->{insertion_mode} == IN_CAPTION_IM) { |
} elsif ($self->{insertion_mode} == IN_CAPTION_IM) { |
| 4914 |
!!!parse-error (type => 'not closed:caption', token => $token); |
!!!parse-error (type => 'not closed', text => 'caption', |
| 4915 |
|
token => $token); |
| 4916 |
|
|
| 4917 |
## NOTE: As if </caption>. |
## NOTE: As if </caption>. |
| 4918 |
## have a table element in table scope |
## have a table element in table scope |
| 4932 |
|
|
| 4933 |
!!!cp ('t157'); |
!!!cp ('t157'); |
| 4934 |
!!!parse-error (type => 'start tag not allowed', |
!!!parse-error (type => 'start tag not allowed', |
| 4935 |
value => $token->{tag_name}, token => $token); |
text => $token->{tag_name}, token => $token); |
| 4936 |
## Ignore the token |
## Ignore the token |
| 4937 |
!!!nack ('t157.1'); |
!!!nack ('t157.1'); |
| 4938 |
!!!next-token; |
!!!next-token; |
| 4949 |
unless ($self->{open_elements}->[-1]->[1] & CAPTION_EL) { |
unless ($self->{open_elements}->[-1]->[1] & CAPTION_EL) { |
| 4950 |
!!!cp ('t159'); |
!!!cp ('t159'); |
| 4951 |
!!!parse-error (type => 'not closed', |
!!!parse-error (type => 'not closed', |
| 4952 |
value => $self->{open_elements}->[-1]->[0] |
text => $self->{open_elements}->[-1]->[0] |
| 4953 |
->manakai_local_name, |
->manakai_local_name, |
| 4954 |
token => $token); |
token => $token); |
| 4955 |
} else { |
} else { |
| 4991 |
} # INSCOPE |
} # INSCOPE |
| 4992 |
unless (defined $i) { |
unless (defined $i) { |
| 4993 |
!!!cp ('t165'); |
!!!cp ('t165'); |
| 4994 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
!!!parse-error (type => 'unmatched end tag', |
| 4995 |
|
text => $token->{tag_name}, |
| 4996 |
|
token => $token); |
| 4997 |
## Ignore the token |
## Ignore the token |
| 4998 |
!!!next-token; |
!!!next-token; |
| 4999 |
next B; |
next B; |
| 5010 |
ne $token->{tag_name}) { |
ne $token->{tag_name}) { |
| 5011 |
!!!cp ('t167'); |
!!!cp ('t167'); |
| 5012 |
!!!parse-error (type => 'not closed', |
!!!parse-error (type => 'not closed', |
| 5013 |
value => $self->{open_elements}->[-1]->[0] |
text => $self->{open_elements}->[-1]->[0] |
| 5014 |
->manakai_local_name, |
->manakai_local_name, |
| 5015 |
token => $token); |
token => $token); |
| 5016 |
} else { |
} else { |
| 5027 |
next B; |
next B; |
| 5028 |
} elsif ($self->{insertion_mode} == IN_CAPTION_IM) { |
} elsif ($self->{insertion_mode} == IN_CAPTION_IM) { |
| 5029 |
!!!cp ('t169'); |
!!!cp ('t169'); |
| 5030 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
!!!parse-error (type => 'unmatched end tag', |
| 5031 |
|
text => $token->{tag_name}, token => $token); |
| 5032 |
## Ignore the token |
## Ignore the token |
| 5033 |
!!!next-token; |
!!!next-token; |
| 5034 |
next B; |
next B; |
| 5055 |
|
|
| 5056 |
!!!cp ('t173'); |
!!!cp ('t173'); |
| 5057 |
!!!parse-error (type => 'unmatched end tag', |
!!!parse-error (type => 'unmatched end tag', |
| 5058 |
value => $token->{tag_name}, token => $token); |
text => $token->{tag_name}, token => $token); |
| 5059 |
## Ignore the token |
## Ignore the token |
| 5060 |
!!!next-token; |
!!!next-token; |
| 5061 |
next B; |
next B; |
| 5071 |
unless ($self->{open_elements}->[-1]->[1] & CAPTION_EL) { |
unless ($self->{open_elements}->[-1]->[1] & CAPTION_EL) { |
| 5072 |
!!!cp ('t175'); |
!!!cp ('t175'); |
| 5073 |
!!!parse-error (type => 'not closed', |
!!!parse-error (type => 'not closed', |
| 5074 |
value => $self->{open_elements}->[-1]->[0] |
text => $self->{open_elements}->[-1]->[0] |
| 5075 |
->manakai_local_name, |
->manakai_local_name, |
| 5076 |
token => $token); |
token => $token); |
| 5077 |
} else { |
} else { |
| 5088 |
next B; |
next B; |
| 5089 |
} elsif ($self->{insertion_mode} == IN_CELL_IM) { |
} elsif ($self->{insertion_mode} == IN_CELL_IM) { |
| 5090 |
!!!cp ('t177'); |
!!!cp ('t177'); |
| 5091 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
!!!parse-error (type => 'unmatched end tag', |
| 5092 |
|
text => $token->{tag_name}, token => $token); |
| 5093 |
## Ignore the token |
## Ignore the token |
| 5094 |
!!!next-token; |
!!!next-token; |
| 5095 |
next B; |
next B; |
| 5132 |
|
|
| 5133 |
!!!cp ('t182'); |
!!!cp ('t182'); |
| 5134 |
!!!parse-error (type => 'unmatched end tag', |
!!!parse-error (type => 'unmatched end tag', |
| 5135 |
value => $token->{tag_name}, token => $token); |
text => $token->{tag_name}, token => $token); |
| 5136 |
## Ignore the token |
## Ignore the token |
| 5137 |
!!!next-token; |
!!!next-token; |
| 5138 |
next B; |
next B; |
| 5139 |
} # INSCOPE |
} # INSCOPE |
| 5140 |
} elsif ($token->{tag_name} eq 'table' and |
} elsif ($token->{tag_name} eq 'table' and |
| 5141 |
$self->{insertion_mode} == IN_CAPTION_IM) { |
$self->{insertion_mode} == IN_CAPTION_IM) { |
| 5142 |
!!!parse-error (type => 'not closed:caption', token => $token); |
!!!parse-error (type => 'not closed', text => 'caption', |
| 5143 |
|
token => $token); |
| 5144 |
|
|
| 5145 |
## As if </caption> |
## As if </caption> |
| 5146 |
## have a table element in table scope |
## have a table element in table scope |
| 5158 |
} # INSCOPE |
} # INSCOPE |
| 5159 |
unless (defined $i) { |
unless (defined $i) { |
| 5160 |
!!!cp ('t186'); |
!!!cp ('t186'); |
| 5161 |
!!!parse-error (type => 'unmatched end tag:caption', token => $token); |
!!!parse-error (type => 'unmatched end tag', |
| 5162 |
|
text => 'caption', token => $token); |
| 5163 |
## Ignore the token |
## Ignore the token |
| 5164 |
!!!next-token; |
!!!next-token; |
| 5165 |
next B; |
next B; |
| 5174 |
unless ($self->{open_elements}->[-1]->[1] & CAPTION_EL) { |
unless ($self->{open_elements}->[-1]->[1] & CAPTION_EL) { |
| 5175 |
!!!cp ('t188'); |
!!!cp ('t188'); |
| 5176 |
!!!parse-error (type => 'not closed', |
!!!parse-error (type => 'not closed', |
| 5177 |
value => $self->{open_elements}->[-1]->[0] |
text => $self->{open_elements}->[-1]->[0] |
| 5178 |
->manakai_local_name, |
->manakai_local_name, |
| 5179 |
token => $token); |
token => $token); |
| 5180 |
} else { |
} else { |
| 5194 |
}->{$token->{tag_name}}) { |
}->{$token->{tag_name}}) { |
| 5195 |
if ($self->{insertion_mode} & BODY_TABLE_IMS) { |
if ($self->{insertion_mode} & BODY_TABLE_IMS) { |
| 5196 |
!!!cp ('t190'); |
!!!cp ('t190'); |
| 5197 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
!!!parse-error (type => 'unmatched end tag', |
| 5198 |
|
text => $token->{tag_name}, token => $token); |
| 5199 |
## Ignore the token |
## Ignore the token |
| 5200 |
!!!next-token; |
!!!next-token; |
| 5201 |
next B; |
next B; |
| 5209 |
}->{$token->{tag_name}} and |
}->{$token->{tag_name}} and |
| 5210 |
$self->{insertion_mode} == IN_CAPTION_IM) { |
$self->{insertion_mode} == IN_CAPTION_IM) { |
| 5211 |
!!!cp ('t192'); |
!!!cp ('t192'); |
| 5212 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
!!!parse-error (type => 'unmatched end tag', |
| 5213 |
|
text => $token->{tag_name}, token => $token); |
| 5214 |
## Ignore the token |
## Ignore the token |
| 5215 |
!!!next-token; |
!!!next-token; |
| 5216 |
next B; |
next B; |
| 5250 |
} |
} |
| 5251 |
} |
} |
| 5252 |
|
|
| 5253 |
!!!parse-error (type => 'in table:#character', token => $token); |
!!!parse-error (type => 'in table:#text', token => $token); |
| 5254 |
|
|
| 5255 |
## As if in body, but insert into foster parent element |
## As if in body, but insert into foster parent element |
| 5256 |
## ISSUE: Spec says that "whenever a node would be inserted |
## ISSUE: Spec says that "whenever a node would be inserted |
| 5301 |
!!!next-token; |
!!!next-token; |
| 5302 |
next B; |
next B; |
| 5303 |
} elsif ($token->{type} == START_TAG_TOKEN) { |
} elsif ($token->{type} == START_TAG_TOKEN) { |
| 5304 |
if ({ |
if ({ |
| 5305 |
tr => ($self->{insertion_mode} != IN_ROW_IM), |
tr => ($self->{insertion_mode} != IN_ROW_IM), |
| 5306 |
th => 1, td => 1, |
th => 1, td => 1, |
| 5307 |
}->{$token->{tag_name}}) { |
}->{$token->{tag_name}}) { |
| 5308 |
if ($self->{insertion_mode} == IN_TABLE_IM) { |
if ($self->{insertion_mode} == IN_TABLE_IM) { |
| 5309 |
## Clear back to table context |
## Clear back to table context |
| 5310 |
while (not ($self->{open_elements}->[-1]->[1] |
while (not ($self->{open_elements}->[-1]->[1] |
| 5311 |
& TABLE_SCOPING_EL)) { |
& TABLE_SCOPING_EL)) { |
| 5312 |
!!!cp ('t201'); |
!!!cp ('t201'); |
| 5313 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 5314 |
} |
} |
| 5315 |
|
|
| 5316 |
!!!insert-element ('tbody',, $token); |
!!!insert-element ('tbody',, $token); |
| 5317 |
$self->{insertion_mode} = IN_TABLE_BODY_IM; |
$self->{insertion_mode} = IN_TABLE_BODY_IM; |
| 5318 |
## reprocess in the "in table body" insertion mode... |
## reprocess in the "in table body" insertion mode... |
| 5319 |
} |
} |
| 5320 |
|
|
| 5321 |
if ($self->{insertion_mode} == IN_TABLE_BODY_IM) { |
if ($self->{insertion_mode} == IN_TABLE_BODY_IM) { |
| 5322 |
unless ($token->{tag_name} eq 'tr') { |
unless ($token->{tag_name} eq 'tr') { |
| 5323 |
!!!cp ('t202'); |
!!!cp ('t202'); |
| 5324 |
!!!parse-error (type => 'missing start tag:tr', token => $token); |
!!!parse-error (type => 'missing start tag:tr', token => $token); |
| 5325 |
} |
} |
| 5326 |
|
|
| 5327 |
## Clear back to table body context |
## Clear back to table body context |
| 5328 |
while (not ($self->{open_elements}->[-1]->[1] |
while (not ($self->{open_elements}->[-1]->[1] |
| 5329 |
& TABLE_ROWS_SCOPING_EL)) { |
& TABLE_ROWS_SCOPING_EL)) { |
| 5330 |
!!!cp ('t203'); |
!!!cp ('t203'); |
| 5331 |
## ISSUE: Can this case be reached? |
## ISSUE: Can this case be reached? |
| 5332 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 5333 |
} |
} |
| 5334 |
|
|
| 5335 |
$self->{insertion_mode} = IN_ROW_IM; |
$self->{insertion_mode} = IN_ROW_IM; |
| 5336 |
if ($token->{tag_name} eq 'tr') { |
if ($token->{tag_name} eq 'tr') { |
| 5386 |
unless (defined $i) { |
unless (defined $i) { |
| 5387 |
!!!cp ('t210'); |
!!!cp ('t210'); |
| 5388 |
## TODO: This type is wrong. |
## TODO: This type is wrong. |
| 5389 |
!!!parse-error (type => 'unmacthed end tag:'.$token->{tag_name}, token => $token); |
!!!parse-error (type => 'unmacthed end tag', |
| 5390 |
|
text => $token->{tag_name}, token => $token); |
| 5391 |
## Ignore the token |
## Ignore the token |
| 5392 |
!!!nack ('t210.1'); |
!!!nack ('t210.1'); |
| 5393 |
!!!next-token; |
!!!next-token; |
| 5431 |
} # INSCOPE |
} # INSCOPE |
| 5432 |
unless (defined $i) { |
unless (defined $i) { |
| 5433 |
!!!cp ('t216'); |
!!!cp ('t216'); |
| 5434 |
## TODO: This erorr type ios wrong. |
## TODO: This erorr type is wrong. |
| 5435 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
!!!parse-error (type => 'unmatched end tag', |
| 5436 |
|
text => $token->{tag_name}, token => $token); |
| 5437 |
## Ignore the token |
## Ignore the token |
| 5438 |
!!!nack ('t216.1'); |
!!!nack ('t216.1'); |
| 5439 |
!!!next-token; |
!!!next-token; |
| 5508 |
} |
} |
| 5509 |
} elsif ($token->{tag_name} eq 'table') { |
} elsif ($token->{tag_name} eq 'table') { |
| 5510 |
!!!parse-error (type => 'not closed', |
!!!parse-error (type => 'not closed', |
| 5511 |
value => $self->{open_elements}->[-1]->[0] |
text => $self->{open_elements}->[-1]->[0] |
| 5512 |
->manakai_local_name, |
->manakai_local_name, |
| 5513 |
token => $token); |
token => $token); |
| 5514 |
|
|
| 5529 |
unless (defined $i) { |
unless (defined $i) { |
| 5530 |
!!!cp ('t223'); |
!!!cp ('t223'); |
| 5531 |
## TODO: The following is wrong, maybe. |
## TODO: The following is wrong, maybe. |
| 5532 |
!!!parse-error (type => 'unmatched end tag:table', token => $token); |
!!!parse-error (type => 'unmatched end tag', text => 'table', |
| 5533 |
|
token => $token); |
| 5534 |
## Ignore tokens </table><table> |
## Ignore tokens </table><table> |
| 5535 |
!!!nack ('t223.1'); |
!!!nack ('t223.1'); |
| 5536 |
!!!next-token; |
!!!next-token; |
| 5537 |
next B; |
next B; |
| 5538 |
} |
} |
| 5539 |
|
|
| 5540 |
## TODO: Followings are removed from the latest spec. |
## TODO: Followings are removed from the latest spec. |
| 5541 |
## generate implied end tags |
## generate implied end tags |
| 5542 |
while ($self->{open_elements}->[-1]->[1] & END_TAG_OPTIONAL_EL) { |
while ($self->{open_elements}->[-1]->[1] & END_TAG_OPTIONAL_EL) { |
| 5543 |
!!!cp ('t224'); |
!!!cp ('t224'); |
| 5548 |
!!!cp ('t225'); |
!!!cp ('t225'); |
| 5549 |
## NOTE: |<table><tr><table>| |
## NOTE: |<table><tr><table>| |
| 5550 |
!!!parse-error (type => 'not closed', |
!!!parse-error (type => 'not closed', |
| 5551 |
value => $self->{open_elements}->[-1]->[0] |
text => $self->{open_elements}->[-1]->[0] |
| 5552 |
->manakai_local_name, |
->manakai_local_name, |
| 5553 |
token => $token); |
token => $token); |
| 5554 |
} else { |
} else { |
| 5589 |
my $type = lc $token->{attributes}->{type}->{value}; |
my $type = lc $token->{attributes}->{type}->{value}; |
| 5590 |
if ($type eq 'hidden') { |
if ($type eq 'hidden') { |
| 5591 |
!!!cp ('t227.3'); |
!!!cp ('t227.3'); |
| 5592 |
!!!parse-error (type => 'in table:'.$token->{tag_name}, token => $token); |
!!!parse-error (type => 'in table', |
| 5593 |
|
text => $token->{tag_name}, token => $token); |
| 5594 |
|
|
| 5595 |
!!!insert-element ($token->{tag_name}, $token->{attributes}, $token); |
!!!insert-element ($token->{tag_name}, $token->{attributes}, $token); |
| 5596 |
|
|
| 5618 |
# |
# |
| 5619 |
} |
} |
| 5620 |
|
|
| 5621 |
!!!parse-error (type => 'in table:'.$token->{tag_name}, token => $token); |
!!!parse-error (type => 'in table', text => $token->{tag_name}, |
| 5622 |
|
token => $token); |
| 5623 |
|
|
| 5624 |
$insert = $insert_to_foster; |
$insert = $insert_to_foster; |
| 5625 |
# |
# |
| 5641 |
} # INSCOPE |
} # INSCOPE |
| 5642 |
unless (defined $i) { |
unless (defined $i) { |
| 5643 |
!!!cp ('t230'); |
!!!cp ('t230'); |
| 5644 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
!!!parse-error (type => 'unmatched end tag', |
| 5645 |
|
text => $token->{tag_name}, token => $token); |
| 5646 |
## Ignore the token |
## Ignore the token |
| 5647 |
!!!nack ('t230.1'); |
!!!nack ('t230.1'); |
| 5648 |
!!!next-token; |
!!!next-token; |
| 5683 |
unless (defined $i) { |
unless (defined $i) { |
| 5684 |
!!!cp ('t235'); |
!!!cp ('t235'); |
| 5685 |
## TODO: The following is wrong. |
## TODO: The following is wrong. |
| 5686 |
!!!parse-error (type => 'unmatched end tag:'.$token->{type}, token => $token); |
!!!parse-error (type => 'unmatched end tag', |
| 5687 |
|
text => $token->{type}, token => $token); |
| 5688 |
## Ignore the token |
## Ignore the token |
| 5689 |
!!!nack ('t236.1'); |
!!!nack ('t236.1'); |
| 5690 |
!!!next-token; |
!!!next-token; |
| 5720 |
} # INSCOPE |
} # INSCOPE |
| 5721 |
unless (defined $i) { |
unless (defined $i) { |
| 5722 |
!!!cp ('t239'); |
!!!cp ('t239'); |
| 5723 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
!!!parse-error (type => 'unmatched end tag', |
| 5724 |
|
text => $token->{tag_name}, token => $token); |
| 5725 |
## Ignore the token |
## Ignore the token |
| 5726 |
!!!nack ('t239.1'); |
!!!nack ('t239.1'); |
| 5727 |
!!!next-token; |
!!!next-token; |
| 5767 |
} # INSCOPE |
} # INSCOPE |
| 5768 |
unless (defined $i) { |
unless (defined $i) { |
| 5769 |
!!!cp ('t243'); |
!!!cp ('t243'); |
| 5770 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
!!!parse-error (type => 'unmatched end tag', |
| 5771 |
|
text => $token->{tag_name}, token => $token); |
| 5772 |
## Ignore the token |
## Ignore the token |
| 5773 |
!!!nack ('t243.1'); |
!!!nack ('t243.1'); |
| 5774 |
!!!next-token; |
!!!next-token; |
| 5802 |
} # INSCOPE |
} # INSCOPE |
| 5803 |
unless (defined $i) { |
unless (defined $i) { |
| 5804 |
!!!cp ('t249'); |
!!!cp ('t249'); |
| 5805 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
!!!parse-error (type => 'unmatched end tag', |
| 5806 |
|
text => $token->{tag_name}, token => $token); |
| 5807 |
## Ignore the token |
## Ignore the token |
| 5808 |
!!!nack ('t249.1'); |
!!!nack ('t249.1'); |
| 5809 |
!!!next-token; |
!!!next-token; |
| 5826 |
} # INSCOPE |
} # INSCOPE |
| 5827 |
unless (defined $i) { |
unless (defined $i) { |
| 5828 |
!!!cp ('t252'); |
!!!cp ('t252'); |
| 5829 |
!!!parse-error (type => 'unmatched end tag:tr', token => $token); |
!!!parse-error (type => 'unmatched end tag', |
| 5830 |
|
text => 'tr', token => $token); |
| 5831 |
## Ignore the token |
## Ignore the token |
| 5832 |
!!!nack ('t252.1'); |
!!!nack ('t252.1'); |
| 5833 |
!!!next-token; |
!!!next-token; |
| 5862 |
} # INSCOPE |
} # INSCOPE |
| 5863 |
unless (defined $i) { |
unless (defined $i) { |
| 5864 |
!!!cp ('t256'); |
!!!cp ('t256'); |
| 5865 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
!!!parse-error (type => 'unmatched end tag', |
| 5866 |
|
text => $token->{tag_name}, token => $token); |
| 5867 |
## Ignore the token |
## Ignore the token |
| 5868 |
!!!nack ('t256.1'); |
!!!nack ('t256.1'); |
| 5869 |
!!!next-token; |
!!!next-token; |
| 5890 |
tbody => 1, tfoot => 1, thead => 1, # $self->{insertion_mode} == IN_TABLE_IM |
tbody => 1, tfoot => 1, thead => 1, # $self->{insertion_mode} == IN_TABLE_IM |
| 5891 |
}->{$token->{tag_name}}) { |
}->{$token->{tag_name}}) { |
| 5892 |
!!!cp ('t258'); |
!!!cp ('t258'); |
| 5893 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
!!!parse-error (type => 'unmatched end tag', |
| 5894 |
|
text => $token->{tag_name}, token => $token); |
| 5895 |
## Ignore the token |
## Ignore the token |
| 5896 |
!!!nack ('t258.1'); |
!!!nack ('t258.1'); |
| 5897 |
!!!next-token; |
!!!next-token; |
| 5898 |
next B; |
next B; |
| 5899 |
} else { |
} else { |
| 5900 |
!!!cp ('t259'); |
!!!cp ('t259'); |
| 5901 |
!!!parse-error (type => 'in table:/'.$token->{tag_name}, token => $token); |
!!!parse-error (type => 'in table:/', |
| 5902 |
|
text => $token->{tag_name}, token => $token); |
| 5903 |
|
|
| 5904 |
$insert = $insert_to_foster; |
$insert = $insert_to_foster; |
| 5905 |
# |
# |
| 5949 |
if ($token->{tag_name} eq 'colgroup') { |
if ($token->{tag_name} eq 'colgroup') { |
| 5950 |
if ($self->{open_elements}->[-1]->[1] & HTML_EL) { |
if ($self->{open_elements}->[-1]->[1] & HTML_EL) { |
| 5951 |
!!!cp ('t264'); |
!!!cp ('t264'); |
| 5952 |
!!!parse-error (type => 'unmatched end tag:colgroup', token => $token); |
!!!parse-error (type => 'unmatched end tag', |
| 5953 |
|
text => 'colgroup', token => $token); |
| 5954 |
## Ignore the token |
## Ignore the token |
| 5955 |
!!!next-token; |
!!!next-token; |
| 5956 |
next B; |
next B; |
| 5963 |
} |
} |
| 5964 |
} elsif ($token->{tag_name} eq 'col') { |
} elsif ($token->{tag_name} eq 'col') { |
| 5965 |
!!!cp ('t266'); |
!!!cp ('t266'); |
| 5966 |
!!!parse-error (type => 'unmatched end tag:col', token => $token); |
!!!parse-error (type => 'unmatched end tag', |
| 5967 |
|
text => 'col', token => $token); |
| 5968 |
## Ignore the token |
## Ignore the token |
| 5969 |
!!!next-token; |
!!!next-token; |
| 5970 |
next B; |
next B; |
| 5994 |
if ($self->{open_elements}->[-1]->[1] & HTML_EL) { |
if ($self->{open_elements}->[-1]->[1] & HTML_EL) { |
| 5995 |
!!!cp ('t269'); |
!!!cp ('t269'); |
| 5996 |
## TODO: Wrong error type? |
## TODO: Wrong error type? |
| 5997 |
!!!parse-error (type => 'unmatched end tag:colgroup', token => $token); |
!!!parse-error (type => 'unmatched end tag', |
| 5998 |
|
text => 'colgroup', token => $token); |
| 5999 |
## Ignore the token |
## Ignore the token |
| 6000 |
!!!nack ('t269.1'); |
!!!nack ('t269.1'); |
| 6001 |
!!!next-token; |
!!!next-token; |
| 6049 |
!!!nack ('t277.1'); |
!!!nack ('t277.1'); |
| 6050 |
!!!next-token; |
!!!next-token; |
| 6051 |
next B; |
next B; |
| 6052 |
} elsif ($token->{tag_name} eq 'select' or |
} elsif ({ |
| 6053 |
$token->{tag_name} eq 'input' or |
select => 1, input => 1, textarea => 1, |
| 6054 |
|
}->{$token->{tag_name}} or |
| 6055 |
($self->{insertion_mode} == IN_SELECT_IN_TABLE_IM and |
($self->{insertion_mode} == IN_SELECT_IN_TABLE_IM and |
| 6056 |
{ |
{ |
| 6057 |
caption => 1, table => 1, |
caption => 1, table => 1, |
| 6059 |
tr => 1, td => 1, th => 1, |
tr => 1, td => 1, th => 1, |
| 6060 |
}->{$token->{tag_name}})) { |
}->{$token->{tag_name}})) { |
| 6061 |
## TODO: The type below is not good - <select> is replaced by </select> |
## TODO: The type below is not good - <select> is replaced by </select> |
| 6062 |
!!!parse-error (type => 'not closed:select', token => $token); |
!!!parse-error (type => 'not closed', text => 'select', |
| 6063 |
|
token => $token); |
| 6064 |
## NOTE: As if the token were </select> (<select> case) or |
## NOTE: As if the token were </select> (<select> case) or |
| 6065 |
## as if there were </select> (otherwise). |
## as if there were </select> (otherwise). |
| 6066 |
## have an element in table scope |
## have an element in table scope |
| 6078 |
} # INSCOPE |
} # INSCOPE |
| 6079 |
unless (defined $i) { |
unless (defined $i) { |
| 6080 |
!!!cp ('t280'); |
!!!cp ('t280'); |
| 6081 |
!!!parse-error (type => 'unmatched end tag:select', token => $token); |
!!!parse-error (type => 'unmatched end tag', |
| 6082 |
|
text => 'select', token => $token); |
| 6083 |
## Ignore the token |
## Ignore the token |
| 6084 |
!!!nack ('t280.1'); |
!!!nack ('t280.1'); |
| 6085 |
!!!next-token; |
!!!next-token; |
| 6103 |
} |
} |
| 6104 |
} else { |
} else { |
| 6105 |
!!!cp ('t282'); |
!!!cp ('t282'); |
| 6106 |
!!!parse-error (type => 'in select:'.$token->{tag_name}, token => $token); |
!!!parse-error (type => 'in select', |
| 6107 |
|
text => $token->{tag_name}, token => $token); |
| 6108 |
## Ignore the token |
## Ignore the token |
| 6109 |
!!!nack ('t282.1'); |
!!!nack ('t282.1'); |
| 6110 |
!!!next-token; |
!!!next-token; |
| 6122 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 6123 |
} else { |
} else { |
| 6124 |
!!!cp ('t285'); |
!!!cp ('t285'); |
| 6125 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
!!!parse-error (type => 'unmatched end tag', |
| 6126 |
|
text => $token->{tag_name}, token => $token); |
| 6127 |
## Ignore the token |
## Ignore the token |
| 6128 |
} |
} |
| 6129 |
!!!nack ('t285.1'); |
!!!nack ('t285.1'); |
| 6135 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 6136 |
} else { |
} else { |
| 6137 |
!!!cp ('t287'); |
!!!cp ('t287'); |
| 6138 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
!!!parse-error (type => 'unmatched end tag', |
| 6139 |
|
text => $token->{tag_name}, token => $token); |
| 6140 |
## Ignore the token |
## Ignore the token |
| 6141 |
} |
} |
| 6142 |
!!!nack ('t287.1'); |
!!!nack ('t287.1'); |
| 6158 |
} # INSCOPE |
} # INSCOPE |
| 6159 |
unless (defined $i) { |
unless (defined $i) { |
| 6160 |
!!!cp ('t290'); |
!!!cp ('t290'); |
| 6161 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
!!!parse-error (type => 'unmatched end tag', |
| 6162 |
|
text => $token->{tag_name}, token => $token); |
| 6163 |
## Ignore the token |
## Ignore the token |
| 6164 |
!!!nack ('t290.1'); |
!!!nack ('t290.1'); |
| 6165 |
!!!next-token; |
!!!next-token; |
| 6180 |
tfoot => 1, thead => 1, tr => 1, td => 1, th => 1, |
tfoot => 1, thead => 1, tr => 1, td => 1, th => 1, |
| 6181 |
}->{$token->{tag_name}}) { |
}->{$token->{tag_name}}) { |
| 6182 |
## TODO: The following is wrong? |
## TODO: The following is wrong? |
| 6183 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
!!!parse-error (type => 'unmatched end tag', |
| 6184 |
|
text => $token->{tag_name}, token => $token); |
| 6185 |
|
|
| 6186 |
## have an element in table scope |
## have an element in table scope |
| 6187 |
my $i; |
my $i; |
| 6222 |
unless (defined $i) { |
unless (defined $i) { |
| 6223 |
!!!cp ('t297'); |
!!!cp ('t297'); |
| 6224 |
## TODO: The following error type is correct? |
## TODO: The following error type is correct? |
| 6225 |
!!!parse-error (type => 'unmatched end tag:select', token => $token); |
!!!parse-error (type => 'unmatched end tag', |
| 6226 |
|
text => 'select', token => $token); |
| 6227 |
## Ignore the </select> token |
## Ignore the </select> token |
| 6228 |
!!!nack ('t297.1'); |
!!!nack ('t297.1'); |
| 6229 |
!!!next-token; ## TODO: ok? |
!!!next-token; ## TODO: ok? |
| 6240 |
next B; |
next B; |
| 6241 |
} else { |
} else { |
| 6242 |
!!!cp ('t299'); |
!!!cp ('t299'); |
| 6243 |
!!!parse-error (type => 'in select:/'.$token->{tag_name}, token => $token); |
!!!parse-error (type => 'in select:/', |
| 6244 |
|
text => $token->{tag_name}, token => $token); |
| 6245 |
## Ignore the token |
## Ignore the token |
| 6246 |
!!!nack ('t299.3'); |
!!!nack ('t299.3'); |
| 6247 |
!!!next-token; |
!!!next-token; |
| 6279 |
|
|
| 6280 |
if ($self->{insertion_mode} == AFTER_HTML_BODY_IM) { |
if ($self->{insertion_mode} == AFTER_HTML_BODY_IM) { |
| 6281 |
!!!cp ('t301'); |
!!!cp ('t301'); |
| 6282 |
!!!parse-error (type => 'after html:#character', token => $token); |
!!!parse-error (type => 'after html:#text', token => $token); |
| 6283 |
|
|
| 6284 |
## Reprocess in the "after body" insertion mode. |
## Reprocess in the "after body" insertion mode. |
| 6285 |
} else { |
} else { |
| 6287 |
} |
} |
| 6288 |
|
|
| 6289 |
## "after body" insertion mode |
## "after body" insertion mode |
| 6290 |
!!!parse-error (type => 'after body:#character', token => $token); |
!!!parse-error (type => 'after body:#text', token => $token); |
| 6291 |
|
|
| 6292 |
$self->{insertion_mode} = IN_BODY_IM; |
$self->{insertion_mode} = IN_BODY_IM; |
| 6293 |
## reprocess |
## reprocess |
| 6295 |
} elsif ($token->{type} == START_TAG_TOKEN) { |
} elsif ($token->{type} == START_TAG_TOKEN) { |
| 6296 |
if ($self->{insertion_mode} == AFTER_HTML_BODY_IM) { |
if ($self->{insertion_mode} == AFTER_HTML_BODY_IM) { |
| 6297 |
!!!cp ('t303'); |
!!!cp ('t303'); |
| 6298 |
!!!parse-error (type => 'after html:'.$token->{tag_name}, token => $token); |
!!!parse-error (type => 'after html', |
| 6299 |
|
text => $token->{tag_name}, token => $token); |
| 6300 |
|
|
| 6301 |
## Reprocess in the "after body" insertion mode. |
## Reprocess in the "after body" insertion mode. |
| 6302 |
} else { |
} else { |
| 6304 |
} |
} |
| 6305 |
|
|
| 6306 |
## "after body" insertion mode |
## "after body" insertion mode |
| 6307 |
!!!parse-error (type => 'after body:'.$token->{tag_name}, token => $token); |
!!!parse-error (type => 'after body', |
| 6308 |
|
text => $token->{tag_name}, token => $token); |
| 6309 |
|
|
| 6310 |
$self->{insertion_mode} = IN_BODY_IM; |
$self->{insertion_mode} = IN_BODY_IM; |
| 6311 |
!!!ack-later; |
!!!ack-later; |
| 6314 |
} elsif ($token->{type} == END_TAG_TOKEN) { |
} elsif ($token->{type} == END_TAG_TOKEN) { |
| 6315 |
if ($self->{insertion_mode} == AFTER_HTML_BODY_IM) { |
if ($self->{insertion_mode} == AFTER_HTML_BODY_IM) { |
| 6316 |
!!!cp ('t305'); |
!!!cp ('t305'); |
| 6317 |
!!!parse-error (type => 'after html:/'.$token->{tag_name}, token => $token); |
!!!parse-error (type => 'after html:/', |
| 6318 |
|
text => $token->{tag_name}, token => $token); |
| 6319 |
|
|
| 6320 |
$self->{insertion_mode} = AFTER_BODY_IM; |
$self->{insertion_mode} = AFTER_BODY_IM; |
| 6321 |
## Reprocess in the "after body" insertion mode. |
## Reprocess in the "after body" insertion mode. |
| 6327 |
if ($token->{tag_name} eq 'html') { |
if ($token->{tag_name} eq 'html') { |
| 6328 |
if (defined $self->{inner_html_node}) { |
if (defined $self->{inner_html_node}) { |
| 6329 |
!!!cp ('t307'); |
!!!cp ('t307'); |
| 6330 |
!!!parse-error (type => 'unmatched end tag:html', token => $token); |
!!!parse-error (type => 'unmatched end tag', |
| 6331 |
|
text => 'html', token => $token); |
| 6332 |
## Ignore the token |
## Ignore the token |
| 6333 |
!!!next-token; |
!!!next-token; |
| 6334 |
next B; |
next B; |
| 6340 |
} |
} |
| 6341 |
} else { |
} else { |
| 6342 |
!!!cp ('t309'); |
!!!cp ('t309'); |
| 6343 |
!!!parse-error (type => 'after body:/'.$token->{tag_name}, token => $token); |
!!!parse-error (type => 'after body:/', |
| 6344 |
|
text => $token->{tag_name}, token => $token); |
| 6345 |
|
|
| 6346 |
$self->{insertion_mode} = IN_BODY_IM; |
$self->{insertion_mode} = IN_BODY_IM; |
| 6347 |
## reprocess |
## reprocess |
| 6369 |
if ($token->{data} =~ s/^[^\x09\x0A\x0B\x0C\x20]+//) { |
if ($token->{data} =~ s/^[^\x09\x0A\x0B\x0C\x20]+//) { |
| 6370 |
if ($self->{insertion_mode} == IN_FRAMESET_IM) { |
if ($self->{insertion_mode} == IN_FRAMESET_IM) { |
| 6371 |
!!!cp ('t311'); |
!!!cp ('t311'); |
| 6372 |
!!!parse-error (type => 'in frameset:#character', token => $token); |
!!!parse-error (type => 'in frameset:#text', token => $token); |
| 6373 |
} elsif ($self->{insertion_mode} == AFTER_FRAMESET_IM) { |
} elsif ($self->{insertion_mode} == AFTER_FRAMESET_IM) { |
| 6374 |
!!!cp ('t312'); |
!!!cp ('t312'); |
| 6375 |
!!!parse-error (type => 'after frameset:#character', token => $token); |
!!!parse-error (type => 'after frameset:#text', token => $token); |
| 6376 |
} else { # "after html frameset" |
} else { # "after after frameset" |
| 6377 |
!!!cp ('t313'); |
!!!cp ('t313'); |
| 6378 |
!!!parse-error (type => 'after html:#character', token => $token); |
!!!parse-error (type => 'after html:#text', token => $token); |
|
|
|
|
$self->{insertion_mode} = AFTER_FRAMESET_IM; |
|
|
## Reprocess in the "after frameset" insertion mode. |
|
|
!!!parse-error (type => 'after frameset:#character', token => $token); |
|
| 6379 |
} |
} |
| 6380 |
|
|
| 6381 |
## Ignore the token. |
## Ignore the token. |
| 6391 |
|
|
| 6392 |
die qq[$0: Character "$token->{data}"]; |
die qq[$0: Character "$token->{data}"]; |
| 6393 |
} elsif ($token->{type} == START_TAG_TOKEN) { |
} elsif ($token->{type} == START_TAG_TOKEN) { |
|
if ($self->{insertion_mode} == AFTER_HTML_FRAMESET_IM) { |
|
|
!!!cp ('t316'); |
|
|
!!!parse-error (type => 'after html:'.$token->{tag_name}, token => $token); |
|
|
|
|
|
$self->{insertion_mode} = AFTER_FRAMESET_IM; |
|
|
## Process in the "after frameset" insertion mode. |
|
|
} else { |
|
|
!!!cp ('t317'); |
|
|
} |
|
|
|
|
| 6394 |
if ($token->{tag_name} eq 'frameset' and |
if ($token->{tag_name} eq 'frameset' and |
| 6395 |
$self->{insertion_mode} == IN_FRAMESET_IM) { |
$self->{insertion_mode} == IN_FRAMESET_IM) { |
| 6396 |
!!!cp ('t318'); |
!!!cp ('t318'); |
| 6408 |
next B; |
next B; |
| 6409 |
} elsif ($token->{tag_name} eq 'noframes') { |
} elsif ($token->{tag_name} eq 'noframes') { |
| 6410 |
!!!cp ('t320'); |
!!!cp ('t320'); |
| 6411 |
## NOTE: As if in body. |
## NOTE: As if in head. |
| 6412 |
$parse_rcdata->(CDATA_CONTENT_MODEL); |
$parse_rcdata->(CDATA_CONTENT_MODEL); |
| 6413 |
next B; |
next B; |
| 6414 |
|
|
| 6415 |
|
## NOTE: |<!DOCTYPE HTML><frameset></frameset></html><noframes></noframes>| |
| 6416 |
|
## has no parse error. |
| 6417 |
} else { |
} else { |
| 6418 |
if ($self->{insertion_mode} == IN_FRAMESET_IM) { |
if ($self->{insertion_mode} == IN_FRAMESET_IM) { |
| 6419 |
!!!cp ('t321'); |
!!!cp ('t321'); |
| 6420 |
!!!parse-error (type => 'in frameset:'.$token->{tag_name}, token => $token); |
!!!parse-error (type => 'in frameset', |
| 6421 |
} else { |
text => $token->{tag_name}, token => $token); |
| 6422 |
|
} elsif ($self->{insertion_mode} == AFTER_FRAMESET_IM) { |
| 6423 |
!!!cp ('t322'); |
!!!cp ('t322'); |
| 6424 |
!!!parse-error (type => 'after frameset:'.$token->{tag_name}, token => $token); |
!!!parse-error (type => 'after frameset', |
| 6425 |
|
text => $token->{tag_name}, token => $token); |
| 6426 |
|
} else { # "after after frameset" |
| 6427 |
|
!!!cp ('t322.2'); |
| 6428 |
|
!!!parse-error (type => 'after after frameset', |
| 6429 |
|
text => $token->{tag_name}, token => $token); |
| 6430 |
} |
} |
| 6431 |
## Ignore the token |
## Ignore the token |
| 6432 |
!!!nack ('t322.1'); |
!!!nack ('t322.1'); |
| 6434 |
next B; |
next B; |
| 6435 |
} |
} |
| 6436 |
} elsif ($token->{type} == END_TAG_TOKEN) { |
} elsif ($token->{type} == END_TAG_TOKEN) { |
|
if ($self->{insertion_mode} == AFTER_HTML_FRAMESET_IM) { |
|
|
!!!cp ('t323'); |
|
|
!!!parse-error (type => 'after html:/'.$token->{tag_name}, token => $token); |
|
|
|
|
|
$self->{insertion_mode} = AFTER_FRAMESET_IM; |
|
|
## Process in the "after frameset" insertion mode. |
|
|
} else { |
|
|
!!!cp ('t324'); |
|
|
} |
|
|
|
|
| 6437 |
if ($token->{tag_name} eq 'frameset' and |
if ($token->{tag_name} eq 'frameset' and |
| 6438 |
$self->{insertion_mode} == IN_FRAMESET_IM) { |
$self->{insertion_mode} == IN_FRAMESET_IM) { |
| 6439 |
if ($self->{open_elements}->[-1]->[1] & HTML_EL and |
if ($self->{open_elements}->[-1]->[1] & HTML_EL and |
| 6440 |
@{$self->{open_elements}} == 1) { |
@{$self->{open_elements}} == 1) { |
| 6441 |
!!!cp ('t325'); |
!!!cp ('t325'); |
| 6442 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
!!!parse-error (type => 'unmatched end tag', |
| 6443 |
|
text => $token->{tag_name}, token => $token); |
| 6444 |
## Ignore the token |
## Ignore the token |
| 6445 |
!!!next-token; |
!!!next-token; |
| 6446 |
} else { |
} else { |
| 6466 |
} else { |
} else { |
| 6467 |
if ($self->{insertion_mode} == IN_FRAMESET_IM) { |
if ($self->{insertion_mode} == IN_FRAMESET_IM) { |
| 6468 |
!!!cp ('t330'); |
!!!cp ('t330'); |
| 6469 |
!!!parse-error (type => 'in frameset:/'.$token->{tag_name}, token => $token); |
!!!parse-error (type => 'in frameset:/', |
| 6470 |
} else { |
text => $token->{tag_name}, token => $token); |
| 6471 |
|
} elsif ($self->{insertion_mode} == AFTER_FRAMESET_IM) { |
| 6472 |
|
!!!cp ('t330.1'); |
| 6473 |
|
!!!parse-error (type => 'after frameset:/', |
| 6474 |
|
text => $token->{tag_name}, token => $token); |
| 6475 |
|
} else { # "after after html" |
| 6476 |
!!!cp ('t331'); |
!!!cp ('t331'); |
| 6477 |
!!!parse-error (type => 'after frameset:/'.$token->{tag_name}, token => $token); |
!!!parse-error (type => 'after after frameset:/', |
| 6478 |
|
text => $token->{tag_name}, token => $token); |
| 6479 |
} |
} |
| 6480 |
## Ignore the token |
## Ignore the token |
| 6481 |
!!!next-token; |
!!!next-token; |
| 6529 |
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. |
| 6530 |
|
|
| 6531 |
unless ($self->{confident}) { |
unless ($self->{confident}) { |
| 6532 |
if ($token->{attributes}->{charset}) { ## TODO: And if supported |
if ($token->{attributes}->{charset}) { |
| 6533 |
!!!cp ('t335'); |
!!!cp ('t335'); |
| 6534 |
|
## NOTE: Whether the encoding is supported or not is handled |
| 6535 |
|
## in the {change_encoding} callback. |
| 6536 |
$self->{change_encoding} |
$self->{change_encoding} |
| 6537 |
->($self, $token->{attributes}->{charset}->{value}, $token); |
->($self, $token->{attributes}->{charset}->{value}, $token); |
| 6538 |
|
|
| 6541 |
$token->{attributes}->{charset} |
$token->{attributes}->{charset} |
| 6542 |
->{has_reference}); |
->{has_reference}); |
| 6543 |
} elsif ($token->{attributes}->{content}) { |
} elsif ($token->{attributes}->{content}) { |
|
## ISSUE: Algorithm name in the spec was incorrect so that not linked to the definition. |
|
| 6544 |
if ($token->{attributes}->{content}->{value} |
if ($token->{attributes}->{content}->{value} |
| 6545 |
=~ /\A[^;]*;[\x09-\x0D\x20]*[Cc][Hh][Aa][Rr][Ss][Ee][Tt] |
=~ /[Cc][Hh][Aa][Rr][Ss][Ee][Tt] |
| 6546 |
[\x09-\x0D\x20]*= |
[\x09-\x0D\x20]*= |
| 6547 |
[\x09-\x0D\x20]*(?>"([^"]*)"|'([^']*)'| |
[\x09-\x0D\x20]*(?>"([^"]*)"|'([^']*)'| |
| 6548 |
([^"'\x09-\x0D\x20][^\x09-\x0D\x20]*))/x) { |
([^"'\x09-\x0D\x20][^\x09-\x0D\x20\x3B]*))/x) { |
| 6549 |
!!!cp ('t336'); |
!!!cp ('t336'); |
| 6550 |
|
## NOTE: Whether the encoding is supported or not is handled |
| 6551 |
|
## in the {change_encoding} callback. |
| 6552 |
$self->{change_encoding} |
$self->{change_encoding} |
| 6553 |
->($self, defined $1 ? $1 : defined $2 ? $2 : $3, $token); |
->($self, defined $1 ? $1 : defined $2 ? $2 : $3, $token); |
| 6554 |
$meta_el->[0]->get_attribute_node_ns (undef, 'content') |
$meta_el->[0]->get_attribute_node_ns (undef, 'content') |
| 6583 |
$parse_rcdata->(RCDATA_CONTENT_MODEL); |
$parse_rcdata->(RCDATA_CONTENT_MODEL); |
| 6584 |
next B; |
next B; |
| 6585 |
} elsif ($token->{tag_name} eq 'body') { |
} elsif ($token->{tag_name} eq 'body') { |
| 6586 |
!!!parse-error (type => 'in body:body', token => $token); |
!!!parse-error (type => 'in body', text => 'body', token => $token); |
| 6587 |
|
|
| 6588 |
if (@{$self->{open_elements}} == 1 or |
if (@{$self->{open_elements}} == 1 or |
| 6589 |
not ($self->{open_elements}->[1]->[1] & BODY_EL)) { |
not ($self->{open_elements}->[1]->[1] & BODY_EL)) { |
| 6703 |
if ($i != -1) { |
if ($i != -1) { |
| 6704 |
!!!cp ('t355'); |
!!!cp ('t355'); |
| 6705 |
!!!parse-error (type => 'not closed', |
!!!parse-error (type => 'not closed', |
| 6706 |
value => $self->{open_elements}->[-1]->[0] |
text => $self->{open_elements}->[-1]->[0] |
| 6707 |
->manakai_local_name, |
->manakai_local_name, |
| 6708 |
token => $token); |
token => $token); |
| 6709 |
} else { |
} else { |
| 6857 |
xmp => 1, |
xmp => 1, |
| 6858 |
iframe => 1, |
iframe => 1, |
| 6859 |
noembed => 1, |
noembed => 1, |
| 6860 |
noframes => 1, |
noframes => 1, ## NOTE: This is an "as if in head" code clone. |
| 6861 |
noscript => 0, ## TODO: 1 if scripting is enabled |
noscript => 0, ## TODO: 1 if scripting is enabled |
| 6862 |
}->{$token->{tag_name}}) { |
}->{$token->{tag_name}}) { |
| 6863 |
if ($token->{tag_name} eq 'xmp') { |
if ($token->{tag_name} eq 'xmp') { |
| 6879 |
!!!next-token; |
!!!next-token; |
| 6880 |
next B; |
next B; |
| 6881 |
} else { |
} else { |
| 6882 |
|
!!!ack ('t391.1'); |
| 6883 |
|
|
| 6884 |
my $at = $token->{attributes}; |
my $at = $token->{attributes}; |
| 6885 |
my $form_attrs; |
my $form_attrs; |
| 6886 |
$form_attrs->{action} = $at->{action} if $at->{action}; |
$form_attrs->{action} = $at->{action} if $at->{action}; |
| 6924 |
line => $token->{line}, column => $token->{column}}, |
line => $token->{line}, column => $token->{column}}, |
| 6925 |
{type => END_TAG_TOKEN, tag_name => 'form', |
{type => END_TAG_TOKEN, tag_name => 'form', |
| 6926 |
line => $token->{line}, column => $token->{column}}; |
line => $token->{line}, column => $token->{column}}; |
|
!!!nack ('t391.1'); ## NOTE: Not acknowledged. |
|
| 6927 |
!!!back-token (@tokens); |
!!!back-token (@tokens); |
| 6928 |
!!!next-token; |
!!!next-token; |
| 6929 |
next B; |
next B; |
| 6971 |
## Ignore the token |
## Ignore the token |
| 6972 |
} else { |
} else { |
| 6973 |
!!!cp ('t398'); |
!!!cp ('t398'); |
| 6974 |
!!!parse-error (type => 'in RCDATA:#'.$token->{type}, token => $token); |
!!!parse-error (type => 'in RCDATA:#eof', token => $token); |
| 6975 |
} |
} |
| 6976 |
!!!next-token; |
!!!next-token; |
| 6977 |
next B; |
next B; |
| 6978 |
|
} elsif ($token->{tag_name} eq 'rt' or |
| 6979 |
|
$token->{tag_name} eq 'rp') { |
| 6980 |
|
## has a |ruby| element in scope |
| 6981 |
|
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
| 6982 |
|
my $node = $self->{open_elements}->[$_]; |
| 6983 |
|
if ($node->[1] & RUBY_EL) { |
| 6984 |
|
!!!cp ('t398.1'); |
| 6985 |
|
## generate implied end tags |
| 6986 |
|
while ($self->{open_elements}->[-1]->[1] & END_TAG_OPTIONAL_EL) { |
| 6987 |
|
!!!cp ('t398.2'); |
| 6988 |
|
pop @{$self->{open_elements}}; |
| 6989 |
|
} |
| 6990 |
|
unless ($self->{open_elements}->[-1]->[1] & RUBY_EL) { |
| 6991 |
|
!!!cp ('t398.3'); |
| 6992 |
|
!!!parse-error (type => 'not closed', |
| 6993 |
|
text => $self->{open_elements}->[-1]->[0] |
| 6994 |
|
->manakai_local_name, |
| 6995 |
|
token => $token); |
| 6996 |
|
pop @{$self->{open_elements}} |
| 6997 |
|
while not $self->{open_elements}->[-1]->[1] & RUBY_EL; |
| 6998 |
|
} |
| 6999 |
|
last INSCOPE; |
| 7000 |
|
} elsif ($node->[1] & SCOPING_EL) { |
| 7001 |
|
!!!cp ('t398.4'); |
| 7002 |
|
last INSCOPE; |
| 7003 |
|
} |
| 7004 |
|
} # INSCOPE |
| 7005 |
|
|
| 7006 |
|
!!!insert-element-t ($token->{tag_name}, $token->{attributes}, $token); |
| 7007 |
|
|
| 7008 |
|
!!!nack ('t398.5'); |
| 7009 |
|
!!!next-token; |
| 7010 |
|
redo B; |
| 7011 |
} elsif ($token->{tag_name} eq 'math' or |
} elsif ($token->{tag_name} eq 'math' or |
| 7012 |
$token->{tag_name} eq 'svg') { |
$token->{tag_name} eq 'svg') { |
| 7013 |
$reconstruct_active_formatting_elements->($insert_to_current); |
$reconstruct_active_formatting_elements->($insert_to_current); |
| 7014 |
|
|
| 7015 |
|
## "Adjust MathML attributes" ('math' only) - done in insert-element-f |
| 7016 |
|
|
| 7017 |
|
## "adjust SVG attributes" ('svg' only) - done in insert-element-f |
| 7018 |
|
|
| 7019 |
|
## "adjust foreign attributes" - done in insert-element-f |
| 7020 |
|
|
| 7021 |
!!!insert-element-f ($token->{tag_name} eq 'math' ? $MML_NS : $SVG_NS, $token); |
!!!insert-element-f ($token->{tag_name} eq 'math' ? $MML_NS : $SVG_NS, $token->{tag_name}, $token->{attributes}, $token); |
| 7022 |
|
|
| 7023 |
if ($self->{self_closing}) { |
if ($self->{self_closing}) { |
| 7024 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 7040 |
thead => 1, tr => 1, |
thead => 1, tr => 1, |
| 7041 |
}->{$token->{tag_name}}) { |
}->{$token->{tag_name}}) { |
| 7042 |
!!!cp ('t401'); |
!!!cp ('t401'); |
| 7043 |
!!!parse-error (type => 'in body:'.$token->{tag_name}, token => $token); |
!!!parse-error (type => 'in body', |
| 7044 |
|
text => $token->{tag_name}, token => $token); |
| 7045 |
## Ignore the token |
## Ignore the token |
| 7046 |
!!!nack ('t401.1'); ## NOTE: |<col/>| or |<frame/>| here is an error. |
!!!nack ('t401.1'); ## NOTE: |<col/>| or |<frame/>| here is an error. |
| 7047 |
!!!next-token; |
!!!next-token; |
| 7126 |
} |
} |
| 7127 |
|
|
| 7128 |
!!!parse-error (type => 'start tag not allowed', |
!!!parse-error (type => 'start tag not allowed', |
| 7129 |
value => $token->{tag_name}, token => $token); |
text => $token->{tag_name}, token => $token); |
| 7130 |
## NOTE: Ignore the token. |
## NOTE: Ignore the token. |
| 7131 |
!!!next-token; |
!!!next-token; |
| 7132 |
next B; |
next B; |
| 7136 |
unless ($_->[1] & ALL_END_TAG_OPTIONAL_EL) { |
unless ($_->[1] & ALL_END_TAG_OPTIONAL_EL) { |
| 7137 |
!!!cp ('t403'); |
!!!cp ('t403'); |
| 7138 |
!!!parse-error (type => 'not closed', |
!!!parse-error (type => 'not closed', |
| 7139 |
value => $_->[0]->manakai_local_name, |
text => $_->[0]->manakai_local_name, |
| 7140 |
token => $token); |
token => $token); |
| 7141 |
last; |
last; |
| 7142 |
} else { |
} else { |
| 7156 |
unless ($self->{open_elements}->[-1]->[1] & BODY_EL) { |
unless ($self->{open_elements}->[-1]->[1] & BODY_EL) { |
| 7157 |
!!!cp ('t406'); |
!!!cp ('t406'); |
| 7158 |
!!!parse-error (type => 'not closed', |
!!!parse-error (type => 'not closed', |
| 7159 |
value => $self->{open_elements}->[1]->[0] |
text => $self->{open_elements}->[1]->[0] |
| 7160 |
->manakai_local_name, |
->manakai_local_name, |
| 7161 |
token => $token); |
token => $token); |
| 7162 |
} else { |
} else { |
| 7167 |
next B; |
next B; |
| 7168 |
} else { |
} else { |
| 7169 |
!!!cp ('t408'); |
!!!cp ('t408'); |
| 7170 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
!!!parse-error (type => 'unmatched end tag', |
| 7171 |
|
text => $token->{tag_name}, token => $token); |
| 7172 |
## Ignore the token |
## Ignore the token |
| 7173 |
!!!next-token; |
!!!next-token; |
| 7174 |
next B; |
next B; |
| 7196 |
|
|
| 7197 |
unless (defined $i) { # has an element in scope |
unless (defined $i) { # has an element in scope |
| 7198 |
!!!cp ('t413'); |
!!!cp ('t413'); |
| 7199 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
!!!parse-error (type => 'unmatched end tag', |
| 7200 |
|
text => $token->{tag_name}, token => $token); |
| 7201 |
|
## NOTE: Ignore the token. |
| 7202 |
} else { |
} else { |
| 7203 |
## Step 1. generate implied end tags |
## Step 1. generate implied end tags |
| 7204 |
while ({ |
while ({ |
| 7205 |
|
## END_TAG_OPTIONAL_EL |
| 7206 |
dd => ($token->{tag_name} ne 'dd'), |
dd => ($token->{tag_name} ne 'dd'), |
| 7207 |
dt => ($token->{tag_name} ne 'dt'), |
dt => ($token->{tag_name} ne 'dt'), |
| 7208 |
li => ($token->{tag_name} ne 'li'), |
li => ($token->{tag_name} ne 'li'), |
| 7209 |
p => 1, |
p => 1, |
| 7210 |
|
rt => 1, |
| 7211 |
|
rp => 1, |
| 7212 |
}->{$self->{open_elements}->[-1]->[0]->manakai_local_name}) { |
}->{$self->{open_elements}->[-1]->[0]->manakai_local_name}) { |
| 7213 |
!!!cp ('t409'); |
!!!cp ('t409'); |
| 7214 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 7219 |
ne $token->{tag_name}) { |
ne $token->{tag_name}) { |
| 7220 |
!!!cp ('t412'); |
!!!cp ('t412'); |
| 7221 |
!!!parse-error (type => 'not closed', |
!!!parse-error (type => 'not closed', |
| 7222 |
value => $self->{open_elements}->[-1]->[0] |
text => $self->{open_elements}->[-1]->[0] |
| 7223 |
->manakai_local_name, |
->manakai_local_name, |
| 7224 |
token => $token); |
token => $token); |
| 7225 |
} else { |
} else { |
| 7256 |
|
|
| 7257 |
unless (defined $i) { # has an element in scope |
unless (defined $i) { # has an element in scope |
| 7258 |
!!!cp ('t421'); |
!!!cp ('t421'); |
| 7259 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
!!!parse-error (type => 'unmatched end tag', |
| 7260 |
|
text => $token->{tag_name}, token => $token); |
| 7261 |
|
## NOTE: Ignore the token. |
| 7262 |
} else { |
} else { |
| 7263 |
## Step 1. generate implied end tags |
## Step 1. generate implied end tags |
| 7264 |
while ($self->{open_elements}->[-1]->[1] & END_TAG_OPTIONAL_EL) { |
while ($self->{open_elements}->[-1]->[1] & END_TAG_OPTIONAL_EL) { |
| 7271 |
ne $token->{tag_name}) { |
ne $token->{tag_name}) { |
| 7272 |
!!!cp ('t417.1'); |
!!!cp ('t417.1'); |
| 7273 |
!!!parse-error (type => 'not closed', |
!!!parse-error (type => 'not closed', |
| 7274 |
value => $self->{open_elements}->[-1]->[0] |
text => $self->{open_elements}->[-1]->[0] |
| 7275 |
->manakai_local_name, |
->manakai_local_name, |
| 7276 |
token => $token); |
token => $token); |
| 7277 |
} else { |
} else { |
| 7303 |
|
|
| 7304 |
unless (defined $i) { # has an element in scope |
unless (defined $i) { # has an element in scope |
| 7305 |
!!!cp ('t425.1'); |
!!!cp ('t425.1'); |
| 7306 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
!!!parse-error (type => 'unmatched end tag', |
| 7307 |
|
text => $token->{tag_name}, token => $token); |
| 7308 |
|
## NOTE: Ignore the token. |
| 7309 |
} else { |
} else { |
| 7310 |
## Step 1. generate implied end tags |
## Step 1. generate implied end tags |
| 7311 |
while ($self->{open_elements}->[-1]->[1] & END_TAG_OPTIONAL_EL) { |
while ($self->{open_elements}->[-1]->[1] & END_TAG_OPTIONAL_EL) { |
| 7317 |
if ($self->{open_elements}->[-1]->[0]->manakai_local_name |
if ($self->{open_elements}->[-1]->[0]->manakai_local_name |
| 7318 |
ne $token->{tag_name}) { |
ne $token->{tag_name}) { |
| 7319 |
!!!cp ('t425'); |
!!!cp ('t425'); |
| 7320 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
!!!parse-error (type => 'unmatched end tag', |
| 7321 |
|
text => $token->{tag_name}, token => $token); |
| 7322 |
} else { |
} else { |
| 7323 |
!!!cp ('t426'); |
!!!cp ('t426'); |
| 7324 |
} |
} |
| 7349 |
ne $token->{tag_name}) { |
ne $token->{tag_name}) { |
| 7350 |
!!!cp ('t412.1'); |
!!!cp ('t412.1'); |
| 7351 |
!!!parse-error (type => 'not closed', |
!!!parse-error (type => 'not closed', |
| 7352 |
value => $self->{open_elements}->[-1]->[0] |
text => $self->{open_elements}->[-1]->[0] |
| 7353 |
->manakai_local_name, |
->manakai_local_name, |
| 7354 |
token => $token); |
token => $token); |
| 7355 |
} else { |
} else { |
| 7359 |
splice @{$self->{open_elements}}, $i; |
splice @{$self->{open_elements}}, $i; |
| 7360 |
} else { |
} else { |
| 7361 |
!!!cp ('t413.1'); |
!!!cp ('t413.1'); |
| 7362 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
!!!parse-error (type => 'unmatched end tag', |
| 7363 |
|
text => $token->{tag_name}, token => $token); |
| 7364 |
|
|
| 7365 |
!!!cp ('t415.1'); |
!!!cp ('t415.1'); |
| 7366 |
## As if <p>, then reprocess the current token |
## As if <p>, then reprocess the current token |
| 7383 |
next B; |
next B; |
| 7384 |
} elsif ($token->{tag_name} eq 'br') { |
} elsif ($token->{tag_name} eq 'br') { |
| 7385 |
!!!cp ('t428'); |
!!!cp ('t428'); |
| 7386 |
!!!parse-error (type => 'unmatched end tag:br', token => $token); |
!!!parse-error (type => 'unmatched end tag', |
| 7387 |
|
text => 'br', token => $token); |
| 7388 |
|
|
| 7389 |
## As if <br> |
## As if <br> |
| 7390 |
$reconstruct_active_formatting_elements->($insert_to_current); |
$reconstruct_active_formatting_elements->($insert_to_current); |
| 7409 |
noscript => 0, ## TODO: if scripting is enabled |
noscript => 0, ## TODO: if scripting is enabled |
| 7410 |
}->{$token->{tag_name}}) { |
}->{$token->{tag_name}}) { |
| 7411 |
!!!cp ('t429'); |
!!!cp ('t429'); |
| 7412 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
!!!parse-error (type => 'unmatched end tag', |
| 7413 |
|
text => $token->{tag_name}, token => $token); |
| 7414 |
## Ignore the token |
## Ignore the token |
| 7415 |
!!!next-token; |
!!!next-token; |
| 7416 |
next B; |
next B; |
| 7429 |
## generate implied end tags |
## generate implied end tags |
| 7430 |
while ($self->{open_elements}->[-1]->[1] & END_TAG_OPTIONAL_EL) { |
while ($self->{open_elements}->[-1]->[1] & END_TAG_OPTIONAL_EL) { |
| 7431 |
!!!cp ('t430'); |
!!!cp ('t430'); |
| 7432 |
## ISSUE: Can this case be reached? |
## NOTE: |<ruby><rt></ruby>|. |
| 7433 |
|
## ISSUE: <ruby><rt></rt> will also take this code path, |
| 7434 |
|
## which seems wrong. |
| 7435 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 7436 |
|
$node_i++; |
| 7437 |
} |
} |
| 7438 |
|
|
| 7439 |
## Step 2 |
## Step 2 |
| 7442 |
!!!cp ('t431'); |
!!!cp ('t431'); |
| 7443 |
## NOTE: <x><y></x> |
## NOTE: <x><y></x> |
| 7444 |
!!!parse-error (type => 'not closed', |
!!!parse-error (type => 'not closed', |
| 7445 |
value => $self->{open_elements}->[-1]->[0] |
text => $self->{open_elements}->[-1]->[0] |
| 7446 |
->manakai_local_name, |
->manakai_local_name, |
| 7447 |
token => $token); |
token => $token); |
| 7448 |
} else { |
} else { |
| 7450 |
} |
} |
| 7451 |
|
|
| 7452 |
## Step 3 |
## Step 3 |
| 7453 |
splice @{$self->{open_elements}}, $node_i; |
splice @{$self->{open_elements}}, $node_i if $node_i < 0; |
| 7454 |
|
|
| 7455 |
!!!next-token; |
!!!next-token; |
| 7456 |
last S2; |
last S2; |
| 7461 |
($node->[1] & SPECIAL_EL or |
($node->[1] & SPECIAL_EL or |
| 7462 |
$node->[1] & SCOPING_EL)) { |
$node->[1] & SCOPING_EL)) { |
| 7463 |
!!!cp ('t433'); |
!!!cp ('t433'); |
| 7464 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
!!!parse-error (type => 'unmatched end tag', |
| 7465 |
|
text => $token->{tag_name}, token => $token); |
| 7466 |
## Ignore the token |
## Ignore the token |
| 7467 |
!!!next-token; |
!!!next-token; |
| 7468 |
last S2; |
last S2; |
| 7508 |
## TODO: script stuffs |
## TODO: script stuffs |
| 7509 |
} # _tree_construct_main |
} # _tree_construct_main |
| 7510 |
|
|
| 7511 |
sub set_inner_html ($$$) { |
sub set_inner_html ($$$;$) { |
| 7512 |
my $class = shift; |
my $class = shift; |
| 7513 |
my $node = shift; |
my $node = shift; |
| 7514 |
my $s = \$_[0]; |
my $s = \$_[0]; |
| 7515 |
my $onerror = $_[1]; |
my $onerror = $_[1]; |
| 7516 |
|
my $get_wrapper = $_[2] || sub ($) { return $_[0] }; |
| 7517 |
|
|
| 7518 |
## ISSUE: Should {confident} be true? |
## ISSUE: Should {confident} be true? |
| 7519 |
|
|
| 7532 |
} |
} |
| 7533 |
|
|
| 7534 |
## Step 3, 4, 5 # MUST |
## Step 3, 4, 5 # MUST |
| 7535 |
$class->parse_string ($$s => $node, $onerror); |
$class->parse_char_string ($$s => $node, $onerror, $get_wrapper); |
| 7536 |
} elsif ($nt == 1) { |
} elsif ($nt == 1) { |
| 7537 |
## TODO: If non-html element |
## TODO: If non-html element |
| 7538 |
|
|
| 7539 |
## NOTE: Most of this code is copied from |parse_string| |
## NOTE: Most of this code is copied from |parse_string| |
| 7540 |
|
|
| 7541 |
|
## TODO: Support for $get_wrapper |
| 7542 |
|
|
| 7543 |
## Step 1 # MUST |
## Step 1 # MUST |
| 7544 |
my $this_doc = $node->owner_document; |
my $this_doc = $node->owner_document; |
| 7545 |
my $doc = $this_doc->implementation->create_document; |
my $doc = $this_doc->implementation->create_document; |
| 7580 |
!!!cp ('i4'); |
!!!cp ('i4'); |
| 7581 |
!!!parse-error (type => 'NULL'); |
!!!parse-error (type => 'NULL'); |
| 7582 |
$self->{next_char} = 0xFFFD; # REPLACEMENT CHARACTER # MUST |
$self->{next_char} = 0xFFFD; # REPLACEMENT CHARACTER # MUST |
| 7583 |
|
} elsif ($self->{next_char} <= 0x0008 or |
| 7584 |
|
(0x000E <= $self->{next_char} and |
| 7585 |
|
$self->{next_char} <= 0x001F) or |
| 7586 |
|
(0x007F <= $self->{next_char} and |
| 7587 |
|
$self->{next_char} <= 0x009F) or |
| 7588 |
|
(0xD800 <= $self->{next_char} and |
| 7589 |
|
$self->{next_char} <= 0xDFFF) or |
| 7590 |
|
(0xFDD0 <= $self->{next_char} and |
| 7591 |
|
$self->{next_char} <= 0xFDDF) or |
| 7592 |
|
{ |
| 7593 |
|
0xFFFE => 1, 0xFFFF => 1, 0x1FFFE => 1, 0x1FFFF => 1, |
| 7594 |
|
0x2FFFE => 1, 0x2FFFF => 1, 0x3FFFE => 1, 0x3FFFF => 1, |
| 7595 |
|
0x4FFFE => 1, 0x4FFFF => 1, 0x5FFFE => 1, 0x5FFFF => 1, |
| 7596 |
|
0x6FFFE => 1, 0x6FFFF => 1, 0x7FFFE => 1, 0x7FFFF => 1, |
| 7597 |
|
0x8FFFE => 1, 0x8FFFF => 1, 0x9FFFE => 1, 0x9FFFF => 1, |
| 7598 |
|
0xAFFFE => 1, 0xAFFFF => 1, 0xBFFFE => 1, 0xBFFFF => 1, |
| 7599 |
|
0xCFFFE => 1, 0xCFFFF => 1, 0xDFFFE => 1, 0xDFFFF => 1, |
| 7600 |
|
0xEFFFE => 1, 0xEFFFF => 1, 0xFFFFE => 1, 0xFFFFF => 1, |
| 7601 |
|
0x10FFFE => 1, 0x10FFFF => 1, |
| 7602 |
|
}->{$self->{next_char}}) { |
| 7603 |
|
!!!cp ('i4.1'); |
| 7604 |
|
if ($self->{next_char} < 0x10000) { |
| 7605 |
|
!!!parse-error (type => 'control char', |
| 7606 |
|
text => (sprintf 'U+%04X', $self->{next_char})); |
| 7607 |
|
} else { |
| 7608 |
|
!!!parse-error (type => 'control char', |
| 7609 |
|
text => (sprintf 'U-%08X', $self->{next_char})); |
| 7610 |
|
} |
| 7611 |
} |
} |
| 7612 |
}; |
}; |
| 7613 |
$p->{prev_char} = [-1, -1, -1]; |
$p->{prev_char} = [-1, -1, -1]; |