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   315 use 5.016;
  17         74  
3             our $VERSION = '2.01';
4 17     17   276 use strict;
  17         92  
  17         673  
5 17     17   90 use warnings;
  17         34  
  17         1076  
6              
7 17     17   109 use parent 'EBook::Ishmael::EBook::HTML';
  17         43  
  17         165  
8              
9             my $XHTML_NS = 'http://www.w3.org/1999/xhtml';
10              
11             sub heuristic {
12              
13 47     47 0 93 my $class = shift;
14 47         91 my $file = shift;
15 47         113 my $fh = shift;
16              
17 47 100       285 return 1 if $file =~ /\.xhtml?$/;
18 36 100       679 return 0 unless -T $fh;
19              
20 12         44 read $fh, my ($head), 1024;
21              
22 12 50       339 return 0 unless $head =~ /<[^<>]+xmlns\s*=\s*"\Q$XHTML_NS\E"[^<>]*>/;
23              
24 0           return $head =~ /<\s*html[^<>]+>/;
25              
26             }
27              
28             1;