line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Text::Livedoor::Wiki::Plugin::Block::CopyAndPaste; |
2
|
|
|
|
|
|
|
|
3
|
5
|
|
|
5
|
|
26
|
use warnings; |
|
5
|
|
|
|
|
13
|
|
|
5
|
|
|
|
|
155
|
|
4
|
5
|
|
|
5
|
|
32
|
use strict; |
|
5
|
|
|
|
|
14
|
|
|
5
|
|
|
|
|
154
|
|
5
|
5
|
|
|
5
|
|
27
|
use base qw(Text::Livedoor::Wiki::Plugin::Block); |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
212
|
|
6
|
5
|
|
|
5
|
|
309
|
use Text::Livedoor::Wiki::Utils; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
45
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
__PACKAGE__->trigger({ start=> '^=\|([a-z0-9A-Z\-_]*)(?:\(([^\)\|]+)\))?\|$' , end => '^\|\|=$' , escape => 1 }); |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub check { |
11
|
336
|
|
|
336
|
1
|
640
|
my $class = shift; |
12
|
336
|
|
|
|
|
474
|
my $line = shift; |
13
|
336
|
|
|
|
|
375
|
my $args = shift; |
14
|
336
|
|
|
|
|
726
|
my $on_next = $args->{on_next}; |
15
|
336
|
|
|
|
|
495
|
my $id = $args->{id}; |
16
|
336
|
|
|
|
|
405
|
my $scratchpad = $Text::Livedoor::Wiki::scratchpad; |
17
|
336
|
|
|
|
|
612
|
my $row; |
18
|
|
|
|
|
|
|
my $option_str; |
19
|
336
|
|
|
|
|
932
|
my $processing = $scratchpad->{block}{$id}{processing}; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
# header |
24
|
336
|
100
|
100
|
|
|
3717
|
if (( ( $row, $option_str ) = $line =~ /^=\|([a-z0-9A-Z\-_]*)(?:\(([^\)\|]+)\))?\|$/) && !$processing && !$on_next ){ |
|
|
100
|
100
|
|
|
|
|
|
|
100
|
100
|
|
|
|
|
|
|
100
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
25
|
17
|
|
|
|
|
48
|
my $res = { id => $id }; |
26
|
17
|
|
100
|
|
|
90
|
$row ||= 'PLAIN-BOX'; |
27
|
17
|
|
|
|
|
40
|
$res->{class_name} = $row; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
#XXX |
30
|
17
|
|
|
|
|
40
|
$Text::Livedoor::Wiki::scratchpad->{skip_ajust_block_break} = '1'; |
31
|
|
|
|
|
|
|
|
32
|
17
|
|
|
|
|
30
|
my $box = 'pre'; |
33
|
17
|
100
|
|
|
|
53
|
if ($option_str) { |
34
|
4
|
|
|
|
|
13
|
my @params = split( ';', $option_str ); |
35
|
|
|
|
|
|
|
|
36
|
4
|
|
|
|
|
10
|
for my $param (@params) { |
37
|
4
|
|
|
|
|
14
|
my ( $k, $v ) = split( '=', $param ); |
38
|
4
|
100
|
|
|
|
14
|
if ( $k eq 'box' ) { |
39
|
3
|
100
|
|
|
|
15
|
if ( $v eq 'div' ) { |
|
|
100
|
|
|
|
|
|
40
|
1
|
|
|
|
|
5
|
$box = 'div'; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
elsif( $v eq 'textarea' ) { |
43
|
1
|
|
|
|
|
5
|
$box = 'textarea'; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
} |
48
|
17
|
|
|
|
|
45
|
$res->{box} = $box; |
49
|
17
|
|
|
|
|
58
|
$scratchpad->{block}{$id}{processing} = 1; |
50
|
17
|
|
|
|
|
88
|
return $res; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
# end box |
53
|
|
|
|
|
|
|
elsif( $line =~ /^\|\|=$/ && $processing && !$on_next ) { |
54
|
17
|
|
|
|
|
41
|
$scratchpad->{block}{$id}{processing} = 0; |
55
|
17
|
|
|
|
|
99
|
return { line => '' } ; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
# finalize |
58
|
|
|
|
|
|
|
elsif( $on_next && !$processing ) { |
59
|
6
|
|
|
|
|
32
|
return ; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
# processing |
62
|
|
|
|
|
|
|
elsif( $processing ) { |
63
|
89
|
|
|
|
|
494
|
return { line => $line }; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
# not much |
67
|
207
|
|
|
|
|
1200
|
return; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub get { |
71
|
17
|
|
|
17
|
1
|
29
|
my $class = shift; |
72
|
17
|
|
|
|
|
26
|
my $block = shift; |
73
|
17
|
|
|
|
|
22
|
my $inline = shift; |
74
|
17
|
|
|
|
|
32
|
my $items = shift; |
75
|
17
|
|
|
|
|
22
|
my $meta = shift @{$items}; |
|
17
|
|
|
|
|
32
|
|
76
|
17
|
|
|
|
|
34
|
my $box = $meta->{box}; |
77
|
17
|
|
|
|
|
36
|
my $class_name = $meta->{class_name}; |
78
|
17
|
|
|
|
|
28
|
my $id = $meta->{id}; |
79
|
17
|
|
|
|
|
30
|
my $on_prettyprint = ""; |
80
|
17
|
|
|
|
|
94
|
my @syntax = qw/C CC CPP CS CYC JAVA BSH CSH SH CV PY PERL PL PM RB JS HTML XHTML XML XSL/; |
81
|
17
|
|
|
|
|
42
|
for my $sh ( @syntax ) { |
82
|
332
|
100
|
|
|
|
715
|
if ( $class_name eq $sh ) { |
83
|
1
|
|
|
|
|
3
|
$on_prettyprint = "prettyprint "; |
84
|
1
|
|
|
|
|
2
|
last; |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
} |
87
|
17
|
|
|
|
|
40
|
my $data = ''; |
88
|
17
|
|
|
|
|
104
|
$data .= $_->{line} . "\n" for @$items; |
89
|
17
|
|
|
|
|
84
|
$data =~ s/\n$//; |
90
|
|
|
|
|
|
|
|
91
|
17
|
|
|
|
|
67
|
$data = Text::Livedoor::Wiki::Utils::escape_more( $data ); |
92
|
|
|
|
|
|
|
|
93
|
17
|
|
|
|
|
170
|
return qq|<$box id="$id" class="$on_prettyprint$class_name">\n| . $data . "$box>\n";; |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
1; |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head1 NAME |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
Text::Livedoor::Wiki::Plugin::Block::CopyAndPaste - Copy & Page Block Plugin |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head1 DESCRIPTION |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
You can escape Wiki format. Just copy and paste! |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head1 SYNOPSIS |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=|| |
109
|
|
|
|
|
|
|
%%hi mom%% |
110
|
|
|
|
|
|
|
||= |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=|class_name| |
113
|
|
|
|
|
|
|
%%hi mom with class name%% |
114
|
|
|
|
|
|
|
||= |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=|HTML| |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
prettify js class name support. |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
||= |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head1 FUNCTION |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=head2 check |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=head2 get |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=head1 AUTHOR |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
polocky |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=cut |