File Coverage

lib/Kwiki/VimMode.pm
Criterion Covered Total %
statement 7 9 77.7
branch n/a
condition n/a
subroutine 3 3 100.0
pod n/a
total 10 12 83.3


line stmt bran cond sub pod time code
1             package Kwiki::VimMode;
2 2     2   72517 use strict;
  2         4  
  2         69  
3 2     2   9 use warnings;
  2         4  
  2         134  
4              
5 2     2   2319 use Kwiki::Plugin -Base;
  0            
  0            
6             use Kwiki::Installer -base;
7              
8             our $VERSION = 0.05;
9              
10             const class_title => 'color hiliting using Vim';
11             const class_id => 'vim_mode';
12             const css_file => 'vim_mode.css';
13              
14             sub register {
15             my $registry = shift;
16             $registry->add( wafl => vim => 'Kwiki::VimMode::Wafl' );
17             }
18              
19             package Kwiki::VimMode::Wafl;
20             use base 'Spoon::Formatter::WaflBlock';
21              
22             sub to_html {
23             require Text::VimColor;
24             my $string = $self->block_text;
25             chomp $string;
26             $ENV{PATH} = "/usr/local/bin:$ENV{PATH}";
27             $string =~ s/^ filetype: \s* (\w+) \s* \n+//sx;
28             my @filetype = $1 ? ( filetype => $1 ) : ();
29             my $vim = Text::VimColor->new(
30             string => $string,
31             @filetype,
32             vim_options => [ qw( -RXZ -i NONE -u NONE -N ), "+set nomodeline" ]
33             );
34             return '
' . $vim->html . "
\n";
35             }
36              
37             package Kwiki::VimMode;
38              
39             __DATA__