File Coverage

lib/Kwiki/Formatter/Pod.pm
Criterion Covered Total %
statement 1 3 33.3
branch n/a
condition n/a
subroutine 1 1 100.0
pod n/a
total 2 4 50.0


line stmt bran cond sub pod time code
1             package Kwiki::Formatter::Pod;
2 1     1   30605 use Spoon::Formatter -Base;
  0            
  0            
3             use Kwiki::Installer -base;
4             our $VERSION = '0.11';
5              
6             const top_class => 'Kwiki::Formatter::Pod::Top';
7             const class_title => 'Pod Formatter';
8              
9             package Kwiki::Formatter::Pod::Top;
10             use base 'Spoon::Formatter::Unit';
11              
12             sub parse {
13             $self->hub->css->add_file('formatter.css');
14             return $self;
15             }
16              
17             sub to_html {
18             require Pod::Simple::HTML;
19             my $source = $self->text;
20             my $result;
21             my $parser = Kwiki::Formatter::Pod::Simple::HTML->new;
22             $parser->kwiki_hub($self->hub);
23             $parser->output_string(\$result);
24             eval {
25             $parser->parse_string_document($source);
26             };
27             return "
\n$source\n$@\n
\n"
28             if $@ or not $result;
29             $result =~ s/.*(.*)<\/body>.*/$1/s;
30             return qq{
\n$result
};
31             }
32              
33             package Kwiki::Formatter::Pod::Simple::HTML;
34             use base 'Pod::Simple::HTML';
35             use base 'Kwiki::Base';
36             use Kwiki ':char_classes';
37              
38             field 'kwiki_hub';
39              
40             sub do_link {
41             my $token = shift;
42             my $link = $token->attr('to');
43             return super unless $link =~ /^[$WORD]+$/;
44             my $section = $token->attr('section');
45             $section = "#$section"
46             if defined $section and length $section;
47             $self->kwiki_hub->config->script_name . "?$link$section";
48             }
49              
50             package Kwiki::Formatter::Pod;
51             __DATA__