| 1 | package Text::Livedoor::Wiki::Plugin::Inline::Function; | ||||||||||
| 2 | |||||||||||
| 3 | 10 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 10 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 10 | ▶ | use base qw(Text::Livedoor::Wiki::Plugin::Inline); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | 10 | __PACKAGE__->regex(q{([&#]([a-zA-Z]+)\([\s]*([^\)]*)\))((?:\{(?:[^\{\}]|(?:\{(?:[^\{\}]|(?:\{[^\{\}]*\}))*\}))*\})?)}); | |||||||||
| 8 | 10 | __PACKAGE__->n_args(4); | |||||||||
| 9 | |||||||||||
| 10 | 152 | ▶ | sub process { | ||||||||
|
Subroutine
process: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||
| 11 | 152 | my ( $class , $inline, $head_part, $function_name, $opr, $tail_part ) = @_; | |||||||||
| 12 | 152 | my $original = $head_part . $tail_part; | |||||||||
| 13 | 152 | ▶ | $tail_part = $1 if ( $tail_part =~ /^\{(.*)\}$/ ); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 14 | # trim | ||||||||||
| 15 | 152 | $opr =~ s/^\s+//; | |||||||||
| 16 | 152 | $opr =~ s/\s+$//; | |||||||||
| 17 | |||||||||||
| 18 | 152 | $tail_part =~ s/^\s+//; | |||||||||
| 19 | 152 | $tail_part =~ s/\s+$//; | |||||||||
| 20 | |||||||||||
| 21 | 152 | ▶ | unless ( $inline->function->has_function( $function_name ) ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 22 | 1 | return Text::Livedoor::Wiki::Utils::escape_more($original); | |||||||||
| 23 | } | ||||||||||
| 24 | |||||||||||
| 25 | 151 | my $data = $inline->function->prepare( $function_name , $opr , $tail_part ); | |||||||||
| 26 | 151 | ▶ | unless( $data ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 27 | 25 | return Text::Livedoor::Wiki::Utils::escape_more( $original ); | |||||||||
| 28 | } | ||||||||||
| 29 | |||||||||||
| 30 | 126 | return $inline->function->parse( $function_name , $data ); | |||||||||
| 31 | } | ||||||||||
| 32 | |||||||||||
| 33 | 10 | 1; | |||||||||
| 34 | |||||||||||
| 35 | =head1 NAME | ||||||||||
| 36 | |||||||||||
| 37 | Text::Livedoor::Wiki::Plugin::Inline::Function - Inline Function Plugin | ||||||||||
| 38 | |||||||||||
| 39 | =head1 DESCRIPTION | ||||||||||
| 40 | |||||||||||
| 41 | This is a very special plugin which called function plugins. | ||||||||||
| 42 | |||||||||||
| 43 | =head1 SYNOPSIS | ||||||||||
| 44 | |||||||||||
| 45 | &functionname(){hoge} | ||||||||||
| 46 | #functionname(){hoge} | ||||||||||
| 47 | |||||||||||
| 48 | =head1 FUNCTION | ||||||||||
| 49 | |||||||||||
| 50 | =head2 process | ||||||||||
| 51 | |||||||||||
| 52 | =head1 AUTHOR | ||||||||||
| 53 | |||||||||||
| 54 | polocky | ||||||||||
| 55 | |||||||||||
| 56 | =cut | ||||||||||