97 |
$opt{file} =~ s/"/''/g; |
$opt{file} =~ s/"/''/g; |
98 |
sprintf '%s#line %d "%s"%s', "\n", $opt{line_no} || 1, $opt{file}, "\n"; |
sprintf '%s#line %d "%s"%s', "\n", $opt{line_no} || 1, $opt{file}, "\n"; |
99 |
} |
} |
100 |
|
sub literal_or_code ($$) { |
101 |
|
my ($Info, $s) = @_; |
102 |
|
substr ($s, 0, 1) ne '{' ? literal ($s) |
103 |
|
: code ($Info, substr ($s, 1, length ($s) - 2)); |
104 |
|
} |
105 |
|
|
106 |
my $parser = Message::Markup::SuikaWikiConfig20::Parser->new; |
my $parser = Message::Markup::SuikaWikiConfig20::Parser->new; |
107 |
my $plugins = $parser->parse_text ($src); |
my $plugins = $parser->parse_text ($src); |
181 |
register_plugin_const ($_, \%Info); |
register_plugin_const ($_, \%Info); |
182 |
} elsif ($_->local_name eq 'Format') { |
} elsif ($_->local_name eq 'Format') { |
183 |
print "\n", make_format ($_, \%Info); |
print "\n", make_format ($_, \%Info); |
184 |
|
# Parameter |
185 |
|
# PluginCategory |
186 |
} |
} |
187 |
} |
} |
188 |
|
|
213 |
$r .= qq{\$SuikaWiki::Format::Definition::Class{@{[literal $type.'//']}} = '$module_name';\n}; |
$r .= qq{\$SuikaWiki::Format::Definition::Class{@{[literal $type.'//']}} = '$module_name';\n}; |
214 |
} |
} |
215 |
|
|
216 |
$r .= line $Info, line_no => __LINE__ + 2, realfile => __FILE__; |
my $convert = line $Info, line_no => __LINE__ + 2, realfile => __FILE__; |
217 |
$r .= <<'EOH'; |
$convert .= <<'EOH'; |
218 |
our $Converter; |
our $Converter; |
219 |
sub convert ($$;%) { |
sub convert ($$;%) { |
220 |
my ($self, $source, %opt) = @_; |
my ($self, $source, %opt) = @_; |
232 |
} |
} |
233 |
EOH |
EOH |
234 |
|
|
|
my $reset = 0; |
|
235 |
for (@{$src->child_nodes}) { |
for (@{$src->child_nodes}) { |
236 |
if ($_->local_name eq 'Converter') { |
if ($_->local_name eq 'Converter') { |
237 |
$r .= line $Info, reset => 1 unless $reset; |
if ($convert) { |
238 |
|
$r .= $convert; |
239 |
|
$r .= line $Info, reset => 1; |
240 |
|
undef $convert; |
241 |
|
} |
242 |
$r .= make_format_converter ($_, $Info); |
$r .= make_format_converter ($_, $Info); |
|
$reset = 1; |
|
243 |
} elsif ($_->local_name eq 'Use') { |
} elsif ($_->local_name eq 'Use') { |
244 |
$r .= line $Info, node_path => qq(Format[module-name()=$module_name]/Use); |
$r .= line $Info, node_path => qq(Format[module-name()=$module_name]/Use); |
245 |
$r .= $_->inner_text; |
$r .= $_->inner_text; |
|
$reset = 0; |
|
246 |
} |
} |
247 |
} |
} |
|
$r .= line $Info, reset => 1 unless $reset; |
|
|
|
|
248 |
$r; |
$r; |
249 |
} |
} |
250 |
|
|
292 |
if $def{Name}; |
if $def{Name}; |
293 |
} elsif ($def{Name}) { |
} elsif ($def{Name}) { |
294 |
$r = qq{\$Converter->{@{[literal '/'.$def{Name}.'/'.$def{Version}.$flag]}} = {$r};\n}; |
$r = qq{\$Converter->{@{[literal '/'.$def{Name}.'/'.$def{Version}.$flag]}} = {$r};\n}; |
295 |
$r |
} else { |
296 |
|
$r = 'BEGIN { die "Invalid Syntax of Converter: Type or Name property required" }'; |
297 |
} |
} |
298 |
$r; |
$r; |
299 |
} |
} |
307 |
sub @{[$name = $src->get_attribute_value ('Name')]} { |
sub @{[$name = $src->get_attribute_value ('Name')]} { |
308 |
@{[line $Info, node_path => "Function[Name='$name']/Main"]}@{[ |
@{[line $Info, node_path => "Function[Name='$name']/Main"]}@{[ |
309 |
code $Info, $src->get_attribute_value ('Main') |
code $Info, $src->get_attribute_value ('Main') |
310 |
]}@{[line $Info, reset => 1]} |
]} |
311 |
} |
} |
312 |
|
@{[line $Info, reset => 1]} |
313 |
EOH |
EOH |
314 |
} |
} |
315 |
|
|
387 |
EOH |
EOH |
388 |
for (@{$src->child_nodes}) { |
for (@{$src->child_nodes}) { |
389 |
if ($_->local_name eq 'template') { |
if ($_->local_name eq 'template') { |
390 |
$r .= make_view_template_method ($_, $Info); |
$r .= make_view_template_method ($_, $Info, $ViewProp); |
391 |
} elsif ($_->local_name eq 'method') { |
} elsif ($_->local_name eq 'method') { |
392 |
my $method_name = $_->get_attribute_value ('Name'); |
my $method_name = $_->get_attribute_value ('Name'); |
393 |
$r .= ({ |
$r .= ({ |
394 |
main => q(sub main ($$) {)."\n".q(my ($self, $opt) = @_;)."\n", |
main => q(sub main ($$) {)."\n".q(my ($self, $opt, $opt2) = @_;)."\n", |
395 |
main_pre => q(sub main_pre ($$$) {)."\n".q(my ($self, $opt, $opt2) = @_;)."\n", |
main_pre => q(sub main_pre ($$$) {)."\n".q(my ($self, $opt, $opt2) = @_;)."\n", |
396 |
main_post => q(sub main_post ($$$) {)."\n".q(my ($self, $opt, $opt2) = @_;)."\n", |
main_post => q(sub main_post ($$$) {)."\n".q(my ($self, $opt, $opt2) = @_;)."\n", |
397 |
}->{$method_name} |
}->{$method_name} |
398 |
||qq(sub @{[$method_name]} {\n)) |
||qq(sub @{[$method_name]} {\n)) |
399 |
. line ($Info, node_path => "ViewDefinition[Mode='$ViewProp->{Name}']/method[Name='$method_name']") |
. line ($Info, node_path => "ViewDefinition[Mode='$ViewProp->{Name}']/method[Name='$method_name']") |
400 |
. code ($Info, $_->value) |
. code ($Info, $_->value) |
401 |
. line ($Info, reset => 1) |
. qq(}\n) |
402 |
. qq(}\n); |
. line ($Info, reset => 1); |
403 |
} |
} |
404 |
} |
} |
405 |
my $prop = {Name => $ViewProp->{Name}, |
my $prop = {Name => $ViewProp->{Name}, |
409 |
} |
} |
410 |
|
|
411 |
sub make_view_template_method ($$) { |
sub make_view_template_method ($$) { |
412 |
my ($src, $info) = @_; |
my ($src, $Info, $ViewProp) = @_; |
413 |
my $r = <<EOH; |
my $r = <<EOH; |
414 |
|
|
415 |
sub main (\$\$\$) { |
sub main (\$\$\$) { |
428 |
## Compatible options for SuikaWiki 2 WikiPlugin interface |
## Compatible options for SuikaWiki 2 WikiPlugin interface |
429 |
param => \\\%main::form, |
param => \\\%main::form, |
430 |
page => \$main::form{mypage}, |
page => \$main::form{mypage}, |
431 |
toc => [], |
#toc => [], |
432 |
#magic |
#magic |
433 |
#content |
#content |
434 |
#use_anchor_name |
#use_anchor_name |
449 |
@{[do{my $x=$src->get_attribute('http-status-code',make_new_node=>1)->inner_text; |
@{[do{my $x=$src->get_attribute('http-status-code',make_new_node=>1)->inner_text; |
450 |
$x?q{$opt2->{output}->{status_code} = }.(0 + $x).q{;}:q{}}]} |
$x?q{$opt2->{output}->{status_code} = }.(0 + $x).q{;}:q{}}]} |
451 |
@{[do{my $x=$src->get_attribute('http-status-phrase',make_new_node=>1)->inner_text; |
@{[do{my $x=$src->get_attribute('http-status-phrase',make_new_node=>1)->inner_text; |
452 |
$x?q{$opt2->{output}->{reason_phrase} = }.literal($x).q{;}:q{}}]} |
$x?q{$opt2->{output}->{status_phrase} = }.literal($x).q{;}:q{}}]} |
453 |
\$opt2->{output}->{entity}->{media_type} = @{[literal |
\$opt2->{output}->{entity}->{media_type} = @{[literal |
454 |
$src->get_attribute ('media-type',make_new_node=>1) |
$src->get_attribute ('media-type',make_new_node=>1) |
455 |
->inner_text || 'application/octet-stream']}; |
->inner_text || 'application/octet-stream']}; |
468 |
\$self->{view}->{wiki}->init_db; |
\$self->{view}->{wiki}->init_db; |
469 |
\$self->main_pre (\$opt, \$opt2); |
\$self->main_pre (\$opt, \$opt2); |
470 |
|
|
471 |
my \$fmt = SuikaWiki::Plugin->formatter ('view'); |
use Message::Util::Error; |
472 |
\$opt2->{output}->{entity}->{body} |
try { |
473 |
= \$fmt->replace (\$opt2->{template}, param => \$opt2->{o}); |
\$opt2->{output}->{entity}->{body} |
474 |
|
= SuikaWiki::Plugin->formatter ('view') |
475 |
|
->replace (\$opt2->{template}, param => \$opt2->{o}); |
476 |
|
} \$self->{view}->{wiki}->{config}->{catch}->{ @{[ |
477 |
|
$ViewProp->{Name} eq '-error' ? 'formatter_view_error' |
478 |
|
: 'formatter_view' ]} }; |
479 |
\$opt2->{output}->output (output => 'http-cgi'); |
\$opt2->{output}->output (output => 'http-cgi'); |
480 |
|
|
481 |
\$self->main_post (\$opt, \$opt2); |
\$self->main_post (\$opt, \$opt2); |
489 |
my $name = $src->get_attribute ('Name', make_new_node => 1)->value; |
my $name = $src->get_attribute ('Name', make_new_node => 1)->value; |
490 |
$name =~ s/(?<=.)-/_/g; |
$name =~ s/(?<=.)-/_/g; |
491 |
my $main = line ($Info, node_path => "FormattingRule[name()='@{[list $type]}/$name']/Formatting") |
my $main = line ($Info, node_path => "FormattingRule[name()='@{[list $type]}/$name']/Formatting") |
492 |
. code ($Info, $src->get_attribute_value ('Formatting')) |
. code ($Info, $src->get_attribute_value ('Formatting')); |
|
. line ($Info, reset => 1); |
|
493 |
|
|
494 |
my $reg_block; |
my $reg_block; |
495 |
$reg_block = qr/[^{}]*(?>[^{}]+|{(??{$reg_block})})*/; |
$reg_block = qr/[^{}]*(?>[^{}]+|{(??{$reg_block})})*/; |
|
my $reg_attr = qr/__ATTR(TEXT|NODE)?:%(\w+)(?:->{($reg_block)})?__;/; |
|
496 |
|
|
497 |
$main = q{my ($f, $rule_name, $p, $o, %opt) = @_;}."\n".$main |
$main = q{my ($f, $rule_name, $p, $o, %opt) = @_;}."\n".$main |
498 |
if $main =~ /\$f\b/ |
if $main =~ /\$f\b/ |
504 |
$main = q{my $r = '';} . "\n" . $main . "\n" |
$main = q{my $r = '';} . "\n" . $main . "\n" |
505 |
. q{$p->{-parent}->append_node ($r, node_or_text => 1);}; |
. q{$p->{-parent}->append_node ($r, node_or_text => 1);}; |
506 |
} |
} |
507 |
$main =~ s{$reg_attr} |
$main =~ s{__ATTR(TEXT|NODE)?:%(\w+|{$reg_block})(?:->{($reg_block)})?__;} |
508 |
{($1 eq 'TEXT' ? '$p->{'.literal($2).'} = do { my $r = ' : '') |
{($1 eq 'TEXT' ? '$p->{'.literal_or_code($Info, $2) |
509 |
.'$f->parse_attr ($p=>'.literal($2).', $o, ' |
.'} = do { my $r = ' : '') |
510 |
|
.'$f->parse_attr ($p=>'.literal_or_code($Info, $2).', $o, ' |
511 |
.($3?'-parent => '.$3.', ':'') |
.($3?'-parent => '.$3.', ':'') |
512 |
.($1?'-non_parsed_to_node => 1, ':'') |
.($1?'-non_parsed_to_node => 1, ':'') |
513 |
.'%opt)' |
.'%opt)' |
514 |
.($1 eq 'TEXT' ? '; ref $r?$r->inner_text:$r}' : '') |
.($1 eq 'TEXT' ? '; ref $r?$r->inner_text:$r}' : '') |
515 |
.';'}ge; |
.';'}ge; |
516 |
|
|
517 |
my $main = <<EOH; |
$main = <<EOH; |
518 |
{ |
{ |
519 |
main => sub {$main}, |
main => sub {$main}, |
520 |
|
@{[line ($Info, reset => 1)]} |
521 |
Description => [@{[m13ed_val_list $src, 'Description']}], |
Description => [@{[m13ed_val_list $src, 'Description']}], |
522 |
Parameter => {@{[do{ |
Parameter => {@{[do{ |
523 |
my @r; |
my @r; |