File Coverage

blib/lib/EBook/Ishmael/EBook/XHTML.pm
Criterion Covered Total %
statement 18 19 94.7
branch 5 6 83.3
condition n/a
subroutine 5 5 100.0
pod 0 1 0.0
total 28 31 90.3


line stmt bran cond sub pod time code
1             package EBook::Ishmael::EBook::XHTML;
2 17     17   385 use 5.016;
  17         67  
3             our $VERSION = '2.03';
4 17     17   108 use strict;
  17         37  
  17         515  
5 17     17   88 use warnings;
  17         36  
  17         970  
6              
7 17     17   99 use parent 'EBook::Ishmael::EBook::HTML';
  17         32  
  17         127  
8              
9             my $XHTML_NS = 'http://www.w3.org/1999/xhtml';
10              
11             sub heuristic {
12              
13 47     47 0 114 my $class = shift;
14 47         92 my $file = shift;
15 47         84 my $fh = shift;
16              
17 47 100       307 return 1 if $file =~ /\.xhtml?$/;
18 36 100       668 return 0 unless -T $fh;
19              
20 12         46 read $fh, my ($head), 1024;
21              
22 12 50       205 return 0 unless $head =~ /<[^<>]+xmlns\s*=\s*"\Q$XHTML_NS\E"[^<>]*>/;
23              
24 0           return $head =~ /<\s*html[^<>]+>/;
25              
26             }
27              
28             1;