line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Kwiki::PerlTidyBlocks; |
2
|
1
|
|
|
1
|
|
72926
|
use Kwiki::Plugin -Base; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
use Kwiki::Installer -Base; |
4
|
|
|
|
|
|
|
our $VERSION = '0.12'; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
const class_id => 'perl_tidy_blocks'; |
7
|
|
|
|
|
|
|
const css_file => 'perl_tidy_blocks.css'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub register { |
10
|
|
|
|
|
|
|
my $registry = shift; |
11
|
|
|
|
|
|
|
$registry->add(prerequisite => 'cache'); |
12
|
|
|
|
|
|
|
$registry->add(wafl => perl => 'Kwiki::PerlTidyBlocks::Wafl'); |
13
|
|
|
|
|
|
|
} |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
package Kwiki::PerlTidyBlocks::Wafl; |
16
|
|
|
|
|
|
|
use base 'Spoon::Formatter::WaflBlock'; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub to_html { |
19
|
|
|
|
|
|
|
return join '', |
20
|
|
|
|
|
|
|
qq{<table class="perl_tidy_blocks"><tr><td>\n}, |
21
|
|
|
|
|
|
|
$self->from_cache($self->block_text), |
22
|
|
|
|
|
|
|
qq{</td></tr></table>\n}; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub from_cache { |
26
|
|
|
|
|
|
|
my $source = shift; |
27
|
|
|
|
|
|
|
$self->hub->cache->process( |
28
|
|
|
|
|
|
|
sub { $self->tidy($source) }, 'perl_tidy_blocks', $source |
29
|
|
|
|
|
|
|
); |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub tidy { |
33
|
|
|
|
|
|
|
my $source = shift; |
34
|
|
|
|
|
|
|
require Perl::Tidy; |
35
|
|
|
|
|
|
|
my $result; |
36
|
|
|
|
|
|
|
eval { |
37
|
|
|
|
|
|
|
Perl::Tidy::perltidy( |
38
|
|
|
|
|
|
|
source => \$source, |
39
|
|
|
|
|
|
|
destination => \$result, |
40
|
|
|
|
|
|
|
argv => [qw( -q -html -pre -npro )], |
41
|
|
|
|
|
|
|
); |
42
|
|
|
|
|
|
|
}; |
43
|
|
|
|
|
|
|
$@ ? $source : $result; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
package Kwiki::PerlTidyBlocks; |
47
|
|
|
|
|
|
|
__DATA__ |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head1 NAME |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
Kwiki::PerlTidyBlocks - Kwiki Perl Tidy Blocks Plugin |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head1 SYNOPSIS |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head1 DESCRIPTION |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head1 AUTHOR |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
Brian Ingerson <ingy@cpan.org> |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head1 COPYRIGHT |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
Copyright (c) 2004. Brian Ingerson. All rights reserved. |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
66
|
|
|
|
|
|
|
under the same terms as Perl itself. |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
See http://www.perl.com/perl/misc/Artistic.html |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=cut |
71
|
|
|
|
|
|
|
__css/perl_tidy_blocks.css__ |
72
|
|
|
|
|
|
|
table.perl_mode pre { |
73
|
|
|
|
|
|
|
background-color: #FFF; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
table.perl_mode td { |
77
|
|
|
|
|
|
|
border: 0; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
.pd { color: #404080;} /* pod-text */ |
81
|
|
|
|
|
|
|
.c { color: #404080;} /* comment */ |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
.cm { color: #800097;} /* comma */ |
84
|
|
|
|
|
|
|
.co { color: #800097;} /* colon */ |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
.h { color: #804848;} /* here-doc-target */ |
87
|
|
|
|
|
|
|
.hh { color: #800000;} /* here-doc-text */ |
88
|
|
|
|
|
|
|
.q { color: #800000;} /* quote */ |
89
|
|
|
|
|
|
|
.v { color: #800000;} /* v-string */ |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
.i { color: #008080;} /* identifier */ |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
.k { color: #0000FF;} /* keyword */ |
94
|
|
|
|
|
|
|
.n { color: #E02020;} /* numeric */ |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
.m { color: #C00080;} /* subroutine */ |
97
|
|
|
|
|
|
|
.j { color: #C00080;} /* label */ |
98
|
|
|
|
|
|
|
.w { color: #C00080;} /* bareword */ |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
.p { color: #800080;} /* paren */ |
101
|
|
|
|
|
|
|
.s { color: #800080;} /* structure */ |
102
|
|
|
|
|
|
|
.sc { color: #800080;} /* semicolon */ |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
.pu { color: #C44800;} /* punctuation */ |