File Coverage

blib/lib/Pod/Simple/XHTML/BlendedCode/Blender.pm
Criterion Covered Total %
statement 33 33 100.0
branch 2 2 100.0
condition n/a
subroutine 8 8 100.0
pod 0 3 0.0
total 43 46 93.4


line stmt bran cond sub pod time code
1             package Pod::Simple::XHTML::BlendedCode::Blender;
2              
3             # This module blends the code into the pod in such a way that
4             # Pod::Simple::XHTML::Blended can use it.
5             # Think of it as a "pod+code->pod" parser.
6              
7 4     4   56526 use 5.008001;
  4         13  
  4         142  
8 4     4   23 use warnings;
  4         8  
  4         145  
9 4     4   20 use strict;
  4         13  
  4         163  
10 4     4   897 use parent 0.223 qw(Pod::Parser);
  4         422  
  4         74  
11 4     4   4071 use PPI::HTML 1.08 qw();
  4         751051  
  4         1333  
12              
13             our $VERSION = '1.000';
14             $VERSION =~ s/_//ms;
15              
16             sub initialize {
17 4     4 0 169 my $self = shift;
18 4         105 $self->{highlighter} = PPI::HTML->new();
19 4         171 return $self->SUPER::initialize();
20             }
21              
22             sub preprocess_paragraph {
23 117     117 0 10625 my ( $self, $text, $line_number ) = @_;
24              
25 117         147 my $html;
26              
27 117 100       598 if ( $self->cutting() ) {
28 29         129 $html = $self->{highlighter}->html( \$text );
29 29         264628 $html =~ s{<br>}{}msg;
30 29         143 $html =~ s{\n\n}{\n}msg;
31 29         369 $html =~ s{\t}{&nbsp;&nbsp;&nbsp;&nbsp;}msg;
32 29         48 print { $self->output_handle() }
  29         532  
33             "=begin html\n\n<pre>\n$html</pre>\n\n=end html\n\n";
34 29         2018 return q{};
35             } else {
36 88         7681 return $text;
37             }
38             } ## end sub preprocess_paragraph
39              
40             sub command {
41 36     36 0 71 my ( $self, $command, $text, $line_number, $pod_paragraph ) = @_;
42              
43 36         36 print { $self->output_handle() } $pod_paragraph->raw_text();
  36         388  
44 36         1398 return;
45             }
46              
47             1;                                     # Magic true value required at end of module
48              
49             __END__
50