186 |
register_plugin_const ($_, \%Info); |
register_plugin_const ($_, \%Info); |
187 |
} elsif ($_->local_name eq 'Format') { |
} elsif ($_->local_name eq 'Format') { |
188 |
print "\n", make_format ($_, \%Info); |
print "\n", make_format ($_, \%Info); |
189 |
|
} elsif ($_->local_name eq 'FormattingRuleAlias') { |
190 |
|
print "\n", make_rule_alias ($_, \%Info); |
191 |
# Parameter |
# Parameter |
192 |
# PluginCategory |
# PluginCategory |
193 |
} |
} |
616 |
} |
} |
617 |
$r; |
$r; |
618 |
} |
} |
619 |
|
|
620 |
|
=item FormattingRuleAlias |
621 |
|
|
622 |
|
Generating an alias name for a formatting rule that is already loaded. |
623 |
|
Example: |
624 |
|
|
625 |
|
FormattingRuleAlias: |
626 |
|
@Category[list]: |
627 |
|
category-1 |
628 |
|
category-2 |
629 |
|
... |
630 |
|
@Name: new-rule-name |
631 |
|
@Reference: |
632 |
|
@@Category: one-of-category |
633 |
|
@@Name: one-of-name |
634 |
|
|
635 |
|
associates C<(I<category-1>, I<new-rule-name>)>, |
636 |
|
C<(I<category-2>, I<new-rule-name>)>, ... |
637 |
|
with C<(I<one-of-category>, I<one-of-name>)>. |
638 |
|
|
639 |
|
=cut |
640 |
|
|
641 |
|
sub make_rule_alias ($$) { |
642 |
|
my ($src, $Info) = @_; |
643 |
|
my $type = $src->get_attribute ('Category', make_new_node => 1)->value || []; |
644 |
|
my $name = $src->get_attribute ('Name', make_new_node => 1)->value; |
645 |
|
|
646 |
|
my $ref = $src->get_attribute ('Reference', make_new_node => 1); |
647 |
|
my $c = $ref->get_attribute_value ('Category'); |
648 |
|
my $n = $ref->get_attribute_value ('Name'); |
649 |
|
|
650 |
|
s/(?<=.)-/_/g for $n, $name; |
651 |
|
tr/-/_/ for $c, @$type; |
652 |
|
|
653 |
|
my $def = qq{\$SuikaWiki::Plugin::Rule{@{[literal $c]}}->{@{[literal $n]}} or warn qq{Formatting rule "$c/$n" not defined}}; |
654 |
|
|
655 |
|
my $r = change_package $Info, $Info->{module_name}; |
656 |
|
for my $type (@$type) { |
657 |
|
$r .= qq{\$SuikaWiki::Plugin::Rule{@{[literal $type]}}->{@{[literal $name]}} = $def;\n}; |
658 |
|
push @{$Info->{provide}->{rule}->{$type}}, $name; |
659 |
|
} |
660 |
|
$r; |
661 |
|
} |
662 |
|
|
663 |
|
|
664 |
sub random_module_name ($;$) { |
sub random_module_name ($;$) { |