| 2067 |
th => 'in cell', |
th => 'in cell', |
| 2068 |
tr => 'in row', |
tr => 'in row', |
| 2069 |
tbody => 'in table body', |
tbody => 'in table body', |
| 2070 |
thead => 'in table head', |
thead => 'in table body', |
| 2071 |
tfoot => 'in table foot', |
tfoot => 'in table body', |
| 2072 |
caption => 'in caption', |
caption => 'in caption', |
| 2073 |
colgroup => 'in column group', |
colgroup => 'in column group', |
| 2074 |
table => 'in table', |
table => 'in table', |
| 3046 |
noframes => 1, |
noframes => 1, |
| 3047 |
noscript => 0, ## TODO: 1 if scripting is enabled |
noscript => 0, ## TODO: 1 if scripting is enabled |
| 3048 |
}->{$token->{tag_name}}) { |
}->{$token->{tag_name}}) { |
| 3049 |
|
## NOTE: There are two "as if in body" code clones. |
| 3050 |
$parse_rcdata->(CDATA_CONTENT_MODEL, $insert); |
$parse_rcdata->(CDATA_CONTENT_MODEL, $insert); |
| 3051 |
return; |
return; |
| 3052 |
} elsif ($token->{tag_name} eq 'select') { |
} elsif ($token->{tag_name} eq 'select') { |
| 3409 |
} |
} |
| 3410 |
!!!next-token; |
!!!next-token; |
| 3411 |
redo B; |
redo B; |
| 3412 |
} elsif ($self->{insertion_mode} eq 'before head') { |
} elsif ($self->{insertion_mode} eq 'in head' or |
| 3413 |
if ($token->{type} eq 'character') { |
$self->{insertion_mode} eq 'in head noscript' or |
| 3414 |
if ($token->{data} =~ s/^([\x09\x0A\x0B\x0C\x20]+)//) { |
$self->{insertion_mode} eq 'after head' or |
| 3415 |
$self->{open_elements}->[-1]->[0]->manakai_append_text ($1); |
$self->{insertion_mode} eq 'before head') { |
| 3416 |
unless (length $token->{data}) { |
if ($token->{type} eq 'character') { |
| 3417 |
!!!next-token; |
if ($token->{data} =~ s/^([\x09\x0A\x0B\x0C\x20]+)//) { |
| 3418 |
redo B; |
$self->{open_elements}->[-1]->[0]->manakai_append_text ($1); |
| 3419 |
} |
unless (length $token->{data}) { |
| 3420 |
} |
!!!next-token; |
| 3421 |
## As if <head> |
redo B; |
| 3422 |
!!!create-element ($self->{head_element}, 'head'); |
} |
| 3423 |
$self->{open_elements}->[-1]->[0]->append_child ($self->{head_element}); |
} |
| 3424 |
push @{$self->{open_elements}}, [$self->{head_element}, 'head']; |
|
| 3425 |
$self->{insertion_mode} = 'in head'; |
if ($self->{insertion_mode} eq 'before head') { |
| 3426 |
|
## As if <head> |
| 3427 |
|
!!!create-element ($self->{head_element}, 'head'); |
| 3428 |
|
$self->{open_elements}->[-1]->[0]->append_child ($self->{head_element}); |
| 3429 |
|
push @{$self->{open_elements}}, [$self->{head_element}, 'head']; |
| 3430 |
|
|
| 3431 |
|
## Reprocess in the "in head" insertion mode... |
| 3432 |
|
pop @{$self->{open_elements}}; |
| 3433 |
|
|
| 3434 |
|
## Reprocess in the "after head" insertion mode... |
| 3435 |
|
} elsif ($self->{insertion_mode} eq 'in head noscript') { |
| 3436 |
|
## As if </noscript> |
| 3437 |
|
pop @{$self->{open_elements}}; |
| 3438 |
|
!!!parse-error (type => 'in noscript:#character'); |
| 3439 |
|
|
| 3440 |
|
## Reprocess in the "in head" insertion mode... |
| 3441 |
|
## As if </head> |
| 3442 |
|
pop @{$self->{open_elements}}; |
| 3443 |
|
|
| 3444 |
|
## Reprocess in the "after head" insertion mode... |
| 3445 |
|
} elsif ($self->{insertion_mode} eq 'in head') { |
| 3446 |
|
pop @{$self->{open_elements}}; |
| 3447 |
|
|
| 3448 |
|
## Reprocess in the "after head" insertion mode... |
| 3449 |
|
} |
| 3450 |
|
|
| 3451 |
|
## "after head" insertion mode |
| 3452 |
|
## As if <body> |
| 3453 |
|
!!!insert-element ('body'); |
| 3454 |
|
$self->{insertion_mode} = 'in body'; |
| 3455 |
## reprocess |
## reprocess |
| 3456 |
redo B; |
redo B; |
| 3457 |
} elsif ($token->{type} eq 'start tag') { |
} elsif ($token->{type} eq 'start tag') { |
|
my $attr = $token->{tag_name} eq 'head' ? $token->{attributes} : {}; |
|
|
!!!create-element ($self->{head_element}, 'head', $attr); |
|
|
$self->{open_elements}->[-1]->[0]->append_child ($self->{head_element}); |
|
|
push @{$self->{open_elements}}, [$self->{head_element}, 'head']; |
|
|
$self->{insertion_mode} = 'in head'; |
|
| 3458 |
if ($token->{tag_name} eq 'head') { |
if ($token->{tag_name} eq 'head') { |
| 3459 |
!!!next-token; |
if ($self->{insertion_mode} eq 'before head') { |
| 3460 |
#} elsif ({ |
!!!create-element ($self->{head_element}, $token->{tag_name}, $token->{attributes}); |
| 3461 |
# base => 1, link => 1, meta => 1, |
$self->{open_elements}->[-1]->[0]->append_child ($self->{head_element}); |
| 3462 |
# script => 1, style => 1, title => 1, |
push @{$self->{open_elements}}, [$self->{head_element}, $token->{tag_name}]; |
| 3463 |
# }->{$token->{tag_name}}) { |
$self->{insertion_mode} = 'in head'; |
| 3464 |
# ## reprocess |
!!!next-token; |
| 3465 |
} else { |
redo B; |
| 3466 |
## reprocess |
} elsif ($self->{insertion_mode} ne 'after head') { |
| 3467 |
} |
!!!parse-error (type => 'in head:head'); # or in head noscript |
| 3468 |
redo B; |
## Ignore the token |
| 3469 |
} elsif ($token->{type} eq 'end tag') { |
!!!next-token; |
| 3470 |
if ({ |
redo B; |
| 3471 |
head => 1, body => 1, html => 1, |
} else { |
| 3472 |
p => 1, br => 1, |
# |
| 3473 |
}->{$token->{tag_name}}) { |
} |
| 3474 |
|
} elsif ($self->{insertion_mode} eq 'before head') { |
| 3475 |
## As if <head> |
## As if <head> |
| 3476 |
!!!create-element ($self->{head_element}, 'head'); |
!!!create-element ($self->{head_element}, 'head'); |
| 3477 |
$self->{open_elements}->[-1]->[0]->append_child ($self->{head_element}); |
$self->{open_elements}->[-1]->[0]->append_child ($self->{head_element}); |
| 3478 |
push @{$self->{open_elements}}, [$self->{head_element}, 'head']; |
push @{$self->{open_elements}}, [$self->{head_element}, 'head']; |
| 3479 |
|
|
| 3480 |
$self->{insertion_mode} = 'in head'; |
$self->{insertion_mode} = 'in head'; |
| 3481 |
## reprocess |
## Reprocess in the "in head" insertion mode... |
|
redo B; |
|
|
} else { |
|
|
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
|
|
## Ignore the token ## ISSUE: An issue in the spec. |
|
|
!!!next-token; |
|
|
redo B; |
|
| 3482 |
} |
} |
| 3483 |
} else { |
|
| 3484 |
die "$0: $token->{type}: Unknown type"; |
if ($token->{tag_name} eq 'base') { |
| 3485 |
} |
if ($self->{insertion_mode} eq 'in head noscript') { |
| 3486 |
} elsif ($self->{insertion_mode} eq 'in head' or |
## As if </noscript> |
| 3487 |
$self->{insertion_mode} eq 'in head noscript' or |
pop @{$self->{open_elements}}; |
| 3488 |
$self->{insertion_mode} eq 'after head') { |
!!!parse-error (type => 'in noscript:base'); |
| 3489 |
if ($token->{type} eq 'character') { |
|
| 3490 |
if ($token->{data} =~ s/^([\x09\x0A\x0B\x0C\x20]+)//) { |
$self->{insertion_mode} = 'in head'; |
| 3491 |
$self->{open_elements}->[-1]->[0]->manakai_append_text ($1); |
## Reprocess in the "in head" insertion mode... |
|
unless (length $token->{data}) { |
|
|
!!!next-token; |
|
|
redo B; |
|
| 3492 |
} |
} |
| 3493 |
} |
|
| 3494 |
|
## NOTE: There is a "as if in head" code clone. |
| 3495 |
# |
if ($self->{insertion_mode} eq 'after head') { |
| 3496 |
} elsif ($token->{type} eq 'start tag') { |
!!!parse-error (type => 'after head:'.$token->{tag_name}); |
| 3497 |
if ({base => ($self->{insertion_mode} eq 'in head' or |
push @{$self->{open_elements}}, [$self->{head_element}, 'head']; |
| 3498 |
$self->{insertion_mode} eq 'after head'), |
} |
| 3499 |
link => 1}->{$token->{tag_name}}) { |
!!!insert-element ($token->{tag_name}, $token->{attributes}); |
| 3500 |
|
pop @{$self->{open_elements}}; ## ISSUE: This step is missing in the spec. |
| 3501 |
|
pop @{$self->{open_elements}} |
| 3502 |
|
if $self->{insertion_mode} eq 'after head'; |
| 3503 |
|
!!!next-token; |
| 3504 |
|
redo B; |
| 3505 |
|
} elsif ($token->{tag_name} eq 'link') { |
| 3506 |
## NOTE: There is a "as if in head" code clone. |
## NOTE: There is a "as if in head" code clone. |
| 3507 |
if ($self->{insertion_mode} eq 'after head') { |
if ($self->{insertion_mode} eq 'after head') { |
| 3508 |
!!!parse-error (type => 'after head:'.$token->{tag_name}); |
!!!parse-error (type => 'after head:'.$token->{tag_name}); |
| 3545 |
if $self->{insertion_mode} eq 'after head'; |
if $self->{insertion_mode} eq 'after head'; |
| 3546 |
!!!next-token; |
!!!next-token; |
| 3547 |
redo B; |
redo B; |
| 3548 |
} elsif ($token->{tag_name} eq 'title' and |
} elsif ($token->{tag_name} eq 'title') { |
| 3549 |
$self->{insertion_mode} eq 'in head') { |
if ($self->{insertion_mode} eq 'in head noscript') { |
| 3550 |
## NOTE: There is a "as if in head" code clone. |
## As if </noscript> |
| 3551 |
if ($self->{insertion_mode} eq 'after head') { |
pop @{$self->{open_elements}}; |
| 3552 |
|
!!!parse-error (type => 'in noscript:title'); |
| 3553 |
|
|
| 3554 |
|
$self->{insertion_mode} = 'in head'; |
| 3555 |
|
## Reprocess in the "in head" insertion mode... |
| 3556 |
|
} elsif ($self->{insertion_mode} eq 'after head') { |
| 3557 |
!!!parse-error (type => 'after head:'.$token->{tag_name}); |
!!!parse-error (type => 'after head:'.$token->{tag_name}); |
| 3558 |
push @{$self->{open_elements}}, [$self->{head_element}, 'head']; |
push @{$self->{open_elements}}, [$self->{head_element}, 'head']; |
| 3559 |
} |
} |
| 3560 |
|
|
| 3561 |
|
## NOTE: There is a "as if in head" code clone. |
| 3562 |
my $parent = defined $self->{head_element} ? $self->{head_element} |
my $parent = defined $self->{head_element} ? $self->{head_element} |
| 3563 |
: $self->{open_elements}->[-1]->[0]; |
: $self->{open_elements}->[-1]->[0]; |
| 3564 |
$parse_rcdata->(RCDATA_CONTENT_MODEL, |
$parse_rcdata->(RCDATA_CONTENT_MODEL, |
| 3593 |
} else { |
} else { |
| 3594 |
# |
# |
| 3595 |
} |
} |
| 3596 |
} elsif ($token->{tag_name} eq 'head' and |
} elsif ($token->{tag_name} eq 'script') { |
| 3597 |
$self->{insertion_mode} ne 'after head') { |
if ($self->{insertion_mode} eq 'in head noscript') { |
| 3598 |
!!!parse-error (type => 'in head:head'); # or in head noscript |
## As if </noscript> |
| 3599 |
## Ignore the token |
pop @{$self->{open_elements}}; |
| 3600 |
!!!next-token; |
!!!parse-error (type => 'in noscript:script'); |
| 3601 |
redo B; |
|
| 3602 |
} elsif ($self->{insertion_mode} ne 'in head noscript' and |
$self->{insertion_mode} = 'in head'; |
| 3603 |
$token->{tag_name} eq 'script') { |
## Reprocess in the "in head" insertion mode... |
| 3604 |
if ($self->{insertion_mode} eq 'after head') { |
} elsif ($self->{insertion_mode} eq 'after head') { |
| 3605 |
!!!parse-error (type => 'after head:'.$token->{tag_name}); |
!!!parse-error (type => 'after head:'.$token->{tag_name}); |
| 3606 |
push @{$self->{open_elements}}, [$self->{head_element}, 'head']; |
push @{$self->{open_elements}}, [$self->{head_element}, 'head']; |
| 3607 |
} |
} |
| 3608 |
|
|
| 3609 |
## NOTE: There is a "as if in head" code clone. |
## NOTE: There is a "as if in head" code clone. |
| 3610 |
$script_start_tag->($insert_to_current); |
$script_start_tag->($insert_to_current); |
| 3611 |
pop @{$self->{open_elements}} |
pop @{$self->{open_elements}} |
| 3612 |
if $self->{insertion_mode} eq 'after head'; |
if $self->{insertion_mode} eq 'after head'; |
| 3613 |
redo B; |
redo B; |
| 3614 |
} elsif ($self->{insertion_mode} eq 'after head' and |
} elsif ($token->{tag_name} eq 'body' or |
|
$token->{tag_name} eq 'body') { |
|
|
!!!insert-element ('body', $token->{attributes}); |
|
|
$self->{insertion_mode} = 'in body'; |
|
|
!!!next-token; |
|
|
redo B; |
|
|
} elsif ($self->{insertion_mode} eq 'after head' and |
|
| 3615 |
$token->{tag_name} eq 'frameset') { |
$token->{tag_name} eq 'frameset') { |
| 3616 |
!!!insert-element ('frameset', $token->{attributes}); |
if ($self->{insertion_mode} eq 'in head noscript') { |
| 3617 |
$self->{insertion_mode} = 'in frameset'; |
## As if </noscript> |
| 3618 |
|
pop @{$self->{open_elements}}; |
| 3619 |
|
!!!parse-error (type => 'in noscript:'.$token->{tag_name}); |
| 3620 |
|
|
| 3621 |
|
## Reprocess in the "in head" insertion mode... |
| 3622 |
|
## As if </head> |
| 3623 |
|
pop @{$self->{open_elements}}; |
| 3624 |
|
|
| 3625 |
|
## Reprocess in the "after head" insertion mode... |
| 3626 |
|
} elsif ($self->{insertion_mode} eq 'in head') { |
| 3627 |
|
pop @{$self->{open_elements}}; |
| 3628 |
|
|
| 3629 |
|
## Reprocess in the "after head" insertion mode... |
| 3630 |
|
} |
| 3631 |
|
|
| 3632 |
|
## "after head" insertion mode |
| 3633 |
|
!!!insert-element ($token->{tag_name}, $token->{attributes}); |
| 3634 |
|
$self->{insertion_mode} = 'in '.$token->{tag_name}; |
| 3635 |
!!!next-token; |
!!!next-token; |
| 3636 |
redo B; |
redo B; |
| 3637 |
} else { |
} else { |
| 3638 |
# |
# |
| 3639 |
} |
} |
| 3640 |
} elsif ($token->{type} eq 'end tag') { |
|
| 3641 |
if ($self->{insertion_mode} eq 'in head' and |
if ($self->{insertion_mode} eq 'in head noscript') { |
| 3642 |
$token->{tag_name} eq 'head') { |
## As if </noscript> |
| 3643 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 3644 |
$self->{insertion_mode} = 'after head'; |
!!!parse-error (type => 'in noscript:/'.$token->{tag_name}); |
| 3645 |
!!!next-token; |
|
| 3646 |
redo B; |
## Reprocess in the "in head" insertion mode... |
| 3647 |
} elsif ($self->{insertion_mode} eq 'in head noscript' and |
## As if </head> |
|
$token->{tag_name} eq 'noscript') { |
|
| 3648 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 3649 |
$self->{insertion_mode} = 'in head'; |
|
| 3650 |
!!!next-token; |
## Reprocess in the "after head" insertion mode... |
| 3651 |
redo B; |
} elsif ($self->{insertion_mode} eq 'in head') { |
| 3652 |
} elsif ($self->{insertion_mode} eq 'in head' and |
## As if </head> |
| 3653 |
{ |
pop @{$self->{open_elements}}; |
| 3654 |
body => 1, html => 1, |
|
| 3655 |
p => 1, br => 1, |
## Reprocess in the "after head" insertion mode... |
|
}->{$token->{tag_name}}) { |
|
|
# |
|
|
} elsif ($self->{insertion_mode} eq 'in head noscript' and |
|
|
{ |
|
|
p => 1, br => 1, |
|
|
}->{$token->{tag_name}}) { |
|
|
# |
|
|
} elsif ($self->{insertion_mode} ne 'after head') { |
|
|
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
|
|
## Ignore the token |
|
|
!!!next-token; |
|
|
redo B; |
|
|
} else { |
|
|
# |
|
| 3656 |
} |
} |
|
} else { |
|
|
# |
|
|
} |
|
| 3657 |
|
|
| 3658 |
## As if </head> or </noscript> or <body> |
## "after head" insertion mode |
| 3659 |
if ($self->{insertion_mode} eq 'in head') { |
## As if <body> |
|
pop @{$self->{open_elements}}; |
|
|
$self->{insertion_mode} = 'after head'; |
|
|
} elsif ($self->{insertion_mode} eq 'in head noscript') { |
|
|
pop @{$self->{open_elements}}; |
|
|
!!!parse-error (type => 'in noscript:'.(defined $token->{tag_name} ? ($token->{type} eq 'end tag' ? '/' : '') . $token->{tag_name} : '#' . $token->{type})); |
|
|
$self->{insertion_mode} = 'in head'; |
|
|
} else { # 'after head' |
|
| 3660 |
!!!insert-element ('body'); |
!!!insert-element ('body'); |
| 3661 |
$self->{insertion_mode} = 'in body'; |
$self->{insertion_mode} = 'in body'; |
| 3662 |
} |
## reprocess |
|
## reprocess |
|
|
redo B; |
|
|
|
|
|
## ISSUE: An issue in the spec. |
|
|
} elsif ($self->{insertion_mode} eq 'in body') { |
|
|
if ($token->{type} eq 'character') { |
|
|
## NOTE: There is a code clone of "character in body". |
|
|
$reconstruct_active_formatting_elements->($insert_to_current); |
|
|
|
|
|
$self->{open_elements}->[-1]->[0]->manakai_append_text ($token->{data}); |
|
|
|
|
|
!!!next-token; |
|
|
redo B; |
|
|
} else { |
|
|
$in_body->($insert_to_current); |
|
| 3663 |
redo B; |
redo B; |
| 3664 |
} |
} elsif ($token->{type} eq 'end tag') { |
| 3665 |
} elsif ($self->{insertion_mode} eq 'in table') { |
if ($token->{tag_name} eq 'head') { |
| 3666 |
if ($token->{type} eq 'character') { |
if ($self->{insertion_mode} eq 'before head') { |
| 3667 |
## NOTE: There are "character in table" code clones. |
## As if <head> |
| 3668 |
if ($token->{data} =~ s/^([\x09\x0A\x0B\x0C\x20]+)//) { |
!!!create-element ($self->{head_element}, 'head'); |
| 3669 |
$self->{open_elements}->[-1]->[0]->manakai_append_text ($1); |
$self->{open_elements}->[-1]->[0]->append_child ($self->{head_element}); |
| 3670 |
|
push @{$self->{open_elements}}, [$self->{head_element}, 'head']; |
| 3671 |
unless (length $token->{data}) { |
|
| 3672 |
|
## Reprocess in the "in head" insertion mode... |
| 3673 |
|
pop @{$self->{open_elements}}; |
| 3674 |
|
$self->{insertion_mode} = 'after head'; |
| 3675 |
|
!!!next-token; |
| 3676 |
|
redo B; |
| 3677 |
|
} elsif ($self->{insertion_mode} eq 'in head noscript') { |
| 3678 |
|
## As if </noscript> |
| 3679 |
|
pop @{$self->{open_elements}}; |
| 3680 |
|
!!!parse-error (type => 'in noscript:script'); |
| 3681 |
|
|
| 3682 |
|
## Reprocess in the "in head" insertion mode... |
| 3683 |
|
pop @{$self->{open_elements}}; |
| 3684 |
|
$self->{insertion_mode} = 'after head'; |
| 3685 |
|
!!!next-token; |
| 3686 |
|
redo B; |
| 3687 |
|
} elsif ($self->{insertion_mode} eq 'in head') { |
| 3688 |
|
pop @{$self->{open_elements}}; |
| 3689 |
|
$self->{insertion_mode} = 'after head'; |
| 3690 |
!!!next-token; |
!!!next-token; |
| 3691 |
redo B; |
redo B; |
|
} |
|
|
} |
|
|
|
|
|
!!!parse-error (type => 'in table:#character'); |
|
|
|
|
|
## As if in body, but insert into foster parent element |
|
|
## ISSUE: Spec says that "whenever a node would be inserted |
|
|
## into the current node" while characters might not be |
|
|
## result in a new Text node. |
|
|
$reconstruct_active_formatting_elements->($insert_to_foster); |
|
|
|
|
|
if ({ |
|
|
table => 1, tbody => 1, tfoot => 1, |
|
|
thead => 1, tr => 1, |
|
|
}->{$self->{open_elements}->[-1]->[1]}) { |
|
|
# MUST |
|
|
my $foster_parent_element; |
|
|
my $next_sibling; |
|
|
my $prev_sibling; |
|
|
OE: for (reverse 0..$#{$self->{open_elements}}) { |
|
|
if ($self->{open_elements}->[$_]->[1] eq 'table') { |
|
|
my $parent = $self->{open_elements}->[$_]->[0]->parent_node; |
|
|
if (defined $parent and $parent->node_type == 1) { |
|
|
$foster_parent_element = $parent; |
|
|
$next_sibling = $self->{open_elements}->[$_]->[0]; |
|
|
$prev_sibling = $next_sibling->previous_sibling; |
|
|
} else { |
|
|
$foster_parent_element = $self->{open_elements}->[$_ - 1]->[0]; |
|
|
$prev_sibling = $foster_parent_element->last_child; |
|
|
} |
|
|
last OE; |
|
|
} |
|
|
} # OE |
|
|
$foster_parent_element = $self->{open_elements}->[0]->[0] and |
|
|
$prev_sibling = $foster_parent_element->last_child |
|
|
unless defined $foster_parent_element; |
|
|
if (defined $prev_sibling and |
|
|
$prev_sibling->node_type == 3) { |
|
|
$prev_sibling->manakai_append_text ($token->{data}); |
|
| 3692 |
} else { |
} else { |
| 3693 |
$foster_parent_element->insert_before |
# |
|
($self->{document}->create_text_node ($token->{data}), |
|
|
$next_sibling); |
|
| 3694 |
} |
} |
| 3695 |
} else { |
} elsif ($token->{tag_name} eq 'noscript') { |
| 3696 |
$self->{open_elements}->[-1]->[0]->manakai_append_text ($token->{data}); |
if ($self->{insertion_mode} eq 'in head noscript') { |
|
} |
|
|
|
|
|
!!!next-token; |
|
|
redo B; |
|
|
} elsif ($token->{type} eq 'start tag') { |
|
|
if ({ |
|
|
caption => 1, |
|
|
colgroup => 1, |
|
|
tbody => 1, tfoot => 1, thead => 1, |
|
|
}->{$token->{tag_name}}) { |
|
|
## Clear back to table context |
|
|
while ($self->{open_elements}->[-1]->[1] ne 'table' and |
|
|
$self->{open_elements}->[-1]->[1] ne 'html') { |
|
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
|
| 3697 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 3698 |
|
$self->{insertion_mode} = 'in head'; |
| 3699 |
|
!!!next-token; |
| 3700 |
|
redo B; |
| 3701 |
|
} elsif ($self->{insertion_mode} eq 'before head') { |
| 3702 |
|
!!!parse-error (type => 'unmatched end tag:noscript'); |
| 3703 |
|
## Ignore the token ## ISSUE: An issue in the spec. |
| 3704 |
|
!!!next-token; |
| 3705 |
|
redo B; |
| 3706 |
|
} else { |
| 3707 |
|
# |
| 3708 |
} |
} |
|
|
|
|
push @$active_formatting_elements, ['#marker', ''] |
|
|
if $token->{tag_name} eq 'caption'; |
|
|
|
|
|
!!!insert-element ($token->{tag_name}, $token->{attributes}); |
|
|
$self->{insertion_mode} = { |
|
|
caption => 'in caption', |
|
|
colgroup => 'in column group', |
|
|
tbody => 'in table body', |
|
|
tfoot => 'in table body', |
|
|
thead => 'in table body', |
|
|
}->{$token->{tag_name}}; |
|
|
!!!next-token; |
|
|
redo B; |
|
| 3709 |
} elsif ({ |
} elsif ({ |
| 3710 |
col => 1, |
body => 1, html => 1, |
|
td => 1, th => 1, tr => 1, |
|
| 3711 |
}->{$token->{tag_name}}) { |
}->{$token->{tag_name}}) { |
| 3712 |
## Clear back to table context |
if ($self->{insertion_mode} eq 'before head') { |
| 3713 |
while ($self->{open_elements}->[-1]->[1] ne 'table' and |
## As if <head> |
| 3714 |
$self->{open_elements}->[-1]->[1] ne 'html') { |
!!!create-element ($self->{head_element}, 'head'); |
| 3715 |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
$self->{open_elements}->[-1]->[0]->append_child ($self->{head_element}); |
| 3716 |
pop @{$self->{open_elements}}; |
push @{$self->{open_elements}}, [$self->{head_element}, 'head']; |
|
} |
|
|
|
|
|
!!!insert-element ($token->{tag_name} eq 'col' ? 'colgroup' : 'tbody'); |
|
|
$self->{insertion_mode} = $token->{tag_name} eq 'col' |
|
|
? 'in column group' : 'in table body'; |
|
|
## reprocess |
|
|
redo B; |
|
|
} elsif ($token->{tag_name} eq 'table') { |
|
|
## NOTE: There are code clones for this "table in table" |
|
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
|
| 3717 |
|
|
| 3718 |
## As if </table> |
$self->{insertion_mode} = 'in head'; |
| 3719 |
## have a table element in table scope |
## Reprocess in the "in head" insertion mode... |
| 3720 |
my $i; |
} elsif ($self->{insertion_mode} eq 'in head noscript') { |
| 3721 |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
| 3722 |
my $node = $self->{open_elements}->[$_]; |
## Ignore the token |
|
if ($node->[1] eq 'table') { |
|
|
$i = $_; |
|
|
last INSCOPE; |
|
|
} elsif ({ |
|
|
table => 1, html => 1, |
|
|
}->{$node->[1]}) { |
|
|
last INSCOPE; |
|
|
} |
|
|
} # INSCOPE |
|
|
unless (defined $i) { |
|
|
!!!parse-error (type => 'unmatched end tag:table'); |
|
|
## Ignore tokens </table><table> |
|
| 3723 |
!!!next-token; |
!!!next-token; |
| 3724 |
redo B; |
redo B; |
| 3725 |
} |
} |
| 3726 |
|
|
| 3727 |
## generate implied end tags |
# |
| 3728 |
if ({ |
} elsif ({ |
| 3729 |
dd => 1, dt => 1, li => 1, p => 1, |
p => 1, br => 1, |
| 3730 |
td => 1, th => 1, tr => 1, |
}->{$token->{tag_name}}) { |
| 3731 |
tbody => 1, tfoot=> 1, thead => 1, |
if ($self->{insertion_mode} eq 'before head') { |
| 3732 |
}->{$self->{open_elements}->[-1]->[1]}) { |
## As if <head> |
| 3733 |
!!!back-token; # <table> |
!!!create-element ($self->{head_element}, 'head'); |
| 3734 |
$token = {type => 'end tag', tag_name => 'table'}; |
$self->{open_elements}->[-1]->[0]->append_child ($self->{head_element}); |
| 3735 |
!!!back-token; |
push @{$self->{open_elements}}, [$self->{head_element}, 'head']; |
|
$token = {type => 'end tag', |
|
|
tag_name => $self->{open_elements}->[-1]->[1]}; # MUST |
|
|
redo B; |
|
|
} |
|
| 3736 |
|
|
| 3737 |
if ($self->{open_elements}->[-1]->[1] ne 'table') { |
$self->{insertion_mode} = 'in head'; |
| 3738 |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
## Reprocess in the "in head" insertion mode... |
| 3739 |
} |
} |
| 3740 |
|
|
|
splice @{$self->{open_elements}}, $i; |
|
|
|
|
|
$self->_reset_insertion_mode; |
|
|
|
|
|
## reprocess |
|
|
redo B; |
|
|
} else { |
|
| 3741 |
# |
# |
| 3742 |
} |
} else { |
| 3743 |
} elsif ($token->{type} eq 'end tag') { |
if ($self->{insertion_mode} ne 'after head') { |
|
if ($token->{tag_name} eq 'table') { |
|
|
## have a table element in table scope |
|
|
my $i; |
|
|
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
|
|
my $node = $self->{open_elements}->[$_]; |
|
|
if ($node->[1] eq $token->{tag_name}) { |
|
|
$i = $_; |
|
|
last INSCOPE; |
|
|
} elsif ({ |
|
|
table => 1, html => 1, |
|
|
}->{$node->[1]}) { |
|
|
last INSCOPE; |
|
|
} |
|
|
} # INSCOPE |
|
|
unless (defined $i) { |
|
| 3744 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
| 3745 |
## Ignore the token |
## Ignore the token |
| 3746 |
!!!next-token; |
!!!next-token; |
| 3747 |
redo B; |
redo B; |
| 3748 |
|
} else { |
| 3749 |
|
# |
| 3750 |
} |
} |
| 3751 |
|
} |
|
## generate implied end tags |
|
|
if ({ |
|
|
dd => 1, dt => 1, li => 1, p => 1, |
|
|
td => 1, th => 1, tr => 1, |
|
|
tbody => 1, tfoot=> 1, thead => 1, |
|
|
}->{$self->{open_elements}->[-1]->[1]}) { |
|
|
!!!back-token; |
|
|
$token = {type => 'end tag', |
|
|
tag_name => $self->{open_elements}->[-1]->[1]}; # MUST |
|
|
redo B; |
|
|
} |
|
|
|
|
|
if ($self->{open_elements}->[-1]->[1] ne 'table') { |
|
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
|
|
} |
|
| 3752 |
|
|
| 3753 |
splice @{$self->{open_elements}}, $i; |
if ($self->{insertion_mode} eq 'in head noscript') { |
| 3754 |
|
## As if </noscript> |
| 3755 |
|
pop @{$self->{open_elements}}; |
| 3756 |
|
!!!parse-error (type => 'in noscript:/'.$token->{tag_name}); |
| 3757 |
|
|
| 3758 |
|
## Reprocess in the "in head" insertion mode... |
| 3759 |
|
## As if </head> |
| 3760 |
|
pop @{$self->{open_elements}}; |
| 3761 |
|
|
| 3762 |
$self->_reset_insertion_mode; |
## Reprocess in the "after head" insertion mode... |
| 3763 |
|
} elsif ($self->{insertion_mode} eq 'in head') { |
| 3764 |
|
## As if </head> |
| 3765 |
|
pop @{$self->{open_elements}}; |
| 3766 |
|
|
| 3767 |
!!!next-token; |
## Reprocess in the "after head" insertion mode... |
| 3768 |
redo B; |
} elsif ($self->{insertion_mode} eq 'before head') { |
|
} elsif ({ |
|
|
body => 1, caption => 1, col => 1, colgroup => 1, |
|
|
html => 1, tbody => 1, td => 1, tfoot => 1, th => 1, |
|
|
thead => 1, tr => 1, |
|
|
}->{$token->{tag_name}}) { |
|
| 3769 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
| 3770 |
## Ignore the token |
## Ignore the token ## ISSUE: An issue in the spec. |
| 3771 |
!!!next-token; |
!!!next-token; |
| 3772 |
redo B; |
redo B; |
|
} else { |
|
|
# |
|
| 3773 |
} |
} |
| 3774 |
|
|
| 3775 |
|
## "after head" insertion mode |
| 3776 |
|
## As if <body> |
| 3777 |
|
!!!insert-element ('body'); |
| 3778 |
|
$self->{insertion_mode} = 'in body'; |
| 3779 |
|
## reprocess |
| 3780 |
|
redo B; |
| 3781 |
} else { |
} else { |
| 3782 |
# |
die "$0: $token->{type}: Unknown token type"; |
| 3783 |
} |
} |
| 3784 |
|
|
| 3785 |
!!!parse-error (type => 'in table:'.$token->{tag_name}); |
## ISSUE: An issue in the spec. |
| 3786 |
$in_body->($insert_to_foster); |
} elsif ($self->{insertion_mode} eq 'in body' or |
| 3787 |
redo B; |
$self->{insertion_mode} eq 'in cell' or |
| 3788 |
} elsif ($self->{insertion_mode} eq 'in caption') { |
$self->{insertion_mode} eq 'in caption') { |
| 3789 |
if ($token->{type} eq 'character') { |
if ($token->{type} eq 'character') { |
| 3790 |
## NOTE: This is a code clone of "character in body". |
## NOTE: There is a code clone of "character in body". |
| 3791 |
$reconstruct_active_formatting_elements->($insert_to_current); |
$reconstruct_active_formatting_elements->($insert_to_current); |
| 3792 |
|
|
| 3793 |
$self->{open_elements}->[-1]->[0]->manakai_append_text ($token->{data}); |
$self->{open_elements}->[-1]->[0]->manakai_append_text ($token->{data}); |
| 3799 |
caption => 1, col => 1, colgroup => 1, tbody => 1, |
caption => 1, col => 1, colgroup => 1, tbody => 1, |
| 3800 |
td => 1, tfoot => 1, th => 1, thead => 1, tr => 1, |
td => 1, tfoot => 1, th => 1, thead => 1, tr => 1, |
| 3801 |
}->{$token->{tag_name}}) { |
}->{$token->{tag_name}}) { |
| 3802 |
!!!parse-error (type => 'not closed:caption'); |
if ($self->{insertion_mode} eq 'in cell') { |
| 3803 |
|
## have an element in table scope |
| 3804 |
## As if </caption> |
my $tn; |
| 3805 |
## have a table element in table scope |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
| 3806 |
my $i; |
my $node = $self->{open_elements}->[$_]; |
| 3807 |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
if ($node->[1] eq 'td' or $node->[1] eq 'th') { |
| 3808 |
my $node = $self->{open_elements}->[$_]; |
$tn = $node->[1]; |
| 3809 |
if ($node->[1] eq 'caption') { |
last INSCOPE; |
| 3810 |
$i = $_; |
} elsif ({ |
| 3811 |
last INSCOPE; |
table => 1, html => 1, |
| 3812 |
} elsif ({ |
}->{$node->[1]}) { |
| 3813 |
table => 1, html => 1, |
last INSCOPE; |
| 3814 |
}->{$node->[1]}) { |
} |
| 3815 |
last INSCOPE; |
} # INSCOPE |
| 3816 |
} |
unless (defined $tn) { |
| 3817 |
} # INSCOPE |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
| 3818 |
unless (defined $i) { |
## Ignore the token |
| 3819 |
!!!parse-error (type => 'unmatched end tag:caption'); |
!!!next-token; |
| 3820 |
## Ignore the token |
redo B; |
| 3821 |
!!!next-token; |
} |
| 3822 |
redo B; |
|
| 3823 |
} |
## Close the cell |
|
|
|
|
## generate implied end tags |
|
|
if ({ |
|
|
dd => 1, dt => 1, li => 1, p => 1, |
|
|
td => 1, th => 1, tr => 1, |
|
|
tbody => 1, tfoot=> 1, thead => 1, |
|
|
}->{$self->{open_elements}->[-1]->[1]}) { |
|
| 3824 |
!!!back-token; # <?> |
!!!back-token; # <?> |
| 3825 |
$token = {type => 'end tag', tag_name => 'caption'}; |
$token = {type => 'end tag', tag_name => $tn}; |
|
!!!back-token; |
|
|
$token = {type => 'end tag', |
|
|
tag_name => $self->{open_elements}->[-1]->[1]}; # MUST |
|
| 3826 |
redo B; |
redo B; |
| 3827 |
|
} elsif ($self->{insertion_mode} eq 'in caption') { |
| 3828 |
|
!!!parse-error (type => 'not closed:caption'); |
| 3829 |
|
|
| 3830 |
|
## As if </caption> |
| 3831 |
|
## have a table element in table scope |
| 3832 |
|
my $i; |
| 3833 |
|
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
| 3834 |
|
my $node = $self->{open_elements}->[$_]; |
| 3835 |
|
if ($node->[1] eq 'caption') { |
| 3836 |
|
$i = $_; |
| 3837 |
|
last INSCOPE; |
| 3838 |
|
} elsif ({ |
| 3839 |
|
table => 1, html => 1, |
| 3840 |
|
}->{$node->[1]}) { |
| 3841 |
|
last INSCOPE; |
| 3842 |
|
} |
| 3843 |
|
} # INSCOPE |
| 3844 |
|
unless (defined $i) { |
| 3845 |
|
!!!parse-error (type => 'unmatched end tag:caption'); |
| 3846 |
|
## Ignore the token |
| 3847 |
|
!!!next-token; |
| 3848 |
|
redo B; |
| 3849 |
|
} |
| 3850 |
|
|
| 3851 |
|
## generate implied end tags |
| 3852 |
|
if ({ |
| 3853 |
|
dd => 1, dt => 1, li => 1, p => 1, |
| 3854 |
|
td => 1, th => 1, tr => 1, |
| 3855 |
|
tbody => 1, tfoot=> 1, thead => 1, |
| 3856 |
|
}->{$self->{open_elements}->[-1]->[1]}) { |
| 3857 |
|
!!!back-token; # <?> |
| 3858 |
|
$token = {type => 'end tag', tag_name => 'caption'}; |
| 3859 |
|
!!!back-token; |
| 3860 |
|
$token = {type => 'end tag', |
| 3861 |
|
tag_name => $self->{open_elements}->[-1]->[1]}; # MUST |
| 3862 |
|
redo B; |
| 3863 |
|
} |
| 3864 |
|
|
| 3865 |
|
if ($self->{open_elements}->[-1]->[1] ne 'caption') { |
| 3866 |
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
| 3867 |
|
} |
| 3868 |
|
|
| 3869 |
|
splice @{$self->{open_elements}}, $i; |
| 3870 |
|
|
| 3871 |
|
$clear_up_to_marker->(); |
| 3872 |
|
|
| 3873 |
|
$self->{insertion_mode} = 'in table'; |
| 3874 |
|
|
| 3875 |
|
## reprocess |
| 3876 |
|
redo B; |
| 3877 |
|
} else { |
| 3878 |
|
# |
| 3879 |
} |
} |
|
|
|
|
if ($self->{open_elements}->[-1]->[1] ne 'caption') { |
|
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
|
|
} |
|
|
|
|
|
splice @{$self->{open_elements}}, $i; |
|
|
|
|
|
$clear_up_to_marker->(); |
|
|
|
|
|
$self->{insertion_mode} = 'in table'; |
|
|
|
|
|
## reprocess |
|
|
redo B; |
|
| 3880 |
} else { |
} else { |
| 3881 |
# |
# |
| 3882 |
} |
} |
| 3883 |
} elsif ($token->{type} eq 'end tag') { |
} elsif ($token->{type} eq 'end tag') { |
| 3884 |
if ($token->{tag_name} eq 'caption') { |
if ($token->{tag_name} eq 'td' or $token->{tag_name} eq 'th') { |
| 3885 |
## have a table element in table scope |
if ($self->{insertion_mode} eq 'in cell') { |
| 3886 |
|
## have an element in table scope |
| 3887 |
|
my $i; |
| 3888 |
|
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
| 3889 |
|
my $node = $self->{open_elements}->[$_]; |
| 3890 |
|
if ($node->[1] eq $token->{tag_name}) { |
| 3891 |
|
$i = $_; |
| 3892 |
|
last INSCOPE; |
| 3893 |
|
} elsif ({ |
| 3894 |
|
table => 1, html => 1, |
| 3895 |
|
}->{$node->[1]}) { |
| 3896 |
|
last INSCOPE; |
| 3897 |
|
} |
| 3898 |
|
} # INSCOPE |
| 3899 |
|
unless (defined $i) { |
| 3900 |
|
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
| 3901 |
|
## Ignore the token |
| 3902 |
|
!!!next-token; |
| 3903 |
|
redo B; |
| 3904 |
|
} |
| 3905 |
|
|
| 3906 |
|
## generate implied end tags |
| 3907 |
|
if ({ |
| 3908 |
|
dd => 1, dt => 1, li => 1, p => 1, |
| 3909 |
|
td => ($token->{tag_name} eq 'th'), |
| 3910 |
|
th => ($token->{tag_name} eq 'td'), |
| 3911 |
|
tr => 1, |
| 3912 |
|
tbody => 1, tfoot=> 1, thead => 1, |
| 3913 |
|
}->{$self->{open_elements}->[-1]->[1]}) { |
| 3914 |
|
!!!back-token; |
| 3915 |
|
$token = {type => 'end tag', |
| 3916 |
|
tag_name => $self->{open_elements}->[-1]->[1]}; # MUST |
| 3917 |
|
redo B; |
| 3918 |
|
} |
| 3919 |
|
|
| 3920 |
|
if ($self->{open_elements}->[-1]->[1] ne $token->{tag_name}) { |
| 3921 |
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
| 3922 |
|
} |
| 3923 |
|
|
| 3924 |
|
splice @{$self->{open_elements}}, $i; |
| 3925 |
|
|
| 3926 |
|
$clear_up_to_marker->(); |
| 3927 |
|
|
| 3928 |
|
$self->{insertion_mode} = 'in row'; |
| 3929 |
|
|
| 3930 |
|
!!!next-token; |
| 3931 |
|
redo B; |
| 3932 |
|
} elsif ($self->{insertion_mode} eq 'in caption') { |
| 3933 |
|
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
| 3934 |
|
## Ignore the token |
| 3935 |
|
!!!next-token; |
| 3936 |
|
redo B; |
| 3937 |
|
} else { |
| 3938 |
|
# |
| 3939 |
|
} |
| 3940 |
|
} elsif ($token->{tag_name} eq 'caption') { |
| 3941 |
|
if ($self->{insertion_mode} eq 'in caption') { |
| 3942 |
|
## have a table element in table scope |
| 3943 |
|
my $i; |
| 3944 |
|
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
| 3945 |
|
my $node = $self->{open_elements}->[$_]; |
| 3946 |
|
if ($node->[1] eq $token->{tag_name}) { |
| 3947 |
|
$i = $_; |
| 3948 |
|
last INSCOPE; |
| 3949 |
|
} elsif ({ |
| 3950 |
|
table => 1, html => 1, |
| 3951 |
|
}->{$node->[1]}) { |
| 3952 |
|
last INSCOPE; |
| 3953 |
|
} |
| 3954 |
|
} # INSCOPE |
| 3955 |
|
unless (defined $i) { |
| 3956 |
|
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
| 3957 |
|
## Ignore the token |
| 3958 |
|
!!!next-token; |
| 3959 |
|
redo B; |
| 3960 |
|
} |
| 3961 |
|
|
| 3962 |
|
## generate implied end tags |
| 3963 |
|
if ({ |
| 3964 |
|
dd => 1, dt => 1, li => 1, p => 1, |
| 3965 |
|
td => 1, th => 1, tr => 1, |
| 3966 |
|
tbody => 1, tfoot=> 1, thead => 1, |
| 3967 |
|
}->{$self->{open_elements}->[-1]->[1]}) { |
| 3968 |
|
!!!back-token; |
| 3969 |
|
$token = {type => 'end tag', |
| 3970 |
|
tag_name => $self->{open_elements}->[-1]->[1]}; # MUST |
| 3971 |
|
redo B; |
| 3972 |
|
} |
| 3973 |
|
|
| 3974 |
|
if ($self->{open_elements}->[-1]->[1] ne 'caption') { |
| 3975 |
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
| 3976 |
|
} |
| 3977 |
|
|
| 3978 |
|
splice @{$self->{open_elements}}, $i; |
| 3979 |
|
|
| 3980 |
|
$clear_up_to_marker->(); |
| 3981 |
|
|
| 3982 |
|
$self->{insertion_mode} = 'in table'; |
| 3983 |
|
|
| 3984 |
|
!!!next-token; |
| 3985 |
|
redo B; |
| 3986 |
|
} elsif ($self->{insertion_mode} eq 'in cell') { |
| 3987 |
|
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
| 3988 |
|
## Ignore the token |
| 3989 |
|
!!!next-token; |
| 3990 |
|
redo B; |
| 3991 |
|
} else { |
| 3992 |
|
# |
| 3993 |
|
} |
| 3994 |
|
} elsif ({ |
| 3995 |
|
table => 1, tbody => 1, tfoot => 1, |
| 3996 |
|
thead => 1, tr => 1, |
| 3997 |
|
}->{$token->{tag_name}} and |
| 3998 |
|
$self->{insertion_mode} eq 'in cell') { |
| 3999 |
|
## have an element in table scope |
| 4000 |
my $i; |
my $i; |
| 4001 |
|
my $tn; |
| 4002 |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
| 4003 |
my $node = $self->{open_elements}->[$_]; |
my $node = $self->{open_elements}->[$_]; |
| 4004 |
if ($node->[1] eq $token->{tag_name}) { |
if ($node->[1] eq $token->{tag_name}) { |
| 4005 |
$i = $_; |
$i = $_; |
| 4006 |
last INSCOPE; |
last INSCOPE; |
| 4007 |
|
} elsif ($node->[1] eq 'td' or $node->[1] eq 'th') { |
| 4008 |
|
$tn = $node->[1]; |
| 4009 |
|
## NOTE: There is exactly one |td| or |th| element |
| 4010 |
|
## in scope in the stack of open elements by definition. |
| 4011 |
} elsif ({ |
} elsif ({ |
| 4012 |
table => 1, html => 1, |
table => 1, html => 1, |
| 4013 |
}->{$node->[1]}) { |
}->{$node->[1]}) { |
| 4020 |
!!!next-token; |
!!!next-token; |
| 4021 |
redo B; |
redo B; |
| 4022 |
} |
} |
|
|
|
|
## generate implied end tags |
|
|
if ({ |
|
|
dd => 1, dt => 1, li => 1, p => 1, |
|
|
td => 1, th => 1, tr => 1, |
|
|
tbody => 1, tfoot=> 1, thead => 1, |
|
|
}->{$self->{open_elements}->[-1]->[1]}) { |
|
|
!!!back-token; |
|
|
$token = {type => 'end tag', |
|
|
tag_name => $self->{open_elements}->[-1]->[1]}; # MUST |
|
|
redo B; |
|
|
} |
|
| 4023 |
|
|
| 4024 |
if ($self->{open_elements}->[-1]->[1] ne 'caption') { |
## Close the cell |
| 4025 |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
!!!back-token; # </?> |
| 4026 |
} |
$token = {type => 'end tag', tag_name => $tn}; |
|
|
|
|
splice @{$self->{open_elements}}, $i; |
|
|
|
|
|
$clear_up_to_marker->(); |
|
|
|
|
|
$self->{insertion_mode} = 'in table'; |
|
|
|
|
|
!!!next-token; |
|
| 4027 |
redo B; |
redo B; |
| 4028 |
} elsif ($token->{tag_name} eq 'table') { |
} elsif ($token->{tag_name} eq 'table' and |
| 4029 |
|
$self->{insertion_mode} eq 'in caption') { |
| 4030 |
!!!parse-error (type => 'not closed:caption'); |
!!!parse-error (type => 'not closed:caption'); |
| 4031 |
|
|
| 4032 |
## As if </caption> |
## As if </caption> |
| 4077 |
## reprocess |
## reprocess |
| 4078 |
redo B; |
redo B; |
| 4079 |
} elsif ({ |
} elsif ({ |
| 4080 |
body => 1, col => 1, colgroup => 1, |
body => 1, col => 1, colgroup => 1, html => 1, |
|
html => 1, tbody => 1, td => 1, tfoot => 1, |
|
|
th => 1, thead => 1, tr => 1, |
|
| 4081 |
}->{$token->{tag_name}}) { |
}->{$token->{tag_name}}) { |
| 4082 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
if ($self->{insertion_mode} eq 'in cell' or |
| 4083 |
## Ignore the token |
$self->{insertion_mode} eq 'in caption') { |
| 4084 |
!!!next-token; |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
|
redo B; |
|
|
} else { |
|
|
# |
|
|
} |
|
|
} else { |
|
|
# |
|
|
} |
|
|
|
|
|
$in_body->($insert_to_current); |
|
|
redo B; |
|
|
} elsif ($self->{insertion_mode} eq 'in column group') { |
|
|
if ($token->{type} eq 'character') { |
|
|
if ($token->{data} =~ s/^([\x09\x0A\x0B\x0C\x20]+)//) { |
|
|
$self->{open_elements}->[-1]->[0]->manakai_append_text ($1); |
|
|
unless (length $token->{data}) { |
|
|
!!!next-token; |
|
|
redo B; |
|
|
} |
|
|
} |
|
|
|
|
|
# |
|
|
} elsif ($token->{type} eq 'start tag') { |
|
|
if ($token->{tag_name} eq 'col') { |
|
|
!!!insert-element ($token->{tag_name}, $token->{attributes}); |
|
|
pop @{$self->{open_elements}}; |
|
|
!!!next-token; |
|
|
redo B; |
|
|
} else { |
|
|
# |
|
|
} |
|
|
} elsif ($token->{type} eq 'end tag') { |
|
|
if ($token->{tag_name} eq 'colgroup') { |
|
|
if ($self->{open_elements}->[-1]->[1] eq 'html') { |
|
|
!!!parse-error (type => 'unmatched end tag:colgroup'); |
|
| 4085 |
## Ignore the token |
## Ignore the token |
| 4086 |
!!!next-token; |
!!!next-token; |
| 4087 |
redo B; |
redo B; |
| 4088 |
} else { |
} else { |
| 4089 |
pop @{$self->{open_elements}}; # colgroup |
# |
|
$self->{insertion_mode} = 'in table'; |
|
|
!!!next-token; |
|
|
redo B; |
|
| 4090 |
} |
} |
| 4091 |
} elsif ($token->{tag_name} eq 'col') { |
} elsif ({ |
| 4092 |
!!!parse-error (type => 'unmatched end tag:col'); |
tbody => 1, tfoot => 1, |
| 4093 |
|
thead => 1, tr => 1, |
| 4094 |
|
}->{$token->{tag_name}} and |
| 4095 |
|
$self->{insertion_mode} eq 'in caption') { |
| 4096 |
|
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
| 4097 |
## Ignore the token |
## Ignore the token |
| 4098 |
!!!next-token; |
!!!next-token; |
| 4099 |
redo B; |
redo B; |
| 4100 |
} else { |
} else { |
| 4101 |
# |
# |
| 4102 |
} |
} |
| 4103 |
} else { |
} else { |
| 4104 |
# |
# |
| 4105 |
} |
} |
| 4106 |
|
|
| 4107 |
## As if </colgroup> |
$in_body->($insert_to_current); |
| 4108 |
if ($self->{open_elements}->[-1]->[1] eq 'html') { |
redo B; |
| 4109 |
!!!parse-error (type => 'unmatched end tag:colgroup'); |
} elsif ($self->{insertion_mode} eq 'in row' or |
| 4110 |
## Ignore the token |
$self->{insertion_mode} eq 'in table body' or |
| 4111 |
!!!next-token; |
$self->{insertion_mode} eq 'in table') { |
|
redo B; |
|
|
} else { |
|
|
pop @{$self->{open_elements}}; # colgroup |
|
|
$self->{insertion_mode} = 'in table'; |
|
|
## reprocess |
|
|
redo B; |
|
|
} |
|
|
} elsif ($self->{insertion_mode} eq 'in table body') { |
|
| 4112 |
if ($token->{type} eq 'character') { |
if ($token->{type} eq 'character') { |
| 4113 |
## NOTE: This is a "character in table" code clone. |
## NOTE: There are "character in table" code clones. |
| 4114 |
if ($token->{data} =~ s/^([\x09\x0A\x0B\x0C\x20]+)//) { |
if ($token->{data} =~ s/^([\x09\x0A\x0B\x0C\x20]+)//) { |
| 4115 |
$self->{open_elements}->[-1]->[0]->manakai_append_text ($1); |
$self->{open_elements}->[-1]->[0]->manakai_append_text ($1); |
| 4116 |
|
|
| 4127 |
## into the current node" while characters might not be |
## into the current node" while characters might not be |
| 4128 |
## result in a new Text node. |
## result in a new Text node. |
| 4129 |
$reconstruct_active_formatting_elements->($insert_to_foster); |
$reconstruct_active_formatting_elements->($insert_to_foster); |
| 4130 |
|
|
| 4131 |
if ({ |
if ({ |
| 4132 |
table => 1, tbody => 1, tfoot => 1, |
table => 1, tbody => 1, tfoot => 1, |
| 4133 |
thead => 1, tr => 1, |
thead => 1, tr => 1, |
| 4169 |
redo B; |
redo B; |
| 4170 |
} elsif ($token->{type} eq 'start tag') { |
} elsif ($token->{type} eq 'start tag') { |
| 4171 |
if ({ |
if ({ |
| 4172 |
tr => 1, |
tr => ($self->{insertion_mode} ne 'in row'), |
| 4173 |
th => 1, td => 1, |
th => 1, td => 1, |
| 4174 |
}->{$token->{tag_name}}) { |
}->{$token->{tag_name}}) { |
| 4175 |
unless ($token->{tag_name} eq 'tr') { |
if ($self->{insertion_mode} eq 'in table') { |
| 4176 |
!!!parse-error (type => 'missing start tag:tr'); |
## Clear back to table context |
| 4177 |
|
while ($self->{open_elements}->[-1]->[1] ne 'table' and |
| 4178 |
|
$self->{open_elements}->[-1]->[1] ne 'html') { |
| 4179 |
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
| 4180 |
|
pop @{$self->{open_elements}}; |
| 4181 |
|
} |
| 4182 |
|
|
| 4183 |
|
!!!insert-element ('tbody'); |
| 4184 |
|
$self->{insertion_mode} = 'in table body'; |
| 4185 |
|
## reprocess in the "in table body" insertion mode... |
| 4186 |
|
} |
| 4187 |
|
|
| 4188 |
|
if ($self->{insertion_mode} eq 'in table body') { |
| 4189 |
|
unless ($token->{tag_name} eq 'tr') { |
| 4190 |
|
!!!parse-error (type => 'missing start tag:tr'); |
| 4191 |
|
} |
| 4192 |
|
|
| 4193 |
|
## Clear back to table body context |
| 4194 |
|
while (not { |
| 4195 |
|
tbody => 1, tfoot => 1, thead => 1, html => 1, |
| 4196 |
|
}->{$self->{open_elements}->[-1]->[1]}) { |
| 4197 |
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
| 4198 |
|
pop @{$self->{open_elements}}; |
| 4199 |
|
} |
| 4200 |
|
|
| 4201 |
|
$self->{insertion_mode} = 'in row'; |
| 4202 |
|
if ($token->{tag_name} eq 'tr') { |
| 4203 |
|
!!!insert-element ($token->{tag_name}, $token->{attributes}); |
| 4204 |
|
!!!next-token; |
| 4205 |
|
redo B; |
| 4206 |
|
} else { |
| 4207 |
|
!!!insert-element ('tr'); |
| 4208 |
|
## reprocess in the "in row" insertion mode |
| 4209 |
|
} |
| 4210 |
} |
} |
| 4211 |
|
|
| 4212 |
## Clear back to table body context |
## Clear back to table row context |
| 4213 |
while (not { |
while (not { |
| 4214 |
tbody => 1, tfoot => 1, thead => 1, html => 1, |
tr => 1, html => 1, |
| 4215 |
}->{$self->{open_elements}->[-1]->[1]}) { |
}->{$self->{open_elements}->[-1]->[1]}) { |
| 4216 |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
| 4217 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 4218 |
} |
} |
| 4219 |
|
|
| 4220 |
$self->{insertion_mode} = 'in row'; |
!!!insert-element ($token->{tag_name}, $token->{attributes}); |
| 4221 |
if ($token->{tag_name} eq 'tr') { |
$self->{insertion_mode} = 'in cell'; |
| 4222 |
!!!insert-element ($token->{tag_name}, $token->{attributes}); |
|
| 4223 |
!!!next-token; |
push @$active_formatting_elements, ['#marker', '']; |
| 4224 |
} else { |
|
| 4225 |
!!!insert-element ('tr'); |
!!!next-token; |
|
## reprocess |
|
|
} |
|
| 4226 |
redo B; |
redo B; |
| 4227 |
} elsif ({ |
} elsif ({ |
| 4228 |
caption => 1, col => 1, colgroup => 1, |
caption => 1, col => 1, colgroup => 1, |
| 4229 |
tbody => 1, tfoot => 1, thead => 1, |
tbody => 1, tfoot => 1, thead => 1, |
| 4230 |
|
tr => 1, # $self->{insertion_mode} eq 'in row' |
| 4231 |
}->{$token->{tag_name}}) { |
}->{$token->{tag_name}}) { |
| 4232 |
## have an element in table scope |
if ($self->{insertion_mode} eq 'in row') { |
| 4233 |
my $i; |
## As if </tr> |
| 4234 |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
## have an element in table scope |
| 4235 |
my $node = $self->{open_elements}->[$_]; |
my $i; |
| 4236 |
if ({ |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
| 4237 |
tbody => 1, thead => 1, tfoot => 1, |
my $node = $self->{open_elements}->[$_]; |
| 4238 |
}->{$node->[1]}) { |
if ($node->[1] eq 'tr') { |
| 4239 |
$i = $_; |
$i = $_; |
| 4240 |
last INSCOPE; |
last INSCOPE; |
| 4241 |
} elsif ({ |
} elsif ({ |
| 4242 |
table => 1, html => 1, |
table => 1, html => 1, |
| 4243 |
}->{$node->[1]}) { |
}->{$node->[1]}) { |
| 4244 |
last INSCOPE; |
last INSCOPE; |
| 4245 |
|
} |
| 4246 |
|
} # INSCOPE |
| 4247 |
|
unless (defined $i) { |
| 4248 |
|
!!!parse-error (type => 'unmacthed end tag:'.$token->{tag_name}); |
| 4249 |
|
## Ignore the token |
| 4250 |
|
!!!next-token; |
| 4251 |
|
redo B; |
| 4252 |
|
} |
| 4253 |
|
|
| 4254 |
|
## Clear back to table row context |
| 4255 |
|
while (not { |
| 4256 |
|
tr => 1, html => 1, |
| 4257 |
|
}->{$self->{open_elements}->[-1]->[1]}) { |
| 4258 |
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
| 4259 |
|
pop @{$self->{open_elements}}; |
| 4260 |
|
} |
| 4261 |
|
|
| 4262 |
|
pop @{$self->{open_elements}}; # tr |
| 4263 |
|
$self->{insertion_mode} = 'in table body'; |
| 4264 |
|
if ($token->{tag_name} eq 'tr') { |
| 4265 |
|
## reprocess |
| 4266 |
|
redo B; |
| 4267 |
|
} else { |
| 4268 |
|
## reprocess in the "in table body" insertion mode... |
| 4269 |
} |
} |
|
} # INSCOPE |
|
|
unless (defined $i) { |
|
|
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
|
|
## Ignore the token |
|
|
!!!next-token; |
|
|
redo B; |
|
| 4270 |
} |
} |
| 4271 |
|
|
| 4272 |
## Clear back to table body context |
if ($self->{insertion_mode} eq 'in table body') { |
| 4273 |
while (not { |
## have an element in table scope |
| 4274 |
tbody => 1, tfoot => 1, thead => 1, html => 1, |
my $i; |
| 4275 |
}->{$self->{open_elements}->[-1]->[1]}) { |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
| 4276 |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
my $node = $self->{open_elements}->[$_]; |
| 4277 |
|
if ({ |
| 4278 |
|
tbody => 1, thead => 1, tfoot => 1, |
| 4279 |
|
}->{$node->[1]}) { |
| 4280 |
|
$i = $_; |
| 4281 |
|
last INSCOPE; |
| 4282 |
|
} elsif ({ |
| 4283 |
|
table => 1, html => 1, |
| 4284 |
|
}->{$node->[1]}) { |
| 4285 |
|
last INSCOPE; |
| 4286 |
|
} |
| 4287 |
|
} # INSCOPE |
| 4288 |
|
unless (defined $i) { |
| 4289 |
|
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
| 4290 |
|
## Ignore the token |
| 4291 |
|
!!!next-token; |
| 4292 |
|
redo B; |
| 4293 |
|
} |
| 4294 |
|
|
| 4295 |
|
## Clear back to table body context |
| 4296 |
|
while (not { |
| 4297 |
|
tbody => 1, tfoot => 1, thead => 1, html => 1, |
| 4298 |
|
}->{$self->{open_elements}->[-1]->[1]}) { |
| 4299 |
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
| 4300 |
|
pop @{$self->{open_elements}}; |
| 4301 |
|
} |
| 4302 |
|
|
| 4303 |
|
## As if <{current node}> |
| 4304 |
|
## have an element in table scope |
| 4305 |
|
## true by definition |
| 4306 |
|
|
| 4307 |
|
## Clear back to table body context |
| 4308 |
|
## nop by definition |
| 4309 |
|
|
| 4310 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 4311 |
|
$self->{insertion_mode} = 'in table'; |
| 4312 |
|
## reprocess in "in table" insertion mode... |
| 4313 |
} |
} |
| 4314 |
|
|
| 4315 |
## As if <{current node}> |
if ($token->{tag_name} eq 'col') { |
| 4316 |
## have an element in table scope |
## Clear back to table context |
| 4317 |
## true by definition |
while ($self->{open_elements}->[-1]->[1] ne 'table' and |
| 4318 |
|
$self->{open_elements}->[-1]->[1] ne 'html') { |
| 4319 |
## Clear back to table body context |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
| 4320 |
## nop by definition |
pop @{$self->{open_elements}}; |
| 4321 |
|
} |
| 4322 |
pop @{$self->{open_elements}}; |
|
| 4323 |
$self->{insertion_mode} = 'in table'; |
!!!insert-element ('colgroup'); |
| 4324 |
## reprocess |
$self->{insertion_mode} = 'in column group'; |
| 4325 |
redo B; |
## reprocess |
| 4326 |
|
redo B; |
| 4327 |
|
} elsif ({ |
| 4328 |
|
caption => 1, |
| 4329 |
|
colgroup => 1, |
| 4330 |
|
tbody => 1, tfoot => 1, thead => 1, |
| 4331 |
|
}->{$token->{tag_name}}) { |
| 4332 |
|
## Clear back to table context |
| 4333 |
|
while ($self->{open_elements}->[-1]->[1] ne 'table' and |
| 4334 |
|
$self->{open_elements}->[-1]->[1] ne 'html') { |
| 4335 |
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
| 4336 |
|
pop @{$self->{open_elements}}; |
| 4337 |
|
} |
| 4338 |
|
|
| 4339 |
|
push @$active_formatting_elements, ['#marker', ''] |
| 4340 |
|
if $token->{tag_name} eq 'caption'; |
| 4341 |
|
|
| 4342 |
|
!!!insert-element ($token->{tag_name}, $token->{attributes}); |
| 4343 |
|
$self->{insertion_mode} = { |
| 4344 |
|
caption => 'in caption', |
| 4345 |
|
colgroup => 'in column group', |
| 4346 |
|
tbody => 'in table body', |
| 4347 |
|
tfoot => 'in table body', |
| 4348 |
|
thead => 'in table body', |
| 4349 |
|
}->{$token->{tag_name}}; |
| 4350 |
|
!!!next-token; |
| 4351 |
|
redo B; |
| 4352 |
|
} else { |
| 4353 |
|
die "$0: in table: <>: $token->{tag_name}"; |
| 4354 |
|
} |
| 4355 |
} elsif ($token->{tag_name} eq 'table') { |
} elsif ($token->{tag_name} eq 'table') { |
| 4356 |
## NOTE: This is a code clone of "table in table" |
## NOTE: There are code clones for this "table in table" |
| 4357 |
!!!parse-error (type => 'not closed:table'); |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
| 4358 |
|
|
| 4359 |
## As if </table> |
## As if </table> |
| 4360 |
## have a table element in table scope |
## have a table element in table scope |
| 4397 |
|
|
| 4398 |
splice @{$self->{open_elements}}, $i; |
splice @{$self->{open_elements}}, $i; |
| 4399 |
|
|
| 4400 |
$self->_reset_insertion_mode; |
$self->_reset_insertion_mode; |
| 4401 |
|
|
| 4402 |
## reprocess |
## reprocess |
| 4403 |
redo B; |
redo B; |
| 4405 |
# |
# |
| 4406 |
} |
} |
| 4407 |
} elsif ($token->{type} eq 'end tag') { |
} elsif ($token->{type} eq 'end tag') { |
| 4408 |
if ({ |
if ($token->{tag_name} eq 'tr' and |
| 4409 |
tbody => 1, tfoot => 1, thead => 1, |
$self->{insertion_mode} eq 'in row') { |
|
}->{$token->{tag_name}}) { |
|
| 4410 |
## have an element in table scope |
## have an element in table scope |
| 4411 |
my $i; |
my $i; |
| 4412 |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
| 4427 |
redo B; |
redo B; |
| 4428 |
} |
} |
| 4429 |
|
|
| 4430 |
## Clear back to table body context |
## Clear back to table row context |
| 4431 |
while (not { |
while (not { |
| 4432 |
tbody => 1, tfoot => 1, thead => 1, html => 1, |
tr => 1, html => 1, |
| 4433 |
}->{$self->{open_elements}->[-1]->[1]}) { |
}->{$self->{open_elements}->[-1]->[1]}) { |
| 4434 |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
| 4435 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 4436 |
} |
} |
| 4437 |
|
|
| 4438 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; # tr |
| 4439 |
$self->{insertion_mode} = 'in table'; |
$self->{insertion_mode} = 'in table body'; |
| 4440 |
!!!next-token; |
!!!next-token; |
| 4441 |
redo B; |
redo B; |
| 4442 |
} elsif ($token->{tag_name} eq 'table') { |
} elsif ($token->{tag_name} eq 'table') { |
| 4443 |
## have an element in table scope |
if ($self->{insertion_mode} eq 'in row') { |
| 4444 |
my $i; |
## As if </tr> |
| 4445 |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
## have an element in table scope |
| 4446 |
my $node = $self->{open_elements}->[$_]; |
my $i; |
| 4447 |
if ({ |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
| 4448 |
tbody => 1, thead => 1, tfoot => 1, |
my $node = $self->{open_elements}->[$_]; |
| 4449 |
}->{$node->[1]}) { |
if ($node->[1] eq 'tr') { |
| 4450 |
$i = $_; |
$i = $_; |
| 4451 |
last INSCOPE; |
last INSCOPE; |
| 4452 |
} elsif ({ |
} elsif ({ |
| 4453 |
table => 1, html => 1, |
table => 1, html => 1, |
| 4454 |
}->{$node->[1]}) { |
}->{$node->[1]}) { |
| 4455 |
last INSCOPE; |
last INSCOPE; |
| 4456 |
} |
} |
| 4457 |
} # INSCOPE |
} # INSCOPE |
| 4458 |
unless (defined $i) { |
unless (defined $i) { |
| 4459 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
!!!parse-error (type => 'unmatched end tag:'.$token->{type}); |
| 4460 |
## Ignore the token |
## Ignore the token |
| 4461 |
!!!next-token; |
!!!next-token; |
| 4462 |
redo B; |
redo B; |
| 4463 |
} |
} |
| 4464 |
|
|
| 4465 |
## Clear back to table body context |
## Clear back to table row context |
| 4466 |
while (not { |
while (not { |
| 4467 |
tbody => 1, tfoot => 1, thead => 1, html => 1, |
tr => 1, html => 1, |
|
}->{$self->{open_elements}->[-1]->[1]}) { |
|
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
|
|
pop @{$self->{open_elements}}; |
|
|
} |
|
|
|
|
|
## As if <{current node}> |
|
|
## have an element in table scope |
|
|
## true by definition |
|
|
|
|
|
## Clear back to table body context |
|
|
## nop by definition |
|
|
|
|
|
pop @{$self->{open_elements}}; |
|
|
$self->{insertion_mode} = 'in table'; |
|
|
## reprocess |
|
|
redo B; |
|
|
} elsif ({ |
|
|
body => 1, caption => 1, col => 1, colgroup => 1, |
|
|
html => 1, td => 1, th => 1, tr => 1, |
|
|
}->{$token->{tag_name}}) { |
|
|
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
|
|
## Ignore the token |
|
|
!!!next-token; |
|
|
redo B; |
|
|
} else { |
|
|
# |
|
|
} |
|
|
} else { |
|
|
# |
|
|
} |
|
|
|
|
|
## As if in table |
|
|
!!!parse-error (type => 'in table:'.$token->{tag_name}); |
|
|
$in_body->($insert_to_foster); |
|
|
redo B; |
|
|
} elsif ($self->{insertion_mode} eq 'in row') { |
|
|
if ($token->{type} eq 'character') { |
|
|
## NOTE: This is a "character in table" code clone. |
|
|
if ($token->{data} =~ s/^([\x09\x0A\x0B\x0C\x20]+)//) { |
|
|
$self->{open_elements}->[-1]->[0]->manakai_append_text ($1); |
|
|
|
|
|
unless (length $token->{data}) { |
|
|
!!!next-token; |
|
|
redo B; |
|
|
} |
|
|
} |
|
|
|
|
|
!!!parse-error (type => 'in table:#character'); |
|
|
|
|
|
## As if in body, but insert into foster parent element |
|
|
## ISSUE: Spec says that "whenever a node would be inserted |
|
|
## into the current node" while characters might not be |
|
|
## result in a new Text node. |
|
|
$reconstruct_active_formatting_elements->($insert_to_foster); |
|
|
|
|
|
if ({ |
|
|
table => 1, tbody => 1, tfoot => 1, |
|
|
thead => 1, tr => 1, |
|
| 4468 |
}->{$self->{open_elements}->[-1]->[1]}) { |
}->{$self->{open_elements}->[-1]->[1]}) { |
| 4469 |
# MUST |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
| 4470 |
my $foster_parent_element; |
pop @{$self->{open_elements}}; |
| 4471 |
my $next_sibling; |
} |
| 4472 |
my $prev_sibling; |
|
| 4473 |
OE: for (reverse 0..$#{$self->{open_elements}}) { |
pop @{$self->{open_elements}}; # tr |
| 4474 |
if ($self->{open_elements}->[$_]->[1] eq 'table') { |
$self->{insertion_mode} = 'in table body'; |
| 4475 |
my $parent = $self->{open_elements}->[$_]->[0]->parent_node; |
## reprocess in the "in table body" insertion mode... |
| 4476 |
if (defined $parent and $parent->node_type == 1) { |
} |
| 4477 |
$foster_parent_element = $parent; |
|
| 4478 |
$next_sibling = $self->{open_elements}->[$_]->[0]; |
if ($self->{insertion_mode} eq 'in table body') { |
| 4479 |
$prev_sibling = $next_sibling->previous_sibling; |
## have an element in table scope |
| 4480 |
} else { |
my $i; |
| 4481 |
$foster_parent_element = $self->{open_elements}->[$_ - 1]->[0]; |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
| 4482 |
$prev_sibling = $foster_parent_element->last_child; |
my $node = $self->{open_elements}->[$_]; |
| 4483 |
|
if ({ |
| 4484 |
|
tbody => 1, thead => 1, tfoot => 1, |
| 4485 |
|
}->{$node->[1]}) { |
| 4486 |
|
$i = $_; |
| 4487 |
|
last INSCOPE; |
| 4488 |
|
} elsif ({ |
| 4489 |
|
table => 1, html => 1, |
| 4490 |
|
}->{$node->[1]}) { |
| 4491 |
|
last INSCOPE; |
| 4492 |
} |
} |
| 4493 |
last OE; |
} # INSCOPE |
| 4494 |
|
unless (defined $i) { |
| 4495 |
|
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
| 4496 |
|
## Ignore the token |
| 4497 |
|
!!!next-token; |
| 4498 |
|
redo B; |
| 4499 |
|
} |
| 4500 |
|
|
| 4501 |
|
## Clear back to table body context |
| 4502 |
|
while (not { |
| 4503 |
|
tbody => 1, tfoot => 1, thead => 1, html => 1, |
| 4504 |
|
}->{$self->{open_elements}->[-1]->[1]}) { |
| 4505 |
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
| 4506 |
|
pop @{$self->{open_elements}}; |
| 4507 |
} |
} |
| 4508 |
} # OE |
|
| 4509 |
$foster_parent_element = $self->{open_elements}->[0]->[0] and |
## As if <{current node}> |
| 4510 |
$prev_sibling = $foster_parent_element->last_child |
## have an element in table scope |
| 4511 |
unless defined $foster_parent_element; |
## true by definition |
| 4512 |
if (defined $prev_sibling and |
|
| 4513 |
$prev_sibling->node_type == 3) { |
## Clear back to table body context |
| 4514 |
$prev_sibling->manakai_append_text ($token->{data}); |
## nop by definition |
| 4515 |
} else { |
|
|
$foster_parent_element->insert_before |
|
|
($self->{document}->create_text_node ($token->{data}), |
|
|
$next_sibling); |
|
|
} |
|
|
} else { |
|
|
$self->{open_elements}->[-1]->[0]->manakai_append_text ($token->{data}); |
|
|
} |
|
|
|
|
|
!!!next-token; |
|
|
redo B; |
|
|
} elsif ($token->{type} eq 'start tag') { |
|
|
if ($token->{tag_name} eq 'th' or |
|
|
$token->{tag_name} eq 'td') { |
|
|
## Clear back to table row context |
|
|
while (not { |
|
|
tr => 1, html => 1, |
|
|
}->{$self->{open_elements}->[-1]->[1]}) { |
|
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
|
| 4516 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 4517 |
|
$self->{insertion_mode} = 'in table'; |
| 4518 |
|
## reprocess in the "in table" insertion mode... |
| 4519 |
} |
} |
|
|
|
|
!!!insert-element ($token->{tag_name}, $token->{attributes}); |
|
|
$self->{insertion_mode} = 'in cell'; |
|
| 4520 |
|
|
| 4521 |
push @$active_formatting_elements, ['#marker', '']; |
## have a table element in table scope |
|
|
|
|
!!!next-token; |
|
|
redo B; |
|
|
} elsif ({ |
|
|
caption => 1, col => 1, colgroup => 1, |
|
|
tbody => 1, tfoot => 1, thead => 1, tr => 1, |
|
|
}->{$token->{tag_name}}) { |
|
|
## As if </tr> |
|
|
## have an element in table scope |
|
| 4522 |
my $i; |
my $i; |
| 4523 |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
| 4524 |
my $node = $self->{open_elements}->[$_]; |
my $node = $self->{open_elements}->[$_]; |
| 4525 |
if ($node->[1] eq 'tr') { |
if ($node->[1] eq $token->{tag_name}) { |
| 4526 |
$i = $_; |
$i = $_; |
| 4527 |
last INSCOPE; |
last INSCOPE; |
| 4528 |
} elsif ({ |
} elsif ({ |
| 4532 |
} |
} |
| 4533 |
} # INSCOPE |
} # INSCOPE |
| 4534 |
unless (defined $i) { |
unless (defined $i) { |
| 4535 |
!!!parse-error (type => 'unmacthed end tag:'.$token->{tag_name}); |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
| 4536 |
## Ignore the token |
## Ignore the token |
| 4537 |
!!!next-token; |
!!!next-token; |
| 4538 |
redo B; |
redo B; |
| 4539 |
} |
} |
| 4540 |
|
|
|
## Clear back to table row context |
|
|
while (not { |
|
|
tr => 1, html => 1, |
|
|
}->{$self->{open_elements}->[-1]->[1]}) { |
|
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
|
|
pop @{$self->{open_elements}}; |
|
|
} |
|
|
|
|
|
pop @{$self->{open_elements}}; # tr |
|
|
$self->{insertion_mode} = 'in table body'; |
|
|
## reprocess |
|
|
redo B; |
|
|
} elsif ($token->{tag_name} eq 'table') { |
|
|
## NOTE: This is a code clone of "table in table" |
|
|
!!!parse-error (type => 'not closed:table'); |
|
|
|
|
|
## As if </table> |
|
|
## have a table element in table scope |
|
|
my $i; |
|
|
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
|
|
my $node = $self->{open_elements}->[$_]; |
|
|
if ($node->[1] eq 'table') { |
|
|
$i = $_; |
|
|
last INSCOPE; |
|
|
} elsif ({ |
|
|
table => 1, html => 1, |
|
|
}->{$node->[1]}) { |
|
|
last INSCOPE; |
|
|
} |
|
|
} # INSCOPE |
|
|
unless (defined $i) { |
|
|
!!!parse-error (type => 'unmatched end tag:table'); |
|
|
## Ignore tokens </table><table> |
|
|
!!!next-token; |
|
|
redo B; |
|
|
} |
|
|
|
|
| 4541 |
## generate implied end tags |
## generate implied end tags |
| 4542 |
if ({ |
if ({ |
| 4543 |
dd => 1, dt => 1, li => 1, p => 1, |
dd => 1, dt => 1, li => 1, p => 1, |
| 4544 |
td => 1, th => 1, tr => 1, |
td => 1, th => 1, tr => 1, |
| 4545 |
tbody => 1, tfoot=> 1, thead => 1, |
tbody => 1, tfoot=> 1, thead => 1, |
| 4546 |
}->{$self->{open_elements}->[-1]->[1]}) { |
}->{$self->{open_elements}->[-1]->[1]}) { |
|
!!!back-token; # <table> |
|
|
$token = {type => 'end tag', tag_name => 'table'}; |
|
| 4547 |
!!!back-token; |
!!!back-token; |
| 4548 |
$token = {type => 'end tag', |
$token = {type => 'end tag', |
| 4549 |
tag_name => $self->{open_elements}->[-1]->[1]}; # MUST |
tag_name => $self->{open_elements}->[-1]->[1]}; # MUST |
| 4550 |
redo B; |
redo B; |
| 4551 |
} |
} |
| 4552 |
|
|
| 4553 |
if ($self->{open_elements}->[-1]->[1] ne 'table') { |
if ($self->{open_elements}->[-1]->[1] ne 'table') { |
| 4554 |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
| 4555 |
} |
} |
| 4556 |
|
|
| 4557 |
splice @{$self->{open_elements}}, $i; |
splice @{$self->{open_elements}}, $i; |
| 4558 |
|
|
| 4559 |
$self->_reset_insertion_mode; |
$self->_reset_insertion_mode; |
| 4560 |
|
|
|
## reprocess |
|
|
redo B; |
|
|
} else { |
|
|
# |
|
|
} |
|
|
} elsif ($token->{type} eq 'end tag') { |
|
|
if ($token->{tag_name} eq 'tr') { |
|
|
## have an element in table scope |
|
|
my $i; |
|
|
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
|
|
my $node = $self->{open_elements}->[$_]; |
|
|
if ($node->[1] eq $token->{tag_name}) { |
|
|
$i = $_; |
|
|
last INSCOPE; |
|
|
} elsif ({ |
|
|
table => 1, html => 1, |
|
|
}->{$node->[1]}) { |
|
|
last INSCOPE; |
|
|
} |
|
|
} # INSCOPE |
|
|
unless (defined $i) { |
|
|
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
|
|
## Ignore the token |
|
|
!!!next-token; |
|
|
redo B; |
|
|
} |
|
|
|
|
|
## Clear back to table row context |
|
|
while (not { |
|
|
tr => 1, html => 1, |
|
|
}->{$self->{open_elements}->[-1]->[1]}) { |
|
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
|
|
pop @{$self->{open_elements}}; |
|
|
} |
|
|
|
|
|
pop @{$self->{open_elements}}; # tr |
|
|
$self->{insertion_mode} = 'in table body'; |
|
| 4561 |
!!!next-token; |
!!!next-token; |
| 4562 |
redo B; |
redo B; |
|
} elsif ($token->{tag_name} eq 'table') { |
|
|
## As if </tr> |
|
|
## have an element in table scope |
|
|
my $i; |
|
|
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
|
|
my $node = $self->{open_elements}->[$_]; |
|
|
if ($node->[1] eq 'tr') { |
|
|
$i = $_; |
|
|
last INSCOPE; |
|
|
} elsif ({ |
|
|
table => 1, html => 1, |
|
|
}->{$node->[1]}) { |
|
|
last INSCOPE; |
|
|
} |
|
|
} # INSCOPE |
|
|
unless (defined $i) { |
|
|
!!!parse-error (type => 'unmatched end tag:'.$token->{type}); |
|
|
## Ignore the token |
|
|
!!!next-token; |
|
|
redo B; |
|
|
} |
|
|
|
|
|
## Clear back to table row context |
|
|
while (not { |
|
|
tr => 1, html => 1, |
|
|
}->{$self->{open_elements}->[-1]->[1]}) { |
|
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
|
|
pop @{$self->{open_elements}}; |
|
|
} |
|
|
|
|
|
pop @{$self->{open_elements}}; # tr |
|
|
$self->{insertion_mode} = 'in table body'; |
|
|
## reprocess |
|
|
redo B; |
|
| 4563 |
} elsif ({ |
} elsif ({ |
| 4564 |
tbody => 1, tfoot => 1, thead => 1, |
tbody => 1, tfoot => 1, thead => 1, |
| 4565 |
}->{$token->{tag_name}}) { |
}->{$token->{tag_name}} and |
| 4566 |
## have an element in table scope |
($self->{insertion_mode} eq 'in row' or |
| 4567 |
my $i; |
$self->{insertion_mode} eq 'in table body')) { |
| 4568 |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
if ($self->{insertion_mode} eq 'in row') { |
| 4569 |
my $node = $self->{open_elements}->[$_]; |
## have an element in table scope |
| 4570 |
if ($node->[1] eq $token->{tag_name}) { |
my $i; |
| 4571 |
$i = $_; |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
| 4572 |
last INSCOPE; |
my $node = $self->{open_elements}->[$_]; |
| 4573 |
} elsif ({ |
if ($node->[1] eq $token->{tag_name}) { |
| 4574 |
table => 1, html => 1, |
$i = $_; |
| 4575 |
}->{$node->[1]}) { |
last INSCOPE; |
| 4576 |
last INSCOPE; |
} elsif ({ |
| 4577 |
|
table => 1, html => 1, |
| 4578 |
|
}->{$node->[1]}) { |
| 4579 |
|
last INSCOPE; |
| 4580 |
|
} |
| 4581 |
|
} # INSCOPE |
| 4582 |
|
unless (defined $i) { |
| 4583 |
|
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
| 4584 |
|
## Ignore the token |
| 4585 |
|
!!!next-token; |
| 4586 |
|
redo B; |
| 4587 |
|
} |
| 4588 |
|
|
| 4589 |
|
## As if </tr> |
| 4590 |
|
## have an element in table scope |
| 4591 |
|
my $i; |
| 4592 |
|
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
| 4593 |
|
my $node = $self->{open_elements}->[$_]; |
| 4594 |
|
if ($node->[1] eq 'tr') { |
| 4595 |
|
$i = $_; |
| 4596 |
|
last INSCOPE; |
| 4597 |
|
} elsif ({ |
| 4598 |
|
table => 1, html => 1, |
| 4599 |
|
}->{$node->[1]}) { |
| 4600 |
|
last INSCOPE; |
| 4601 |
|
} |
| 4602 |
|
} # INSCOPE |
| 4603 |
|
unless (defined $i) { |
| 4604 |
|
!!!parse-error (type => 'unmatched end tag:tr'); |
| 4605 |
|
## Ignore the token |
| 4606 |
|
!!!next-token; |
| 4607 |
|
redo B; |
| 4608 |
|
} |
| 4609 |
|
|
| 4610 |
|
## Clear back to table row context |
| 4611 |
|
while (not { |
| 4612 |
|
tr => 1, html => 1, |
| 4613 |
|
}->{$self->{open_elements}->[-1]->[1]}) { |
| 4614 |
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
| 4615 |
|
pop @{$self->{open_elements}}; |
| 4616 |
} |
} |
| 4617 |
} # INSCOPE |
|
| 4618 |
unless (defined $i) { |
pop @{$self->{open_elements}}; # tr |
| 4619 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
$self->{insertion_mode} = 'in table body'; |
| 4620 |
## Ignore the token |
## reprocess in the "in table body" insertion mode... |
|
!!!next-token; |
|
|
redo B; |
|
| 4621 |
} |
} |
| 4622 |
|
|
|
## As if </tr> |
|
| 4623 |
## have an element in table scope |
## have an element in table scope |
| 4624 |
my $i; |
my $i; |
| 4625 |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
| 4626 |
my $node = $self->{open_elements}->[$_]; |
my $node = $self->{open_elements}->[$_]; |
| 4627 |
if ($node->[1] eq 'tr') { |
if ($node->[1] eq $token->{tag_name}) { |
| 4628 |
$i = $_; |
$i = $_; |
| 4629 |
last INSCOPE; |
last INSCOPE; |
| 4630 |
} elsif ({ |
} elsif ({ |
| 4634 |
} |
} |
| 4635 |
} # INSCOPE |
} # INSCOPE |
| 4636 |
unless (defined $i) { |
unless (defined $i) { |
| 4637 |
!!!parse-error (type => 'unmatched end tag:tr'); |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
| 4638 |
## Ignore the token |
## Ignore the token |
| 4639 |
!!!next-token; |
!!!next-token; |
| 4640 |
redo B; |
redo B; |
| 4641 |
} |
} |
| 4642 |
|
|
| 4643 |
## Clear back to table row context |
## Clear back to table body context |
| 4644 |
while (not { |
while (not { |
| 4645 |
tr => 1, html => 1, |
tbody => 1, tfoot => 1, thead => 1, html => 1, |
| 4646 |
}->{$self->{open_elements}->[-1]->[1]}) { |
}->{$self->{open_elements}->[-1]->[1]}) { |
| 4647 |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
| 4648 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 4649 |
} |
} |
| 4650 |
|
|
| 4651 |
pop @{$self->{open_elements}}; # tr |
pop @{$self->{open_elements}}; |
| 4652 |
$self->{insertion_mode} = 'in table body'; |
$self->{insertion_mode} = 'in table'; |
| 4653 |
## reprocess |
!!!next-token; |
| 4654 |
redo B; |
redo B; |
| 4655 |
} elsif ({ |
} elsif ({ |
| 4656 |
body => 1, caption => 1, col => 1, |
body => 1, caption => 1, col => 1, colgroup => 1, |
| 4657 |
colgroup => 1, html => 1, td => 1, th => 1, |
html => 1, td => 1, th => 1, |
| 4658 |
|
tr => 1, # $self->{insertion_mode} eq 'in row' |
| 4659 |
|
tbody => 1, tfoot => 1, thead => 1, # $self->{insertion_mode} eq 'in table' |
| 4660 |
}->{$token->{tag_name}}) { |
}->{$token->{tag_name}}) { |
| 4661 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
| 4662 |
## Ignore the token |
## Ignore the token |
| 4666 |
# |
# |
| 4667 |
} |
} |
| 4668 |
} else { |
} else { |
| 4669 |
# |
die "$0: $token->{type}: Unknown token type"; |
| 4670 |
} |
} |
| 4671 |
|
|
|
## As if in table |
|
| 4672 |
!!!parse-error (type => 'in table:'.$token->{tag_name}); |
!!!parse-error (type => 'in table:'.$token->{tag_name}); |
| 4673 |
$in_body->($insert_to_foster); |
$in_body->($insert_to_foster); |
| 4674 |
redo B; |
redo B; |
| 4675 |
} elsif ($self->{insertion_mode} eq 'in cell') { |
} elsif ($self->{insertion_mode} eq 'in column group') { |
| 4676 |
if ($token->{type} eq 'character') { |
if ($token->{type} eq 'character') { |
| 4677 |
## NOTE: This is a code clone of "character in body". |
if ($token->{data} =~ s/^([\x09\x0A\x0B\x0C\x20]+)//) { |
| 4678 |
$reconstruct_active_formatting_elements->($insert_to_current); |
$self->{open_elements}->[-1]->[0]->manakai_append_text ($1); |
| 4679 |
|
unless (length $token->{data}) { |
|
$self->{open_elements}->[-1]->[0]->manakai_append_text ($token->{data}); |
|
|
|
|
|
!!!next-token; |
|
|
redo B; |
|
|
} elsif ($token->{type} eq 'start tag') { |
|
|
if ({ |
|
|
caption => 1, col => 1, colgroup => 1, |
|
|
tbody => 1, td => 1, tfoot => 1, th => 1, |
|
|
thead => 1, tr => 1, |
|
|
}->{$token->{tag_name}}) { |
|
|
## have an element in table scope |
|
|
my $tn; |
|
|
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
|
|
my $node = $self->{open_elements}->[$_]; |
|
|
if ($node->[1] eq 'td' or $node->[1] eq 'th') { |
|
|
$tn = $node->[1]; |
|
|
last INSCOPE; |
|
|
} elsif ({ |
|
|
table => 1, html => 1, |
|
|
}->{$node->[1]}) { |
|
|
last INSCOPE; |
|
|
} |
|
|
} # INSCOPE |
|
|
unless (defined $tn) { |
|
|
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
|
|
## Ignore the token |
|
| 4680 |
!!!next-token; |
!!!next-token; |
| 4681 |
redo B; |
redo B; |
| 4682 |
} |
} |
| 4683 |
|
} |
| 4684 |
## Close the cell |
|
| 4685 |
!!!back-token; # <?> |
# |
| 4686 |
$token = {type => 'end tag', tag_name => $tn}; |
} elsif ($token->{type} eq 'start tag') { |
| 4687 |
|
if ($token->{tag_name} eq 'col') { |
| 4688 |
|
!!!insert-element ($token->{tag_name}, $token->{attributes}); |
| 4689 |
|
pop @{$self->{open_elements}}; |
| 4690 |
|
!!!next-token; |
| 4691 |
redo B; |
redo B; |
| 4692 |
} else { |
} else { |
| 4693 |
# |
# |
| 4694 |
} |
} |
| 4695 |
} elsif ($token->{type} eq 'end tag') { |
} elsif ($token->{type} eq 'end tag') { |
| 4696 |
if ($token->{tag_name} eq 'td' or $token->{tag_name} eq 'th') { |
if ($token->{tag_name} eq 'colgroup') { |
| 4697 |
## have an element in table scope |
if ($self->{open_elements}->[-1]->[1] eq 'html') { |
| 4698 |
my $i; |
!!!parse-error (type => 'unmatched end tag:colgroup'); |
|
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
|
|
my $node = $self->{open_elements}->[$_]; |
|
|
if ($node->[1] eq $token->{tag_name}) { |
|
|
$i = $_; |
|
|
last INSCOPE; |
|
|
} elsif ({ |
|
|
table => 1, html => 1, |
|
|
}->{$node->[1]}) { |
|
|
last INSCOPE; |
|
|
} |
|
|
} # INSCOPE |
|
|
unless (defined $i) { |
|
|
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
|
| 4699 |
## Ignore the token |
## Ignore the token |
| 4700 |
!!!next-token; |
!!!next-token; |
| 4701 |
redo B; |
redo B; |
| 4702 |
|
} else { |
| 4703 |
|
pop @{$self->{open_elements}}; # colgroup |
| 4704 |
|
$self->{insertion_mode} = 'in table'; |
| 4705 |
|
!!!next-token; |
| 4706 |
|
redo B; |
| 4707 |
} |
} |
| 4708 |
|
} elsif ($token->{tag_name} eq 'col') { |
| 4709 |
## generate implied end tags |
!!!parse-error (type => 'unmatched end tag:col'); |
|
if ({ |
|
|
dd => 1, dt => 1, li => 1, p => 1, |
|
|
td => ($token->{tag_name} eq 'th'), |
|
|
th => ($token->{tag_name} eq 'td'), |
|
|
tr => 1, |
|
|
tbody => 1, tfoot=> 1, thead => 1, |
|
|
}->{$self->{open_elements}->[-1]->[1]}) { |
|
|
!!!back-token; |
|
|
$token = {type => 'end tag', |
|
|
tag_name => $self->{open_elements}->[-1]->[1]}; # MUST |
|
|
redo B; |
|
|
} |
|
|
|
|
|
if ($self->{open_elements}->[-1]->[1] ne $token->{tag_name}) { |
|
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
|
|
} |
|
|
|
|
|
splice @{$self->{open_elements}}, $i; |
|
|
|
|
|
$clear_up_to_marker->(); |
|
|
|
|
|
$self->{insertion_mode} = 'in row'; |
|
|
|
|
|
!!!next-token; |
|
|
redo B; |
|
|
} elsif ({ |
|
|
body => 1, caption => 1, col => 1, |
|
|
colgroup => 1, html => 1, |
|
|
}->{$token->{tag_name}}) { |
|
|
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
|
| 4710 |
## Ignore the token |
## Ignore the token |
| 4711 |
!!!next-token; |
!!!next-token; |
| 4712 |
redo B; |
redo B; |
|
} elsif ({ |
|
|
table => 1, tbody => 1, tfoot => 1, |
|
|
thead => 1, tr => 1, |
|
|
}->{$token->{tag_name}}) { |
|
|
## have an element in table scope |
|
|
my $i; |
|
|
my $tn; |
|
|
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
|
|
my $node = $self->{open_elements}->[$_]; |
|
|
if ($node->[1] eq $token->{tag_name}) { |
|
|
$i = $_; |
|
|
last INSCOPE; |
|
|
} elsif ($node->[1] eq 'td' or $node->[1] eq 'th') { |
|
|
$tn = $node->[1]; |
|
|
## NOTE: There is exactly one |td| or |th| element |
|
|
## in scope in the stack of open elements by definition. |
|
|
} elsif ({ |
|
|
table => 1, html => 1, |
|
|
}->{$node->[1]}) { |
|
|
last INSCOPE; |
|
|
} |
|
|
} # INSCOPE |
|
|
unless (defined $i) { |
|
|
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
|
|
## Ignore the token |
|
|
!!!next-token; |
|
|
redo B; |
|
|
} |
|
|
|
|
|
## Close the cell |
|
|
!!!back-token; # </?> |
|
|
$token = {type => 'end tag', tag_name => $tn}; |
|
|
redo B; |
|
| 4713 |
} else { |
} else { |
| 4714 |
# |
# |
| 4715 |
} |
} |
| 4716 |
} else { |
} else { |
| 4717 |
# |
# |
| 4718 |
} |
} |
| 4719 |
|
|
| 4720 |
$in_body->($insert_to_current); |
## As if </colgroup> |
| 4721 |
redo B; |
if ($self->{open_elements}->[-1]->[1] eq 'html') { |
| 4722 |
|
!!!parse-error (type => 'unmatched end tag:colgroup'); |
| 4723 |
|
## Ignore the token |
| 4724 |
|
!!!next-token; |
| 4725 |
|
redo B; |
| 4726 |
|
} else { |
| 4727 |
|
pop @{$self->{open_elements}}; # colgroup |
| 4728 |
|
$self->{insertion_mode} = 'in table'; |
| 4729 |
|
## reprocess |
| 4730 |
|
redo B; |
| 4731 |
|
} |
| 4732 |
} elsif ($self->{insertion_mode} eq 'in select') { |
} elsif ($self->{insertion_mode} eq 'in select') { |
| 4733 |
if ($token->{type} eq 'character') { |
if ($token->{type} eq 'character') { |
| 4734 |
$self->{open_elements}->[-1]->[0]->manakai_append_text ($token->{data}); |
$self->{open_elements}->[-1]->[0]->manakai_append_text ($token->{data}); |
| 4972 |
!!!next-token; |
!!!next-token; |
| 4973 |
redo B; |
redo B; |
| 4974 |
} elsif ($token->{tag_name} eq 'noframes') { |
} elsif ($token->{tag_name} eq 'noframes') { |
| 4975 |
$in_body->($insert_to_current); |
## NOTE: As if in body. |
| 4976 |
|
$parse_rcdata->(CDATA_CONTENT_MODEL, $insert_to_current); |
| 4977 |
redo B; |
redo B; |
| 4978 |
} else { |
} else { |
| 4979 |
!!!parse-error (type => 'in frameset:'.$token->{tag_name}); |
!!!parse-error (type => 'in frameset:'.$token->{tag_name}); |
| 5033 |
die qq[$0: Character "$token->{data}"]; |
die qq[$0: Character "$token->{data}"]; |
| 5034 |
} elsif ($token->{type} eq 'start tag') { |
} elsif ($token->{type} eq 'start tag') { |
| 5035 |
if ($token->{tag_name} eq 'noframes') { |
if ($token->{tag_name} eq 'noframes') { |
| 5036 |
$in_body->($insert_to_current); |
## NOTE: As if in body. |
| 5037 |
|
$parse_rcdata->(CDATA_CONTENT_MODEL, $insert_to_current); |
| 5038 |
redo B; |
redo B; |
| 5039 |
} else { |
} else { |
| 5040 |
!!!parse-error (type => 'after frameset:'.$token->{tag_name}); |
!!!parse-error (type => 'after frameset:'.$token->{tag_name}); |