| 1 | package Text::Livedoor::Wiki::Plugin::Block::CopyAndPaste; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 5 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 5 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 5 | ▶ | use base qw(Text::Livedoor::Wiki::Plugin::Block); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 5 | ▶ | use Text::Livedoor::Wiki::Utils; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 5 | __PACKAGE__->trigger({ start=> '^=\|([a-z0-9A-Z\-_]*)(?:\(([^\)\|]+)\))?\|$' , end => '^\|\|=$' , escape => 1 }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 336 | ▶ | sub check { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
check: called CC=16 SCAR=27.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 336 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 336 | my $line = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 336 | my $args = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 336 | my $on_next = $args->{on_next}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 336 | my $id = $args->{id}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 336 | my $scratchpad = $Text::Livedoor::Wiki::scratchpad; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 336 | my $row; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | my $option_str; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 336 | my $processing = $scratchpad->{block}{$id}{processing}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | # header | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 336 | ▶ | if (( ( $row, $option_str ) = $line =~ /^=\|([a-z0-9A-Z\-_]*)(?:\(([^\)\|]+)\))?\|$/) && !$processing && !$on_next ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
Condition100%6/6
() = $line =~ /^=\|([a-z0-9A-Z\-_]*)(?:\(([^\)\|]+)\))?\|$/ and not $processing and not $on_next
() = $line =~ /^=\|([a-z0-9A-Z\-_]*)(?:\(([^\)\|]+)\))?\|$/ and not $processing
MC/DC100%3/3
() = $line =~ /^=\|([a-z0-9A-Z\-_]*)(?:\(([^\)\|]+)\))?\|$/ and not $processing and not $on_next
() = $line =~ /^=\|([a-z0-9A-Z\-_]*)(?:\(([^\)\|]+)\))?\|$/
not $processing
not $on_next
Truth table100%4/4
A and not(B) and not(C)
A= () = $line =~ /^=\|([a-z0-9A-Z\-_]*)(?:\(([^\)\|]+)\))?\|$/B= not $processingC= not $on_next
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 17 | my $res = { id => $id }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 17 | ▶ | $row ||= 'PLAIN-BOX'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$row ||= "PLAIN-BOX"
MC/DC100%1/1
$row ||= "PLAIN-BOX"
$row
Truth table100%2/2
A
A= $row
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 17 | $res->{class_name} = $row; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | #XXX | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 17 | $Text::Livedoor::Wiki::scratchpad->{skip_ajust_block_break} = '1'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 17 | my $box = 'pre'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 17 | ▶ | if ($option_str) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 4 | my @params = split( ';', $option_str ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 4 | for my $param (@params) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 4 | my ( $k, $v ) = split( '=', $param ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 4 | ▶ | if ( $k eq 'box' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 3 | ▶ | if ( $v eq 'div' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 1 | $box = 'div'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | elsif( $v eq 'textarea' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 1 | $box = 'textarea'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 17 | $res->{box} = $box; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 17 | $scratchpad->{block}{$id}{processing} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 17 | return $res; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | # end box | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | ▶ | elsif( $line =~ /^\|\|=$/ && $processing && !$on_next ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%6/6
$line =~ /^\|\|=$/ and $processing and not $on_next
$line =~ /^\|\|=$/ and $processing
MC/DC100%3/3
$line =~ /^\|\|=$/ and $processing and not $on_next
$line =~ /^\|\|=$/
$processing
not $on_next
Truth table100%4/4
A and B and not(C)
A= $line =~ /^\|\|=$/B= $processingC= not $on_next
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 17 | $scratchpad->{block}{$id}{processing} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 17 | return { line => '' } ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | # finalize | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | ▶ | elsif( $on_next && !$processing ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$on_next and not $processing
MC/DC100%2/2
$on_next and not $processing
$on_next
not $processing
Truth table100%3/3
A and not(B)
A= $on_nextB= not $processing
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 6 | return ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | # processing | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | elsif( $processing ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 89 | return { line => $line }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | # not much | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 207 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 17 | ▶ | sub get { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 17 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 17 | my $block = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 17 | my $inline = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 17 | my $items = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 17 | my $meta = shift @{$items}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 17 | my $box = $meta->{box}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 17 | my $class_name = $meta->{class_name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 17 | my $id = $meta->{id}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 17 | my $on_prettyprint = ""; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 17 | 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 | for my $sh ( @syntax ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 332 | ▶ | if ( $class_name eq $sh ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 1 | $on_prettyprint = "prettyprint "; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 1 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 17 | my $data = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 17 | $data .= $_->{line} . "\n" for @$items; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 17 | $data =~ s/\n$//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 17 | $data = Text::Livedoor::Wiki::Utils::escape_more( $data ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 17 | return qq|<$box id="$id" class="$on_prettyprint$class_name">\n| . $data . "</$box>\n";; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 5 | 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 | <html> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | <title>prettify js class name support.</title> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | </html> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | ||= | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | =head1 FUNCTION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | =head2 check | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | =head2 get | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | polocky | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||