line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#$Id:$ |
2
|
|
|
|
|
|
|
package Template::Plugin::VimColor; |
3
|
2
|
|
|
2
|
|
88015
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
89
|
|
4
|
2
|
|
|
2
|
|
13
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
77
|
|
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
10
|
use base qw (Template::Plugin::Filter); |
|
2
|
|
|
|
|
9
|
|
|
2
|
|
|
|
|
2190
|
|
7
|
2
|
|
|
2
|
|
11049
|
use Text::VimColor; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = 0.01; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub init { |
12
|
|
|
|
|
|
|
my $self = shift; |
13
|
|
|
|
|
|
|
$self->{_DYNAMIC} = 1; |
14
|
|
|
|
|
|
|
$self->install_filter($self->{_ARGS}->[0] || 'vimcolor'); |
15
|
|
|
|
|
|
|
$self; |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub filter { |
19
|
|
|
|
|
|
|
my ($self, $text, $args, $config) = @_; |
20
|
|
|
|
|
|
|
my $filetype = delete $config->{filetype} || 'perl'; |
21
|
|
|
|
|
|
|
my $syntax = Text::VimColor->new( |
22
|
|
|
|
|
|
|
string => \$text, |
23
|
|
|
|
|
|
|
filetype => $filetype, |
24
|
|
|
|
|
|
|
%$config, |
25
|
|
|
|
|
|
|
); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
my $output = $syntax->html; |
28
|
|
|
|
|
|
|
$output = _numbered(\$output) if $config->{set_number}; |
29
|
|
|
|
|
|
|
return $output; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub _numbered { |
33
|
|
|
|
|
|
|
my $textref = shift; |
34
|
|
|
|
|
|
|
my $ret = ''; |
35
|
|
|
|
|
|
|
my $cur_line = 0; |
36
|
|
|
|
|
|
|
$ret .= sprintf qq{%5d %s\n}, ++$cur_line, $_ |
37
|
|
|
|
|
|
|
for split /(?:\r\n|\r|\n)/, $$textref; |
38
|
|
|
|
|
|
|
$ret; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
1; |
42
|
|
|
|
|
|
|
__END__ |