210 |
$r .= qq{\$SuikaWiki::Format::Definition::Class{@{[literal '/'.$name.'/'.$src->get_attribute_value ('Version', default => '').'//']}} = '$module_name';\n}; |
$r .= qq{\$SuikaWiki::Format::Definition::Class{@{[literal '/'.$name.'/'.$src->get_attribute_value ('Version', default => '').'//']}} = '$module_name';\n}; |
211 |
} |
} |
212 |
if (my $type = $src->get_attribute_value ('Type')) { |
if (my $type = $src->get_attribute_value ('Type')) { |
213 |
|
$type .= join '', map { |
214 |
|
';'. $_->local_name .'='. quoted_string $_->inner_text |
215 |
|
} sort { |
216 |
|
$a->local_name cmp $b->local_name |
217 |
|
} @{$src->get_attribute ('Type')->child_nodes}; |
218 |
$r .= qq{\$SuikaWiki::Format::Definition::Class{@{[literal $type.'//']}} = '$module_name';\n}; |
$r .= qq{\$SuikaWiki::Format::Definition::Class{@{[literal $type.'//']}} = '$module_name';\n}; |
219 |
} |
} |
220 |
|
|
245 |
undef $convert; |
undef $convert; |
246 |
} |
} |
247 |
$r .= make_format_converter ($_, $Info); |
$r .= make_format_converter ($_, $Info); |
248 |
|
} elsif ($_->local_name eq 'WikiForm') { |
249 |
|
$r .= q(sub wikiform {)."\n".q(my ($self, $source, %opt) = @_;); |
250 |
|
$r .= line $Info, node_path => qq(Format[module-name()=$module_name]/WikiForm); |
251 |
|
$r .= code $Info, $_->get_attribute_value ('Main'); |
252 |
|
$r .= line $Info, reset => 1; |
253 |
|
$r .= qq(}\n); |
254 |
|
} elsif ($_->local_name eq 'NextIndex') { |
255 |
|
my $name = $_->get_attribute_value ('Name', default => ''); |
256 |
|
$r .= q(sub next_index_for_).$name |
257 |
|
. q( {)."\n".q(my ($self, $source, %opt) = @_;) |
258 |
|
. line $Info, node_path => qq(Format[module-name()=$module_name]/NextIndex[Name=$name]); |
259 |
|
$r .= code $Info, $_->get_attribute_value ('Main'); |
260 |
|
$r .= line $Info, reset => 1; |
261 |
|
$r .= qq(}\n); |
262 |
} elsif ($_->local_name eq 'Use') { |
} elsif ($_->local_name eq 'Use') { |
263 |
$r .= line $Info, node_path => qq(Format[module-name()=$module_name]/Use); |
$r .= line $Info, node_path => qq(Format[module-name()=$module_name]/Use); |
264 |
$r .= $_->inner_text; |
$r .= $_->inner_text; |
389 |
my $ViewProp = {}; |
my $ViewProp = {}; |
390 |
my $r = ''; |
my $r = ''; |
391 |
$ViewProp->{Name} = n11n $src->get_attribute_value ('Mode'); |
$ViewProp->{Name} = n11n $src->get_attribute_value ('Mode'); |
392 |
|
$ViewProp->{Name} =~ s/(?<=.)-/_/g; |
393 |
$ViewProp->{pack_name} = random_module_name ($Info, $ViewProp->{Name}); |
$ViewProp->{pack_name} = random_module_name ($Info, $ViewProp->{Name}); |
394 |
|
|
395 |
$ViewProp->{condition_stringified} = hash |
$ViewProp->{condition_stringified} = hash |
508 |
my $type = $src->get_attribute ('Category', make_new_node => 1)->value || []; |
my $type = $src->get_attribute ('Category', make_new_node => 1)->value || []; |
509 |
my $name = $src->get_attribute ('Name', make_new_node => 1)->value; |
my $name = $src->get_attribute ('Name', make_new_node => 1)->value; |
510 |
$name =~ s/(?<=.)-/_/g; |
$name =~ s/(?<=.)-/_/g; |
|
my $main = line ($Info, node_path => "FormattingRule[name()='@{[list $type]}/$name']/Formatting") |
|
|
. code ($Info, $src->get_attribute_value ('Formatting')); |
|
511 |
|
|
512 |
my $reg_block; |
my $reg_block; |
513 |
$reg_block = qr/[^{}]*(?>[^{}]+|{(??{$reg_block})})*/; |
$reg_block = qr/[^{}]*(?>[^{}]+|{(??{$reg_block})})*/; |
514 |
|
my %code; |
515 |
$main = q{my ($f, $rule_name, $p, $o, %opt) = @_;}."\n".$main |
for my $codename ([qw/Formatting main/], [qw/After after/], |
516 |
if $main =~ /\$f\b/ |
[qw/Before before/], [qw/Pre pre/], [qw/Post post/], |
517 |
or $main =~ /\$rule_name\b/ |
[qw/Attribute attr/]) { |
518 |
or $main =~ /\$[opr]\b/ |
my $main = code $Info, $src->get_attribute_value ($codename->[0]); |
519 |
or $main =~ /[%\$]opt\b/; |
next unless $main; |
520 |
if ($main =~ /\$r\b/) { |
$main = line ($Info, node_path => |
521 |
warn qq(Rule @{[list $type]}/$name: Use of \$r is deprecated); |
"FormattingRule[name()='@{[list $type]}/$name']/".$codename->[0]) |
522 |
$main = q{my $r = '';} . "\n" . $main . "\n" |
. $main; |
523 |
. q{$p->{-parent}->append_node ($r, node_or_text => 1);}; |
|
524 |
} |
$main = q{my ($f, $rule_name, $p, $o, %opt) = @_;}."\n".$main |
525 |
$main =~ s{__ATTR(TEXT|NODE)?:%(\w+|{$reg_block})(?:->{($reg_block)})?__;} |
if $main =~ /\$f\b/ |
526 |
{($1 eq 'TEXT' ? '$p->{'.literal_or_code($Info, $2) |
or $main =~ /\$rule_name\b/ |
527 |
.'} = do { my $r = ' : '') |
or $main =~ /\$[opr]\b/ |
528 |
.'$f->parse_attr ($p=>'.literal_or_code($Info, $2).', $o, ' |
or $main =~ /[%\$]opt\b/; |
529 |
.($3?'-parent => '.$3.', ':'') |
if ($main =~ /\$r\b/) { |
530 |
.($1?'-non_parsed_to_node => 1, ':'') |
warn qq(Rule @{[list $type]}/$name: Use of \$r is deprecated); |
531 |
.'%opt)' |
$main = q{my $r = '';} . "\n" . $main . "\n" |
532 |
.($1 eq 'TEXT' ? '; ref $r?$r->inner_text:$r}' : '') |
. q{$p->{-parent}->append_node ($r, node_or_text => 1);}; |
533 |
.';'}ge; |
} |
534 |
|
$main =~ s{__ATTR(TEXT|NODE)?:%(\w+|{$reg_block})(?:->{($reg_block)})?__;} |
535 |
$main = <<EOH; |
{($1 eq 'TEXT' ? '$p->{'.literal_or_code($Info, $2) |
536 |
|
.'} = do { my $r = ' : '') |
537 |
|
.'$f->parse_attr ($p=>'.literal_or_code($Info, $2).', $o, ' |
538 |
|
.($3?'-parent => '.$3.', ':'') |
539 |
|
.($1?'-non_parsed_to_node => 1, ':'') |
540 |
|
.'%opt)' |
541 |
|
.($1 eq 'TEXT' ? '; ref $r?$r->inner_text:$r}' |
542 |
|
: '') |
543 |
|
.';'}ge; |
544 |
|
$code{$codename->[1]} = barecode "sub {$main}"; |
545 |
|
} |
546 |
|
|
547 |
|
my $main = literal { |
548 |
|
Description => [barecode m13ed_val_list $src, 'Description'], |
549 |
|
Parameter => {do { |
550 |
|
my @r; |
551 |
|
for (@{$src->child_nodes}) { |
552 |
|
if ($_->local_name eq 'Parameter') { |
553 |
|
push @r, $_->get_attribute_value ('Name') |
554 |
|
=> {Type => $_->get_attribute_value ('Type'), |
555 |
|
Default => $_->get_attribute_value ('Default'), |
556 |
|
Description => [barecode m13ed_val_list $_, 'Description']}; |
557 |
|
} |
558 |
|
} |
559 |
|
@r; |
560 |
|
}}, |
561 |
|
%code, |
562 |
|
}; |
563 |
|
$main .= line $Info, reset => 1; |
564 |
|
|
565 |
|
|
566 |
|
my $amain = <<EOH; |
567 |
{ |
{ |
568 |
main => sub {$main}, |
main => sub {$main}, |
569 |
@{[line ($Info, reset => 1)]} |
@{[line ($Info, reset => 1)]} |
570 |
Description => [@{[m13ed_val_list $src, 'Description']}], |
Description => [@{[m13ed_val_list $src, 'Description']}], |
571 |
Parameter => {@{[do{ |
Parameter => {@{[do{ |
|
my @r; |
|
|
for (@{$src->child_nodes}) { |
|
|
if ($_->local_name eq 'Parameter') { |
|
|
push @r, $_->get_attribute_value ('Name') |
|
|
=> {Type => $_->get_attribute_value ('Type'), |
|
|
Default => $_->get_attribute_value ('Default'), |
|
|
Description => [barecode m13ed_val_list $_, 'Description']}; |
|
|
} |
|
|
} |
|
|
list @r; |
|
572 |
}]}}, |
}]}}, |
573 |
} |
} |
574 |
EOH |
EOH |