File Coverage

blib/lib/SWISH/Filters/Doc2html.pm
Criterion Covered Total %
statement 9 18 50.0
branch 0 2 0.0
condition 0 4 0.0
subroutine 3 4 75.0
pod 1 2 50.0
total 13 30 43.3


line stmt bran cond sub pod time code
1             package SWISH::Filters::Doc2html;
2 1     1   526 use strict;
  1         2  
  1         37  
3 1     1   4 use vars qw( $VERSION @ISA );
  1         1  
  1         216  
4             $VERSION = '0.191';
5             @ISA = ('SWISH::Filters::Base');
6              
7             sub new {
8 1     1 0 28 my ($class) = @_;
9              
10 1         6 my $self = bless { mimetypes => [qr!application/(x-)?msword!], }, $class;
11              
12 1         7 return $self->set_programs('wvWare');
13             }
14              
15             sub filter {
16 0     0 1   my ( $self, $doc ) = @_;
17              
18             # Grab output from running program
19 0   0       my $content = $self->run_wvWare( "-1", $doc->fetch_filename ) || return;
20              
21 0   0       my $meta = $doc->meta_data || {};
22 0           my $headers = $self->format_meta_headers($meta);
23              
24 0 0         if ( $content =~ m//i ) {
25 0           $content =~ s//$headers/i;
26             }
27             else {
28 0           $content =~ s//$headers\n<title>/i; </td> </tr> <tr> <td class="h" > <a name="29">29</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } </td> </tr> <tr> <td class="h" > <a name="30">30</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="31">31</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> # update the document's content type </td> </tr> <tr> <td class="h" > <a name="32">32</a> </td> <td class="c0" > 0 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> $doc->set_content_type('text/html'); </td> </tr> <tr> <td class="h" > <a name="33">33</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="34">34</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> # return the document </td> </tr> <tr> <td class="h" > <a name="35">35</a> </td> <td class="c0" > 0 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> return ( \$content, $meta ); </td> </tr> <tr> <td class="h" > <a name="36">36</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } </td> </tr> <tr> <td class="h" > <a name="37">37</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> 1; </td> </tr> <tr> <td class="h" > <a name="38">38</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="39">39</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> __END__ </td> </tr> </table> </body> </html>