| 50 |
my @s = split /\x0D\x0A?|\x0A/, ref $_[0] ? ${$_[0]} : $_[0], -1; |
my @s = split /\x0D\x0A?|\x0A/, ref $_[0] ? ${$_[0]} : $_[0], -1; |
| 51 |
|
|
| 52 |
my $doc = $_[1]; |
my $doc = $_[1]; |
| 53 |
$doc->inner_html |
@{$doc->child_nodes} = (); |
| 54 |
('<html xmlns="http://www.w3.org/1999/xhtml"><head/><body/></html>'); |
my $html_el = $doc->create_element_ns (HTML_NS, [undef, 'html']); |
| 55 |
for ($doc, |
$doc->append_child ($html_el); |
| 56 |
$doc->document_element, |
$html_el->set_attribute_ns |
| 57 |
$doc->document_element->first_child, |
('http://www.w3.org/2000/xmlns/', [undef, 'xmlns'] => HTML_NS); |
| 58 |
$doc->document_element->last_child) { |
my $head_el = $doc->create_element_ns (HTML_NS, [undef, 'head']); |
| 59 |
|
$html_el->append_child ($head_el); |
| 60 |
|
my $body_el = $doc->create_element_ns (HTML_NS, [undef, 'body']); |
| 61 |
|
$html_el->append_child ($body_el); |
| 62 |
|
for ($doc, $html_el, $head_el, $body_el) { |
| 63 |
$_->set_user_data (manakai_source_line => 1); |
$_->set_user_data (manakai_source_line => 1); |
| 64 |
$_->set_user_data (manakai_source_column => 1); |
$_->set_user_data (manakai_source_column => 1); |
| 65 |
} |
} |
| 258 |
} |
} |
| 259 |
} |
} |
| 260 |
return shift @nt; |
return shift @nt; |
| 261 |
} elsif ($s =~ s/^(\*+)\s*//) { |
} elsif ($s =~ s/^(\*+)[\x09\x20]*//) { |
| 262 |
push @nt, {type => HEADING_START_TOKEN, depth => length $1, |
push @nt, {type => HEADING_START_TOKEN, depth => length $1, |
| 263 |
line => $line, column => $column}; |
line => $line, column => $column}; |
| 264 |
$column += $+[0] - $-[0]; |
$column += $+[0] - $-[0]; |
| 267 |
line => $line, column => $column}; |
line => $line, column => $column}; |
| 268 |
undef $continuous_line; |
undef $continuous_line; |
| 269 |
return shift @nt; |
return shift @nt; |
| 270 |
} elsif ($s =~ s/^([-=]+)\s*//) { |
} elsif ($s =~ s/^([-=]+)[\x09\x20]*//) { |
| 271 |
push @nt, {type => LIST_START_TOKEN, depth => $1, |
push @nt, {type => LIST_START_TOKEN, depth => $1, |
| 272 |
line => $line, column => $column}; |
line => $line, column => $column}; |
| 273 |
$column += $+[0] - $-[0]; |
$column += $+[0] - $-[0]; |
| 416 |
undef $continuous_line; |
undef $continuous_line; |
| 417 |
return shift @nt; |
return shift @nt; |
| 418 |
} elsif ($s eq '__IMAGE__') { |
} elsif ($s eq '__IMAGE__') { |
| 419 |
my $image = $doc->create_element_ns (SW09_NS, 'image'); |
my $image = $doc->create_element_ns (SW09_NS, [undef, 'image']); |
| 420 |
$image->set_user_data (manakai_source_line => $line); |
$image->set_user_data (manakai_source_line => $line); |
| 421 |
$image->set_user_data (manakai_source_column => 1); |
$image->set_user_data (manakai_source_column => 1); |
| 422 |
$image->text_content (join "\x0A", $s, @s); |
$image->text_content (join "\x0A", $s, @s); |
| 432 |
$continuous_line = 1; |
$continuous_line = 1; |
| 433 |
return shift @nt; |
return shift @nt; |
| 434 |
} |
} |
| 435 |
}; # $get_next_token_body |
}; # $get_next_token |
| 436 |
|
|
| 437 |
## NOTE: The "initial" mode. |
## NOTE: The "initial" mode. |
| 438 |
if (@s and $s[0] =~ /^#\?/) { |
if (@s and $s[0] =~ /^#\?/) { |
| 443 |
$column += $+[0] - $-[0]; |
$column += $+[0] - $-[0]; |
| 444 |
my ($name, $version) = split m#/#, $1, 2; |
my ($name, $version) = split m#/#, $1, 2; |
| 445 |
my $el = $doc->document_element; |
my $el = $doc->document_element; |
| 446 |
$el->set_attribute_ns (SW09_NS, 'sw:Name' => $name); |
$el->set_attribute_ns (SW09_NS, ['sw', 'Name'] => $name); |
| 447 |
$el->set_attribute_ns (SW09_NS, 'sw:Version' => $version) |
$el->set_attribute_ns (SW09_NS, ['sw', 'Version'] => $version) |
| 448 |
if defined $version; |
if defined $version; |
| 449 |
} |
} |
| 450 |
|
|
|
my $head = $doc->first_child; |
|
| 451 |
while (length $s) { |
while (length $s) { |
| 452 |
$column += $+[0] - $-[0] if $s =~ s/^[\x09\x20]+//; |
$column += $+[0] - $-[0] if $s =~ s/^[\x09\x20]+//; |
| 453 |
my $name = ''; |
my $name = ''; |
| 455 |
$name = $1; |
$name = $1; |
| 456 |
$column += length $name + 1; |
$column += length $name + 1; |
| 457 |
} |
} |
| 458 |
my $param = $doc->create_element_ns (SW09_NS, 'parameter'); |
my $param = $doc->create_element_ns (SW09_NS, [undef, 'parameter']); |
| 459 |
$param->set_attribute (name => $name); |
$param->set_attribute_ns (undef, [undef, 'name'] => $name); |
| 460 |
$param->set_user_data (manakai_source_line => $line); |
$param->set_user_data (manakai_source_line => $line); |
| 461 |
$param->set_user_data (manakai_source_column => $column); |
$param->set_user_data (manakai_source_column => $column); |
| 462 |
$head->append_child ($param); |
$head_el->append_child ($param); |
| 463 |
|
|
| 464 |
$column++ if $s =~ s/^"//; |
$column++ if $s =~ s/^"//; |
| 465 |
if ($s =~ s/^([^"]+)//) { |
if ($s =~ s/^([^"]+)//) { |
| 467 |
$column += length $values; |
$column += length $values; |
| 468 |
$values =~ tr/\\//d; |
$values =~ tr/\\//d; |
| 469 |
for (split /,/, $values, -1) { |
for (split /,/, $values, -1) { |
| 470 |
my $value = $doc->create_element_ns (SW09_NS, 'value'); |
my $value = $doc->create_element_ns (SW09_NS, [undef, 'value']); |
| 471 |
$value->text_content ($_); |
$value->text_content ($_); |
| 472 |
$value->set_user_data (manakai_source_line => $line); |
$value->set_user_data (manakai_source_line => $line); |
| 473 |
$value->set_user_data (manakai_source_column => $column); |
$value->set_user_data (manakai_source_column => $column); |
| 483 |
|
|
| 484 |
## NOTE: Switched to the "body" mode. |
## NOTE: Switched to the "body" mode. |
| 485 |
|
|
| 486 |
my $oe = [{node => $doc->document_element->last_child, |
my $oe = [{node => $body_el, |
| 487 |
section_depth => 0, |
section_depth => 0, |
| 488 |
quotation_depth => 0, |
quotation_depth => 0, |
| 489 |
list_depth => 0}]; |
list_depth => 0}]; |
| 495 |
}; |
}; |
| 496 |
|
|
| 497 |
my $im = IN_SECTION_IM; |
my $im = IN_SECTION_IM; |
| 498 |
$get_next_token->(); |
$token = $get_next_token->(); |
| 499 |
|
|
| 500 |
A: { |
A: { |
| 501 |
if ($im == IN_PARAGRAPH_IM) { |
if ($im == IN_PARAGRAPH_IM) { |
| 502 |
if ($token->{type} == CHARACTER_TOKEN) { |
if ($token->{type} == CHARACTER_TOKEN) { |
| 503 |
$oe->[-1]->{node}->manakai_append_text ($token->{data}); |
$oe->[-1]->{node}->manakai_append_text ($token->{data}); |
| 504 |
$get_next_token->(); |
$token = $get_next_token->(); |
| 505 |
redo A; |
redo A; |
| 506 |
} elsif ($token->{type} == INLINE_START_TAG_TOKEN) { |
} elsif ($token->{type} == INLINE_START_TAG_TOKEN) { |
| 507 |
if (not defined $token->{tag_name}) { |
if (not defined $token->{tag_name}) { |
| 508 |
my $el = $doc->create_element_ns (SW09_NS, 'anchor'); |
my $el = $doc->create_element_ns (SW09_NS, [undef, 'anchor']); |
| 509 |
$oe->[-1]->{node}->append_child ($el); |
$oe->[-1]->{node}->append_child ($el); |
| 510 |
push @$oe, {%{$oe->[-1]}, node => $el}; |
push @$oe, {%{$oe->[-1]}, node => $el}; |
| 511 |
$el->set_user_data (manakai_source_line => $token->{line}); |
$el->set_user_data (manakai_source_line => $token->{line}); |
| 512 |
$el->set_user_data (manakai_source_column => $token->{column}); |
$el->set_user_data (manakai_source_column => $token->{column}); |
| 513 |
|
|
| 514 |
$get_next_token->(); |
$token = $get_next_token->(); |
| 515 |
redo A; |
redo A; |
| 516 |
} else { |
} else { |
| 517 |
my $type = { |
my $type = { |
| 538 |
VAR => [HTML_NS, 'var'], |
VAR => [HTML_NS, 'var'], |
| 539 |
WEAK => [SW09_NS, 'weak'], |
WEAK => [SW09_NS, 'weak'], |
| 540 |
}->{$token->{tag_name}} || [SW10_NS, $token->{tag_name}]; |
}->{$token->{tag_name}} || [SW10_NS, $token->{tag_name}]; |
| 541 |
my $el = $doc->create_element_ns (SW10_NS, 'td'); |
my $el = $doc->create_element_ns (SW10_NS, [undef, 'td']); |
| 542 |
$oe->[-1]->{node}->append_child ($el); |
$oe->[-1]->{node}->append_child ($el); |
| 543 |
push @$oe, {%{$oe->[-1]}, node => $el}; |
push @$oe, {%{$oe->[-1]}, node => $el}; |
| 544 |
$el->set_user_data (manakai_source_line => $token->{line}); |
$el->set_user_data (manakai_source_line => $token->{line}); |
| 545 |
$el->set_user_data (manakai_source_column => $token->{column}); |
$el->set_user_data (manakai_source_column => $token->{column}); |
| 546 |
|
|
| 547 |
$el->set_attribute (class => $token->{classes}) |
$el->set_attribute_ns (undef, [undef, 'class'] => $token->{classes}) |
| 548 |
if defined $token->{classes}; |
if defined $token->{classes}; |
| 549 |
$el->set_attribute_ns (XML_NS, 'xml:lang' => $token->{language}) |
$el->set_attribute_ns (XML_NS, ['xml', 'lang'] => $token->{language}) |
| 550 |
if defined $token->{language}; |
if defined $token->{language}; |
| 551 |
|
|
| 552 |
$get_next_token->(); |
$token = $get_next_token->(); |
| 553 |
redo A; |
redo A; |
| 554 |
} |
} |
| 555 |
} elsif ($token->{type} == INLINE_MIDDLE_TAG_TOKEN) { |
} elsif ($token->{type} == INLINE_MIDDLE_TAG_TOKEN) { |
| 556 |
my ($ns, $ln, $pop) = @{{ |
my ($ns, $ln, $pop) = @{{ |
| 557 |
rt => [SW10_NS, 'attrvalue', 1], |
rt => [HTML_NS, 'rt', 1], |
| 558 |
title => [SW10_NS, 'attrvalue', 1], |
title => [SW10_NS, 'attrvalue', 1], |
| 559 |
nsuri => [SW10_NS, 'attrvalue', 1], |
nsuri => [SW10_NS, 'attrvalue', 1], |
| 560 |
qn => [SW10_NS, 'nsuri'], |
qn => [SW10_NS, 'nsuri'], |
| 563 |
}->{$oe->[-1]->{node}->manakai_local_name} || [SW10_NS, 'title']}; |
}->{$oe->[-1]->{node}->manakai_local_name} || [SW10_NS, 'title']}; |
| 564 |
pop @$oe if $pop; |
pop @$oe if $pop; |
| 565 |
|
|
| 566 |
my $el = $doc->create_element_ns ($ns, $ln); |
my $el = $doc->create_element_ns ($ns, [undef, $ln]); |
| 567 |
$oe->[-1]->{node}->append_child ($el); |
$oe->[-1]->{node}->append_child ($el); |
| 568 |
push @$oe, {%{$oe->[-1]}, node => $el}; |
push @$oe, {%{$oe->[-1]}, node => $el}; |
| 569 |
$el->set_user_data (manakai_source_line => $token->{line}); |
$el->set_user_data (manakai_source_line => $token->{line}); |
| 570 |
$el->set_user_data (manakai_source_column => $token->{column}); |
$el->set_user_data (manakai_source_column => $token->{column}); |
| 571 |
|
|
| 572 |
$el->set_attribute_ns (XML_NS, 'xml:lang' => $token->{language}) |
$el->set_attribute_ns (XML_NS, ['xml', 'lang'] => $token->{language}) |
| 573 |
if defined $token->{language}; |
if defined $token->{language}; |
| 574 |
|
|
| 575 |
$get_next_token->(); |
$token = $get_next_token->(); |
| 576 |
redo A; |
redo A; |
| 577 |
} elsif ($token->{type} == INLINE_END_TAG_TOKEN) { |
} elsif ($token->{type} == INLINE_END_TAG_TOKEN) { |
| 578 |
pop @$oe if { |
pop @$oe if { |
| 583 |
strong => 1, em => 1}->{$oe->[-1]->{node}->manakai_local_name}) { |
strong => 1, em => 1}->{$oe->[-1]->{node}->manakai_local_name}) { |
| 584 |
my $el = $doc->create_element_ns |
my $el = $doc->create_element_ns |
| 585 |
(SW09_NS, |
(SW09_NS, |
| 586 |
defined $token->{res_scheme} |
[undef, defined $token->{res_scheme} |
| 587 |
? 'anchor-external' : 'anchor-internal'); |
? 'anchor-external' : 'anchor-internal']); |
| 588 |
$oe->[-1]->{node}->append_child ($el); |
$oe->[-1]->{node}->append_child ($el); |
| 589 |
push @$oe, {%{$oe->[-1]}, node => $el}; |
push @$oe, {%{$oe->[-1]}, node => $el}; |
| 590 |
$el->set_user_data (manakai_source_line => $token->{line}); |
$el->set_user_data (manakai_source_line => $token->{line}); |
| 592 |
$el->text_content (']]'); |
$el->text_content (']]'); |
| 593 |
} |
} |
| 594 |
|
|
| 595 |
$oe->[-1]->{node}->set_attribute_ns (SW09_NS, 'sw:anchor', |
$oe->[-1]->{node}->set_attribute_ns (SW09_NS, ['sw', 'anchor'], |
| 596 |
$token->{anchor}) |
$token->{anchor}) |
| 597 |
if defined $token->{anchor}; |
if defined $token->{anchor}; |
| 598 |
$oe->[-1]->{node}->set_attribute_ns (SW09_NS, 'sw:resScheme', |
$oe->[-1]->{node}->set_attribute_ns (SW09_NS, ['sw', 'resScheme'], |
| 599 |
$token->{res_scheme}) |
$token->{res_scheme}) |
| 600 |
if defined $token->{res_scheme}; |
if defined $token->{res_scheme}; |
| 601 |
$oe->[-1]->{node}->set_attribute_ns (SW09_NS, 'sw:resParameter', |
$oe->[-1]->{node}->set_attribute_ns (SW09_NS, ['sw', 'resParameter'], |
| 602 |
$token->{res_parameter}) |
$token->{res_parameter}) |
| 603 |
if defined $token->{res_parameter}; |
if defined $token->{res_parameter}; |
| 604 |
|
|
| 605 |
pop @$oe; |
pop @$oe; |
| 606 |
|
|
| 607 |
$get_next_token->(); |
$token = $get_next_token->(); |
| 608 |
redo A; |
redo A; |
| 609 |
} elsif ($token->{type} == STRONG_TOKEN) { |
} elsif ($token->{type} == STRONG_TOKEN) { |
| 610 |
my $el = $doc->create_element_ns (HTML_NS, 'strong'); |
my $el = $doc->create_element_ns (HTML_NS, [undef, 'strong']); |
| 611 |
$oe->[-1]->{node}->append_child ($el); |
$oe->[-1]->{node}->append_child ($el); |
| 612 |
push @$oe, {%{$oe->[-1]}, node => $el}; |
push @$oe, {%{$oe->[-1]}, node => $el}; |
| 613 |
$el->set_user_data (manakai_source_line => $token->{line}); |
$el->set_user_data (manakai_source_line => $token->{line}); |
| 614 |
$el->set_user_data (manakai_source_column => $token->{column}); |
$el->set_user_data (manakai_source_column => $token->{column}); |
| 615 |
|
|
| 616 |
$get_next_token->(); |
$token = $get_next_token->(); |
| 617 |
redo A; |
redo A; |
| 618 |
} elsif ($token->{type} == EMPHASIS_TOKEN) { |
} elsif ($token->{type} == EMPHASIS_TOKEN) { |
| 619 |
my $el = $doc->create_element_ns (HTML_NS, 'em'); |
my $el = $doc->create_element_ns (HTML_NS, [undef, 'em']); |
| 620 |
$oe->[-1]->{node}->append_child ($el); |
$oe->[-1]->{node}->append_child ($el); |
| 621 |
push @$oe, {%{$oe->[-1]}, node => $el}; |
push @$oe, {%{$oe->[-1]}, node => $el}; |
| 622 |
$el->set_user_data (manakai_source_line => $token->{line}); |
$el->set_user_data (manakai_source_line => $token->{line}); |
| 623 |
$el->set_user_data (manakai_source_column => $token->{column}); |
$el->set_user_data (manakai_source_column => $token->{column}); |
| 624 |
|
|
| 625 |
$get_next_token->(); |
$token = $get_next_token->(); |
| 626 |
redo A; |
redo A; |
| 627 |
} elsif ($token->{type} == FORM_TOKEN) { |
} elsif ($token->{type} == FORM_TOKEN) { |
| 628 |
## There is an exact code clone. |
## There is an exact code clone. |
| 629 |
if ($token->{name} eq 'form') { |
if ($token->{name} eq 'form') { |
| 630 |
my $el = $doc->create_element_ns (SW09_NS, 'form'); |
my $el = $doc->create_element_ns (SW09_NS, [undef, 'form']); |
| 631 |
$oe->[-1]->{node}->append_child ($el); |
$oe->[-1]->{node}->append_child ($el); |
| 632 |
push @$oe, {%{$oe->[-1]}, node => $el}; |
push @$oe, {%{$oe->[-1]}, node => $el}; |
| 633 |
$el->set_user_data (manakai_source_line => $token->{line}); |
$el->set_user_data (manakai_source_line => $token->{line}); |
| 634 |
$el->set_user_data (manakai_source_column => $token->{column}); |
$el->set_user_data (manakai_source_column => $token->{column}); |
| 635 |
|
|
| 636 |
$el->set_attribute (id => $token->{id}) if defined $token->{id}; |
$el->set_attribute_ns (undef, [undef, 'id'] |
| 637 |
$el->set_attribute (input => shift @{$token->{parameters}}) |
=> $token->{id}) if defined $token->{id}; |
| 638 |
|
$el->set_attribute_ns (undef, [undef, 'input'] |
| 639 |
|
=> shift @{$token->{parameters}}) |
| 640 |
if @{$token->{parameter}}; |
if @{$token->{parameter}}; |
| 641 |
$el->set_attribute (template => shift @{$token->{parameters}}) |
$el->set_attribute_ns (undef, [undef, 'template'] |
| 642 |
|
=> shift @{$token->{parameters}}) |
| 643 |
if @{$token->{parameter}}; |
if @{$token->{parameter}}; |
| 644 |
$el->set_attribute (option => shift @{$token->{parameters}}) |
$el->set_attribute_ns (undef, [undef, 'option'] |
| 645 |
|
=> shift @{$token->{parameters}}) |
| 646 |
if @{$token->{parameter}}; |
if @{$token->{parameter}}; |
| 647 |
$el->set_attribute (parameter => join ':', @{$token->{parameters}}) |
$el->set_attribute_ns (undef, [undef, 'parameter'] |
| 648 |
|
=> join ':', @{$token->{parameters}}) |
| 649 |
if @{$token->{parameter}}; |
if @{$token->{parameter}}; |
| 650 |
|
|
| 651 |
$get_next_token->(); |
$token = $get_next_token->(); |
| 652 |
redo A; |
redo A; |
| 653 |
} else { |
} else { |
| 654 |
my $el = $doc->create_element_ns (SW09_NS, 'form'); |
my $el = $doc->create_element_ns (SW09_NS, [undef, 'form']); |
| 655 |
$oe->[-1]->{node}->append_child ($el); |
$oe->[-1]->{node}->append_child ($el); |
| 656 |
push @$oe, {%{$oe->[-1]}, node => $el}; |
push @$oe, {%{$oe->[-1]}, node => $el}; |
| 657 |
$el->set_user_data (manakai_source_line => $token->{line}); |
$el->set_user_data (manakai_source_line => $token->{line}); |
| 658 |
$el->set_user_data (manakai_source_column => $token->{column}); |
$el->set_user_data (manakai_source_column => $token->{column}); |
| 659 |
|
|
| 660 |
$el->set_attribute (ref => $token->{name}); |
$el->set_attribute_ns (undef, [undef, 'ref'] |
| 661 |
$el->set_attribute (id => $token->{id}) if defined $token->{id}; |
=> $token->{name}); |
| 662 |
$el->set_attribute (parameter => join ':', @{$token->{parameters}}) |
$el->set_attribute_ns (undef, [undef, 'id'] |
| 663 |
|
=> $token->{id}) if defined $token->{id}; |
| 664 |
|
$el->set_attribute_ns (undef, [undef, 'parameter'] |
| 665 |
|
=> join ':', @{$token->{parameters}}) |
| 666 |
if @{$token->{parameter}}; |
if @{$token->{parameter}}; |
| 667 |
|
|
| 668 |
$get_next_token->(); |
$token = $get_next_token->(); |
| 669 |
redo A; |
redo A; |
| 670 |
} |
} |
| 671 |
} elsif ($token->{type} == ELEMENT_TOKEN) { |
} elsif ($token->{type} == ELEMENT_TOKEN) { |
| 672 |
## NOTE: There is an exact code clone. |
## NOTE: There is an exact code clone. |
| 673 |
my $el = $doc->create_element_ns |
my $el = $doc->create_element_ns |
| 674 |
($token->{namespace}, $token->{local_name}); |
($token->{namespace}, [undef, $token->{local_name}]); |
| 675 |
$oe->[-1]->{node}->append_child ($el); |
$oe->[-1]->{node}->append_child ($el); |
| 676 |
push @$oe, {%{$oe->[-1]}, node => $el}; |
push @$oe, {%{$oe->[-1]}, node => $el}; |
| 677 |
$el->set_user_data (manakai_source_line => $token->{line}); |
$el->set_user_data (manakai_source_line => $token->{line}); |
| 678 |
$el->set_user_data (manakai_source_column => $token->{column}); |
$el->set_user_data (manakai_source_column => $token->{column}); |
| 679 |
|
|
| 680 |
$el->set_attribute_ns (SW09_NS, 'sw:anchor', $token->{anchor}) |
$el->set_attribute_ns (SW09_NS, ['sw', 'anchor'], $token->{anchor}) |
| 681 |
if defined $token->{anchor}; |
if defined $token->{anchor}; |
| 682 |
$el->set_attribute (by => $token->{by}) if defined $token->{by}; |
$el->set_attribute_ns (undef, [undef, 'by'] |
| 683 |
$el->set_attribute_ns (SW09_NS, 'sw:resScheme', $token->{res_scheme}) |
=> $token->{by}) if defined $token->{by}; |
| 684 |
|
$el->set_attribute_ns (SW09_NS, ['sw', 'resScheme'], |
| 685 |
|
$token->{res_scheme}) |
| 686 |
if defined $token->{res_scheme}; |
if defined $token->{res_scheme}; |
| 687 |
$el->set_attribute_ns (SW09_NS, 'sw:resParameter', |
$el->set_attribute_ns (SW09_NS, ['sw', 'resParameter'], |
| 688 |
$token->{res_parameter}) |
$token->{res_parameter}) |
| 689 |
if defined $token->{res_parameter}; |
if defined $token->{res_parameter}; |
| 690 |
$el->text_content ($token->{content}) if defined $token->{content}; |
$el->text_content ($token->{content}) if defined $token->{content}; |
| 691 |
|
|
| 692 |
$get_next_token->(); |
$token = $get_next_token->(); |
| 693 |
redo A; |
redo A; |
| 694 |
} elsif ($token->{type} == LABELED_LIST_MIDDLE_TOKEN) { |
} elsif ($token->{type} == LABELED_LIST_MIDDLE_TOKEN) { |
| 695 |
pop @$oe while not $structural_elements |
pop @$oe while not $structural_elements |
| 696 |
->{$oe->[-1]->{node}->manakai_local_name}; |
->{$oe->[-1]->{node}->manakai_local_name}; |
| 697 |
pop @$oe if $oe->[-1]->{node}->manakai_local_name eq 'dt'; |
pop @$oe if $oe->[-1]->{node}->manakai_local_name eq 'dt'; |
| 698 |
|
|
| 699 |
my $el = $doc->create_element_ns (HTML_NS, 'dt'); |
my $el = $doc->create_element_ns (HTML_NS, [undef, 'dt']); |
| 700 |
$oe->[-1]->{node}->append_child ($el); |
$oe->[-1]->{node}->append_child ($el); |
| 701 |
push @$oe, {%{$oe->[-1]}, node => $el}; |
push @$oe, {%{$oe->[-1]}, node => $el}; |
| 702 |
$el->set_user_data (manakai_source_line => $token->{line}); |
$el->set_user_data (manakai_source_line => $token->{line}); |
| 703 |
$el->set_user_data (manakai_source_column => $token->{column}); |
$el->set_user_data (manakai_source_column => $token->{column}); |
| 704 |
|
|
| 705 |
$get_next_token->(); |
$token = $get_next_token->(); |
| 706 |
redo A; |
redo A; |
| 707 |
} elsif ($token->{type} == HEADING_END_TOKEN) { |
} elsif ($token->{type} == HEADING_END_TOKEN) { |
| 708 |
pop @$oe while not $structural_elements |
pop @$oe while not $structural_elements |
| 710 |
pop @$oe if $oe->[-1]->{node}->manakai_local_name eq 'h1'; |
pop @$oe if $oe->[-1]->{node}->manakai_local_name eq 'h1'; |
| 711 |
|
|
| 712 |
$im = IN_SECTION_IM; |
$im = IN_SECTION_IM; |
| 713 |
$get_next_token->(); |
$token = $get_next_token->(); |
| 714 |
redo A; |
redo A; |
| 715 |
} elsif ($token->{type} == TABLE_CELL_END_TOKEN) { |
} elsif ($token->{type} == TABLE_CELL_END_TOKEN) { |
| 716 |
pop @$oe while not $structural_elements |
pop @$oe while not $structural_elements |
| 718 |
pop @$oe if $oe->[-1]->{node}->manakai_local_name eq 'td'; |
pop @$oe if $oe->[-1]->{node}->manakai_local_name eq 'td'; |
| 719 |
|
|
| 720 |
$im = IN_TABLE_ROW_IM; |
$im = IN_TABLE_ROW_IM; |
| 721 |
$get_next_token->(); |
$token = $get_next_token->(); |
| 722 |
redo A; |
redo A; |
| 723 |
} elsif (($token->{type} == BLOCK_END_TAG_TOKEN and |
} elsif (($token->{type} == BLOCK_END_TAG_TOKEN and |
| 724 |
$token->{tag_name} eq 'PRE') or |
$token->{tag_name} eq 'PRE') or |
| 728 |
pop @$oe if $oe->[-1]->{node}->manakai_local_name eq 'pre'; |
pop @$oe if $oe->[-1]->{node}->manakai_local_name eq 'pre'; |
| 729 |
|
|
| 730 |
$im = IN_SECTION_IM; |
$im = IN_SECTION_IM; |
| 731 |
$get_next_token->(); |
$token = $get_next_token->(); |
| 732 |
redo A; |
redo A; |
| 733 |
} else { |
} else { |
| 734 |
pop @$oe while not $structural_elements |
pop @$oe while not $structural_elements |
| 735 |
->{$oe->[-1]->{node}->manakai_local_name}; |
->{$oe->[-1]->{node}->manakai_local_name}; |
| 736 |
|
|
| 737 |
$im = IN_SECTION_IM; |
$im = IN_SECTION_IM; |
| 738 |
$get_next_token->(); |
## Reconsume. |
| 739 |
redo A; |
redo A; |
| 740 |
} |
} |
| 741 |
} elsif ($im == IN_SECTION_IM) { |
} elsif ($im == IN_SECTION_IM) { |
| 742 |
if ($token->{type} == HEADING_START_TOKEN) { |
if ($token->{type} == HEADING_START_TOKEN) { |
| 743 |
B: { |
B: { |
| 744 |
pop @$oe and redo B |
pop @$oe and redo B |
| 745 |
if {body => 1, section => 1, insert => 1, delete => 1} |
if not {body => 1, section => 1, insert => 1, delete => 1} |
| 746 |
->{$oe->[-1]->{node}->manakai_local_name} or |
->{$oe->[-1]->{node}->manakai_local_name} or |
| 747 |
$token->{depth} <= $oe->[-1]->{section_depth}; |
$token->{depth} <= $oe->[-1]->{section_depth}; |
| 748 |
if ($token->{depth} > $oe->[-1]->{section_depth} + 1) { |
if ($token->{depth} > $oe->[-1]->{section_depth} + 1) { |
| 749 |
my $el = $doc->create_element_ns (HTML_NS, 'section'); |
my $el = $doc->create_element_ns (HTML_NS, [undef, 'section']); |
| 750 |
$oe->[-1]->{node}->append_child ($el); |
$oe->[-1]->{node}->append_child ($el); |
| 751 |
push @$oe, {node => $el, |
push @$oe, {node => $el, |
| 752 |
section_depth => $oe->[-1]->{section_depth} + 1, |
section_depth => $oe->[-1]->{section_depth} + 1, |
| 755 |
} |
} |
| 756 |
} # B |
} # B |
| 757 |
|
|
| 758 |
my $el = $doc->create_element_ns (HTML_NS, 'section'); |
my $el = $doc->create_element_ns (HTML_NS, [undef, 'section']); |
| 759 |
$oe->[-1]->{node}->append_child ($el); |
$oe->[-1]->{node}->append_child ($el); |
| 760 |
push @$oe, {node => $el, |
push @$oe, {node => $el, |
| 761 |
section_depth => $oe->[-1]->{section_depth} + 1, |
section_depth => $oe->[-1]->{section_depth} + 1, |
| 762 |
quotation_depth => 0, list_depth => 0}; |
quotation_depth => 0, list_depth => 0}; |
| 763 |
|
|
| 764 |
my $el2 = $doc->create_element_ns (HTML_NS, 'h1'); |
my $el2 = $doc->create_element_ns (HTML_NS, [undef, 'h1']); |
| 765 |
$oe->[-1]->{node}->append_child ($el2); |
$oe->[-1]->{node}->append_child ($el2); |
| 766 |
push @$oe, {%{$oe->[-1]}, node => $el2}; |
push @$oe, {%{$oe->[-1]}, node => $el2}; |
| 767 |
|
|
| 768 |
$im = IN_PARAGRAPH_IM; |
$im = IN_PARAGRAPH_IM; |
| 769 |
$get_next_token->(); |
$token = $get_next_token->(); |
| 770 |
redo A; |
redo A; |
| 771 |
} elsif ($token->{type} == BLOCK_START_TAG_TOKEN and |
} elsif ($token->{type} == BLOCK_START_TAG_TOKEN and |
| 772 |
($token->{tag_name} eq 'INS' or |
($token->{tag_name} eq 'INS' or |
| 773 |
$token->{tag_name} eq 'DEL')) { |
$token->{tag_name} eq 'DEL')) { |
| 774 |
my $el = $doc->create_element_ns |
my $el = $doc->create_element_ns |
| 775 |
(SW09_NS, ($token->{tag_name} eq 'INS' ? 'insert' : 'delete')); |
(SW09_NS, |
| 776 |
|
[undef, $token->{tag_name} eq 'INS' ? 'insert' : 'delete']); |
| 777 |
$oe->[-1]->{node}->append_child ($el); |
$oe->[-1]->{node}->append_child ($el); |
| 778 |
push @$oe, {node => $el, section_depth => 0, |
push @$oe, {node => $el, section_depth => 0, |
| 779 |
quotation_depth => 0, list_depth => 0}; |
quotation_depth => 0, list_depth => 0}; |
| 780 |
$el->set_attribute (class => $token->{classes}) |
$el->set_attribute_ns (undef, [undef, 'class'] => $token->{classes}) |
| 781 |
if defined $token->{classes}; |
if defined $token->{classes}; |
| 782 |
$get_next_token->(); |
$token = $get_next_token->(); |
| 783 |
redo A; |
redo A; |
| 784 |
} elsif ($token->{type} == QUOTATION_START_TOKEN) { |
} elsif ($token->{type} == QUOTATION_START_TOKEN) { |
| 785 |
B: { |
B: { |
| 786 |
pop @$oe and redo B |
pop @$oe and redo B |
| 787 |
if {body => 1, section => 1, insert => 1, delete => 1, |
if not {body => 1, section => 1, insert => 1, delete => 1, |
| 788 |
blockquote => 1} |
blockquote => 1} |
| 789 |
->{$oe->[-1]->{node}->manakai_local_name} or |
->{$oe->[-1]->{node}->manakai_local_name} or |
| 790 |
$token->{depth} <= $oe->[-1]->{quotation_depth}; |
$token->{depth} <= $oe->[-1]->{quotation_depth}; |
| 791 |
if ($token->{depth} > $oe->[-1]->{quotation_depth} + 1) { |
if ($token->{depth} > $oe->[-1]->{quotation_depth} + 1) { |
| 792 |
my $el = $doc->create_element_ns (HTML_NS, 'blockquote'); |
my $el = $doc->create_element_ns (HTML_NS, [undef, 'blockquote']); |
| 793 |
$oe->[-1]->{node}->append_child ($el); |
$oe->[-1]->{node}->append_child ($el); |
| 794 |
push @$oe, {node => $el, section_depth => 0, |
push @$oe, {node => $el, section_depth => 0, |
| 795 |
quotation_depth => $oe->[-1]->{quotation_depth} + 1, |
quotation_depth => $oe->[-1]->{quotation_depth} + 1, |
| 798 |
} |
} |
| 799 |
} # B |
} # B |
| 800 |
|
|
| 801 |
my $el = $doc->create_element_ns (HTML_NS, 'blockquote'); |
my $el = $doc->create_element_ns (HTML_NS, [undef, 'blockquote']); |
| 802 |
$oe->[-1]->{node}->append_child ($el); |
$oe->[-1]->{node}->append_child ($el); |
| 803 |
push @$oe, {node => $el, section_depth => 0, |
push @$oe, {node => $el, section_depth => 0, |
| 804 |
quotation_depth => $oe->[-1]->{quotation_depth} + 1, |
quotation_depth => $oe->[-1]->{quotation_depth} + 1, |
| 805 |
list_depth => 0}; |
list_depth => 0}; |
| 806 |
|
|
| 807 |
$get_next_token->(); |
$token = $get_next_token->(); |
| 808 |
redo A; |
redo A; |
| 809 |
} elsif ($token->{type} == LIST_START_TOKEN) { |
} elsif ($token->{type} == LIST_START_TOKEN) { |
| 810 |
my $depth = length $token->{depth}; |
my $depth = length $token->{depth}; |
| 811 |
|
my $list_type = substr ($token->{depth}, -1, 1) eq '-' ? 'ul' : 'ol'; |
| 812 |
B: { |
B: { |
| 813 |
pop @$oe and redo B if $oe->[-1]->{list_depth} > $depth; |
pop @$oe and redo B if $oe->[-1]->{list_depth} > $depth; |
| 814 |
|
pop @$oe and redo B if $oe->[-1]->{list_depth} == $depth and |
| 815 |
|
$list_type ne $oe->[-1]->{node}->manakai_local_name; |
| 816 |
if ($oe->[-1]->{list_depth} < $depth) { |
if ($oe->[-1]->{list_depth} < $depth) { |
| 817 |
my $type = substr $token->{depth}, $oe->[-1]->{list_depth}; |
my $type = substr $token->{depth}, $oe->[-1]->{list_depth}, 1; |
| 818 |
my $el = $doc->create_element_ns |
my $el = $doc->create_element_ns |
| 819 |
(HTML_NS, $type eq '-' ? 'ul' : 'ol'); |
(HTML_NS, [undef, $type eq '-' ? 'ul' : 'ol']); |
| 820 |
$oe->[-1]->{node}->append_child ($el); |
$oe->[-1]->{node}->append_child ($el); |
| 821 |
push @$oe, {%{$oe->[-1]}, node => $el, |
push @$oe, {%{$oe->[-1]}, node => $el, |
| 822 |
list_depth => $oe->[-1]->{list_depth} + 1}; |
list_depth => $oe->[-1]->{list_depth} + 1}; |
| 823 |
if ($oe->[-1]->{list_depth} < $depth) { |
if ($oe->[-1]->{list_depth} < $depth) { |
| 824 |
my $el = $doc->create_element_ns (HTML_NS, 'li'); |
my $el = $doc->create_element_ns (HTML_NS, [undef, 'li']); |
| 825 |
$oe->[-1]->{node}->append_child ($el); |
$oe->[-1]->{node}->append_child ($el); |
| 826 |
push @$oe, {%{$oe->[-1]}, node => $el}; |
push @$oe, {%{$oe->[-1]}, node => $el}; |
| 827 |
} |
} |
| 828 |
redo B; |
redo B; |
| 829 |
} |
} |
| 830 |
} # B |
} # B |
|
|
|
|
pop @$oe if $oe->[-1]->{list_depth} == $depth and |
|
|
not {ul => 1, ol => 1}->{$oe->[-1]->{node}->manakai_local_name}; |
|
| 831 |
|
|
| 832 |
my $el = $doc->create_element_ns (HTML_NS, 'li'); |
my $el = $doc->create_element_ns (HTML_NS, [undef, 'li']); |
| 833 |
$oe->[-1]->{node}->append_child ($el); |
$oe->[-1]->{node}->append_child ($el); |
| 834 |
push @$oe, {%{$oe->[-1]}, node => $el}; |
push @$oe, {%{$oe->[-1]}, node => $el}; |
| 835 |
|
|
| 836 |
$im = IN_PARAGRAPH_IM; |
$im = IN_PARAGRAPH_IM; |
| 837 |
$get_next_token->(); |
$token = $get_next_token->(); |
| 838 |
redo A; |
redo A; |
| 839 |
} elsif ($token->{type} == LABELED_LIST_START_TOKEN) { |
} elsif ($token->{type} == LABELED_LIST_START_TOKEN) { |
| 840 |
pop @$oe if $oe->[-1]->{node}->manakai_local_name eq 'dd'; |
pop @$oe if $oe->[-1]->{node}->manakai_local_name eq 'dd'; |
| 841 |
if ($oe->[-1]->{node}->manakai_local_name ne 'dl') { |
if ($oe->[-1]->{node}->manakai_local_name ne 'dl') { |
| 842 |
my $el = $doc->create_element_ns (HTML_NS, 'dl'); |
my $el = $doc->create_element_ns (HTML_NS, [undef, 'dl']); |
| 843 |
$oe->[-1]->{node}->append_child ($el); |
$oe->[-1]->{node}->append_child ($el); |
| 844 |
push @$oe, {%{$oe->[-1]}, node => $el}; |
push @$oe, {%{$oe->[-1]}, node => $el}; |
| 845 |
} |
} |
| 846 |
|
|
| 847 |
my $el = $doc->create_element_ns (HTML_NS, 'dt'); |
my $el = $doc->create_element_ns (HTML_NS, [undef, 'dt']); |
| 848 |
$oe->[-1]->{node}->append_child ($el); |
$oe->[-1]->{node}->append_child ($el); |
| 849 |
push @$oe, {%{$oe->[-1]}, node => $el}; |
push @$oe, {%{$oe->[-1]}, node => $el}; |
| 850 |
|
|
| 851 |
$im = IN_PARAGRAPH_IM; |
$im = IN_PARAGRAPH_IM; |
| 852 |
$get_next_token->(); |
$token = $get_next_token->(); |
| 853 |
redo A; |
redo A; |
| 854 |
} elsif ($token->{type} == TABLE_ROW_START_TOKEN) { |
} elsif ($token->{type} == TABLE_ROW_START_TOKEN) { |
| 855 |
my $el = $doc->create_element_ns (HTML_NS, 'table'); |
my $el = $doc->create_element_ns (HTML_NS, [undef, 'table']); |
| 856 |
$oe->[-1]->{node}->append_child ($el); |
$oe->[-1]->{node}->append_child ($el); |
| 857 |
push @$oe, {%{$oe->[-1]}, node => $el}; |
push @$oe, {%{$oe->[-1]}, node => $el}; |
| 858 |
|
|
| 859 |
$el = $doc->create_element_ns (HTML_NS, 'tbody'); |
$el = $doc->create_element_ns (HTML_NS, [undef, 'tbody']); |
| 860 |
$oe->[-1]->{node}->append_child ($el); |
$oe->[-1]->{node}->append_child ($el); |
| 861 |
push @$oe, {%{$oe->[-1]}, node => $el}; |
push @$oe, {%{$oe->[-1]}, node => $el}; |
| 862 |
|
|
| 863 |
$el = $doc->create_element_ns (HTML_NS, 'tr'); |
$el = $doc->create_element_ns (HTML_NS, [undef, 'tr']); |
| 864 |
$oe->[-1]->{node}->append_child ($el); |
$oe->[-1]->{node}->append_child ($el); |
| 865 |
push @$oe, {%{$oe->[-1]}, node => $el}; |
push @$oe, {%{$oe->[-1]}, node => $el}; |
| 866 |
|
|
| 867 |
$im = IN_TABLE_ROW_IM; |
$im = IN_TABLE_ROW_IM; |
| 868 |
$get_next_token->(); |
$token = $get_next_token->(); |
| 869 |
redo A; |
redo A; |
| 870 |
} elsif (($token->{type} == BLOCK_START_TAG_TOKEN and |
} elsif (($token->{type} == BLOCK_START_TAG_TOKEN and |
| 871 |
$token->{tag_name} eq 'PRE') or |
$token->{tag_name} eq 'PRE') or |
| 872 |
$token->{type} == PREFORMATTED_START_TOKEN) { |
$token->{type} == PREFORMATTED_START_TOKEN) { |
| 873 |
my $el = $doc->create_element_ns (HTML_NS, 'pre'); |
my $el = $doc->create_element_ns (HTML_NS, [undef, 'pre']); |
| 874 |
$oe->[-1]->{node}->append_child ($el); |
$oe->[-1]->{node}->append_child ($el); |
| 875 |
push @$oe, {%{$oe->[-1]}, node => $el}; |
push @$oe, {%{$oe->[-1]}, node => $el}; |
| 876 |
|
|
| 877 |
$el->set_attribute (class => $token->{classes}) |
$el->set_attribute_ns (undef, [undef, 'class'] => $token->{classes}) |
| 878 |
if defined $token->{classes}; |
if defined $token->{classes}; |
| 879 |
|
|
| 880 |
$im = IN_PARAGRAPH_IM; |
$im = IN_PARAGRAPH_IM; |
| 881 |
$get_next_token->(); |
$token = $get_next_token->(); |
| 882 |
redo A; |
redo A; |
| 883 |
} elsif ($token->{type} == COMMENT_PARAGRAPH_START_TOKEN) { |
} elsif ($token->{type} == COMMENT_PARAGRAPH_START_TOKEN) { |
| 884 |
my $el = $doc->create_element_ns (SW10_NS, 'comment-p'); |
my $el = $doc->create_element_ns (SW10_NS, [undef, 'comment-p']); |
| 885 |
$oe->[-1]->{node}->append_child ($el); |
$oe->[-1]->{node}->append_child ($el); |
| 886 |
push @$oe, {%{$oe->[-1]}, node => $el}; |
push @$oe, {%{$oe->[-1]}, node => $el}; |
| 887 |
|
|
| 888 |
$im = IN_PARAGRAPH_IM; |
$im = IN_PARAGRAPH_IM; |
| 889 |
$get_next_token->(); |
$token = $get_next_token->(); |
| 890 |
redo A; |
redo A; |
| 891 |
} elsif ($token->{type} == EDITORIAL_NOTE_START_TOKEN) { |
} elsif ($token->{type} == EDITORIAL_NOTE_START_TOKEN) { |
| 892 |
my $el = $doc->create_element_ns (SW10_NS, 'ed'); |
my $el = $doc->create_element_ns (SW10_NS, [undef, 'ed']); |
| 893 |
$oe->[-1]->{node}->append_child ($el); |
$oe->[-1]->{node}->append_child ($el); |
| 894 |
push @$oe, {%{$oe->[-1]}, node => $el}; |
push @$oe, {%{$oe->[-1]}, node => $el}; |
| 895 |
|
|
| 896 |
$im = IN_PARAGRAPH_IM; |
$im = IN_PARAGRAPH_IM; |
| 897 |
$get_next_token->(); |
$token = $get_next_token->(); |
| 898 |
redo A; |
redo A; |
| 899 |
} elsif ($token->{type} == EMPTY_LINE_TOKEN) { |
} elsif ($token->{type} == EMPTY_LINE_TOKEN) { |
| 900 |
pop @$oe while {body => 1, section => 1, insert => 1, delete => 1} |
pop @$oe while not {body => 1, section => 1, insert => 1, delete => 1} |
| 901 |
->{$oe->[-1]->{node}->manakai_local_name}; |
->{$oe->[-1]->{node}->manakai_local_name}; |
| 902 |
$get_next_token->(); |
$token = $get_next_token->(); |
| 903 |
redo A; |
redo A; |
| 904 |
} elsif ($token->{type} == BLOCK_END_TAG_TOKEN) { |
} elsif ($token->{type} == BLOCK_END_TAG_TOKEN) { |
| 905 |
if ($token->{type} eq 'INS') { |
if ($token->{tag_name} eq 'INS') { |
| 906 |
for (reverse 1..$#$oe) { |
for (reverse 1..$#$oe) { |
| 907 |
if ($oe->[$_]->{node}->manakai_local_name eq 'insert') { |
if ($oe->[$_]->{node}->manakai_local_name eq 'insert') { |
| 908 |
splice @$oe, $_; |
splice @$oe, $_; |
| 909 |
last; |
last; |
| 910 |
} |
} |
| 911 |
} |
} |
| 912 |
} elsif ($token->{type} eq 'DEL') { |
} elsif ($token->{tag_name} eq 'DEL') { |
| 913 |
for (reverse 1..$#$oe) { |
for (reverse 1..$#$oe) { |
| 914 |
if ($oe->[$_]->{node}->manakai_local_name eq 'delete') { |
if ($oe->[$_]->{node}->manakai_local_name eq 'delete') { |
| 915 |
splice @$oe, $_; |
splice @$oe, $_; |
| 919 |
} else { |
} else { |
| 920 |
## NOTE: Ignore the token. |
## NOTE: Ignore the token. |
| 921 |
} |
} |
| 922 |
|
$token = $get_next_token->(); |
| 923 |
|
redo A; |
| 924 |
} elsif ($token->{type} == FORM_TOKEN) { |
} elsif ($token->{type} == FORM_TOKEN) { |
| 925 |
## There is an exact code clone. |
## There is an exact code clone. |
| 926 |
if ($token->{name} eq 'form') { |
if ($token->{name} eq 'form') { |
| 927 |
my $el = $doc->create_element_ns (SW09_NS, 'form'); |
my $el = $doc->create_element_ns (SW09_NS, [undef, 'form']); |
| 928 |
$oe->[-1]->{node}->append_child ($el); |
$oe->[-1]->{node}->append_child ($el); |
| 929 |
push @$oe, {%{$oe->[-1]}, node => $el}; |
push @$oe, {%{$oe->[-1]}, node => $el}; |
| 930 |
$el->set_user_data (manakai_source_line => $token->{line}); |
$el->set_user_data (manakai_source_line => $token->{line}); |
| 931 |
$el->set_user_data (manakai_source_column => $token->{column}); |
$el->set_user_data (manakai_source_column => $token->{column}); |
| 932 |
|
|
| 933 |
$el->set_attribute (id => $token->{id}) if defined $token->{id}; |
$el->set_attribute_ns (undef, [undef, 'id'] |
| 934 |
$el->set_attribute (input => shift @{$token->{parameters}}) |
=> $token->{id}) if defined $token->{id}; |
| 935 |
|
$el->set_attribute_ns (undef, [undef, 'input'] |
| 936 |
|
=> shift @{$token->{parameters}}) |
| 937 |
if @{$token->{parameter}}; |
if @{$token->{parameter}}; |
| 938 |
$el->set_attribute (template => shift @{$token->{parameters}}) |
$el->set_attribute_ns (undef, [undef, 'template'] |
| 939 |
|
=> shift @{$token->{parameters}}) |
| 940 |
if @{$token->{parameter}}; |
if @{$token->{parameter}}; |
| 941 |
$el->set_attribute (option => shift @{$token->{parameters}}) |
$el->set_attribute_ns (undef, [undef, 'option'] |
| 942 |
|
=> shift @{$token->{parameters}}) |
| 943 |
if @{$token->{parameter}}; |
if @{$token->{parameter}}; |
| 944 |
$el->set_attribute (parameter => join ':', @{$token->{parameters}}) |
$el->set_attribute_ns (undef, [undef, 'parameter'] |
| 945 |
|
=> join ':', @{$token->{parameters}}) |
| 946 |
if @{$token->{parameter}}; |
if @{$token->{parameter}}; |
| 947 |
|
|
| 948 |
$get_next_token->(); |
$token = $get_next_token->(); |
| 949 |
redo A; |
redo A; |
| 950 |
} else { |
} else { |
| 951 |
my $el = $doc->create_element_ns (SW09_NS, 'form'); |
my $el = $doc->create_element_ns (SW09_NS, [undef, 'form']); |
| 952 |
$oe->[-1]->{node}->append_child ($el); |
$oe->[-1]->{node}->append_child ($el); |
| 953 |
push @$oe, {%{$oe->[-1]}, node => $el}; |
push @$oe, {%{$oe->[-1]}, node => $el}; |
| 954 |
$el->set_user_data (manakai_source_line => $token->{line}); |
$el->set_user_data (manakai_source_line => $token->{line}); |
| 955 |
$el->set_user_data (manakai_source_column => $token->{column}); |
$el->set_user_data (manakai_source_column => $token->{column}); |
| 956 |
|
|
| 957 |
$el->set_attribute (ref => $token->{name}); |
$el->set_attribute_ns (undef, [undef, 'ref'] => $token->{name}); |
| 958 |
$el->set_attribute (id => $token->{id}) if defined $token->{id}; |
$el->set_attribute_ns (undef, [undef, 'id'] |
| 959 |
$el->set_attribute (parameter => join ':', @{$token->{parameters}}) |
=> $token->{id}) if defined $token->{id}; |
| 960 |
|
$el->set_attribute_ns (undef, [undef, 'parameter'] |
| 961 |
|
=> join ':', @{$token->{parameters}}) |
| 962 |
if @{$token->{parameter}}; |
if @{$token->{parameter}}; |
| 963 |
|
|
| 964 |
$get_next_token->(); |
$token = $get_next_token->(); |
| 965 |
redo A; |
redo A; |
| 966 |
} |
} |
| 967 |
} elsif ($token->{type} == ELEMENT_TOKEN and |
} elsif ($token->{type} == ELEMENT_TOKEN and |
| 968 |
$token->{local_name} eq 'replace') { |
$token->{local_name} eq 'replace') { |
| 969 |
## NOTE: There is an exact code clone. |
## NOTE: There is an exact code clone. |
| 970 |
my $el = $doc->create_element_ns |
my $el = $doc->create_element_ns |
| 971 |
($token->{namespace}, $token->{local_name}); |
($token->{namespace}, [undef, $token->{local_name}]); |
| 972 |
$oe->[-1]->{node}->append_child ($el); |
$oe->[-1]->{node}->append_child ($el); |
| 973 |
push @$oe, {%{$oe->[-1]}, node => $el}; |
push @$oe, {%{$oe->[-1]}, node => $el}; |
| 974 |
$el->set_user_data (manakai_source_line => $token->{line}); |
$el->set_user_data (manakai_source_line => $token->{line}); |
| 975 |
$el->set_user_data (manakai_source_column => $token->{column}); |
$el->set_user_data (manakai_source_column => $token->{column}); |
| 976 |
|
|
| 977 |
$el->set_attribute_ns (SW09_NS, 'sw:anchor', $token->{anchor}) |
$el->set_attribute_ns (SW09_NS, ['sw', 'anchor'], $token->{anchor}) |
| 978 |
if defined $token->{anchor}; |
if defined $token->{anchor}; |
| 979 |
$el->set_attribute (by => $token->{by}) if defined $token->{by}; |
$el->set_attribute_ns (undef, [undef, 'by'] |
| 980 |
$el->set_attribute_ns (SW09_NS, 'sw:resScheme', $token->{res_scheme}) |
=> $token->{by}) if defined $token->{by}; |
| 981 |
|
$el->set_attribute_ns (SW09_NS, ['sw', 'resScheme'], |
| 982 |
|
$token->{res_scheme}) |
| 983 |
if defined $token->{res_scheme}; |
if defined $token->{res_scheme}; |
| 984 |
$el->set_attribute_ns (SW09_NS, 'sw:resParameter', |
$el->set_attribute_ns (SW09_NS, ['sw', 'resParameter'], |
| 985 |
$token->{res_parameter}) |
$token->{res_parameter}) |
| 986 |
if defined $token->{res_parameter}; |
if defined $token->{res_parameter}; |
| 987 |
$el->text_content ($token->{content}) if defined $token->{content}; |
$el->text_content ($token->{content}) if defined $token->{content}; |
| 988 |
|
|
| 989 |
$get_next_token->(); |
$token = $get_next_token->(); |
| 990 |
redo A; |
redo A; |
| 991 |
} elsif ($token->{type} == END_OF_FILE_TOKEN) { |
} elsif ($token->{type} == END_OF_FILE_TOKEN) { |
| 992 |
return; |
return; |
| 999 |
TABLE_COLSPAN_CELL_TOKEN => 1}->{$token->{type}}) { |
TABLE_COLSPAN_CELL_TOKEN => 1}->{$token->{type}}) { |
| 1000 |
## NOTE: Ignore the token. |
## NOTE: Ignore the token. |
| 1001 |
} else { |
} else { |
| 1002 |
my $el = $doc->create_element_ns (HTML_NS, 'p'); |
my $el = $doc->create_element_ns (HTML_NS, [undef, 'p']); |
| 1003 |
$oe->[-1]->{node}->append_child ($el); |
$oe->[-1]->{node}->append_child ($el); |
| 1004 |
push @$oe, {%{$oe->[-1]}, node => $el}; |
push @$oe, {%{$oe->[-1]}, node => $el}; |
| 1005 |
|
|
| 1009 |
} |
} |
| 1010 |
} elsif ($im == IN_TABLE_ROW_IM) { |
} elsif ($im == IN_TABLE_ROW_IM) { |
| 1011 |
if ($token->{type} == TABLE_CELL_START_TOKEN) { |
if ($token->{type} == TABLE_CELL_START_TOKEN) { |
| 1012 |
my $el = $doc->create_element_ns (HTML_NS, 'td'); |
my $el = $doc->create_element_ns (HTML_NS, [undef, 'td']); |
| 1013 |
$oe->[-1]->{node}->append_child ($el); |
$oe->[-1]->{node}->append_child ($el); |
| 1014 |
push @$oe, {%{$oe->[-1]}, node => $el}; |
push @$oe, {%{$oe->[-1]}, node => $el}; |
| 1015 |
$el->set_user_data (manakai_source_line => $token->{line}); |
$el->set_user_data (manakai_source_line => $token->{line}); |
| 1016 |
$el->set_user_data (manakai_source_column => $token->{column}); |
$el->set_user_data (manakai_source_column => $token->{column}); |
| 1017 |
|
|
| 1018 |
$im = IN_PARAGRAPH_IM; |
$im = IN_PARAGRAPH_IM; |
| 1019 |
$get_next_token->(); |
$token = $get_next_token->(); |
| 1020 |
redo A; |
redo A; |
| 1021 |
} elsif ($token->{type} == TABLE_COLSPAN_CELL_TOKEN) { |
} elsif ($token->{type} == TABLE_COLSPAN_CELL_TOKEN) { |
| 1022 |
my $lc = $oe->[-1]->{node}->last_child; |
my $lc = $oe->[-1]->{node}->last_child; |
| 1023 |
if ($lc and $lc->manakai_local_name eq 'td') { |
if ($lc and $lc->manakai_local_name eq 'td') { |
| 1024 |
$lc->set_attribute |
$lc->set_attribute_ns |
| 1025 |
(colspan => ($lc->get_attribute ('colspan') || 0) + 1); |
(undef, [undef, 'colspan'], |
| 1026 |
|
($lc->get_attribute_ns (undef, 'colspan') || 0) + 1); |
| 1027 |
} else { |
} else { |
| 1028 |
my $el = $doc->create_element_ns (SW10_NS, 'td'); |
my $el = $doc->create_element_ns (SW10_NS, [undef, 'td']); |
| 1029 |
$oe->[-1]->{node}->append_child ($el); |
$oe->[-1]->{node}->append_child ($el); |
| 1030 |
$el->set_user_data (manakai_source_line => $token->{line}); |
$el->set_user_data (manakai_source_line => $token->{line}); |
| 1031 |
$el->set_user_data (manakai_source_column => $token->{column}); |
$el->set_user_data (manakai_source_column => $token->{column}); |
| 1032 |
} |
} |
| 1033 |
|
|
| 1034 |
$get_next_token->(); |
$token = $get_next_token->(); |
| 1035 |
redo A; |
redo A; |
| 1036 |
} elsif ($token->{type} == TABLE_ROW_END_TOKEN) { |
} elsif ($token->{type} == TABLE_ROW_END_TOKEN) { |
| 1037 |
pop @$oe if $oe->[-1]->{node}->manakai_local_name eq 'tr'; |
pop @$oe if $oe->[-1]->{node}->manakai_local_name eq 'tr'; |
| 1038 |
$get_next_token->(); |
$token = $get_next_token->(); |
| 1039 |
redo A; |
redo A; |
| 1040 |
} elsif ($token->{type} == TABLE_ROW_START_TOKEN) { |
} elsif ($token->{type} == TABLE_ROW_START_TOKEN) { |
| 1041 |
my $el = $doc->create_element_ns (HTML_NS, 'tr'); |
my $el = $doc->create_element_ns (HTML_NS, [undef, 'tr']); |
| 1042 |
$oe->[-1]->{node}->append_child ($el); |
$oe->[-1]->{node}->append_child ($el); |
| 1043 |
push @$oe, {%{$oe->[-1]}, node => $el}; |
push @$oe, {%{$oe->[-1]}, node => $el}; |
| 1044 |
$el->set_user_data (manakai_source_line => $token->{line}); |
$el->set_user_data (manakai_source_line => $token->{line}); |
| 1045 |
$el->set_user_data (manakai_source_column => $token->{column}); |
$el->set_user_data (manakai_source_column => $token->{column}); |
| 1046 |
|
|
| 1047 |
$get_next_token->(); |
$token = $get_next_token->(); |
| 1048 |
redo A; |
redo A; |
| 1049 |
} else { |
} else { |
| 1050 |
$im = IN_SECTION_IM; |
$im = IN_SECTION_IM; |