blib/lib/Bible/OBML/Gateway.pm

filter: Statementstmt 72.5% 161 / 222 Branchbran 42.5% 23 / 54 Conditioncond 34.3% 22 / 64 MC/DCmcdc 8.8% 3 / 34 Subroutinesub 54.3% 31 / 57 Podpod 100% 5 / 5 totaltotal 56.1% 245 / 436 CC 56 SCAR 25.3
CC
56
Cov
61%
__ANON__
37.2
__ANON__
30.0
parse
28.4
CRAP 12.6
↑ Summary
1 package Bible::OBML::Gateway;
2 # ABSTRACT: Bible Gateway content conversion to Open Bible Markup Language
3  
4 2 ▶use 5.022;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 2 ▶use exact;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use exact::class;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 ▶use Bible::OBML;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 ▶use Bible::Reference;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 2 ▶use Mojo::ByteStream;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 2 ▶use Mojo::DOM;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 2 ▶use Mojo::UserAgent;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 2 ▶use Mojo::URL;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 2 ▶use Mojo::Util 'html_unescape';
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 2 our $VERSION = '2.12'; # VERSION
17  
18 2 has translation => 'NIV';
19 1 ▶has reference => sub { Bible::Reference->new( bible => 'Protestant' ) };
Subroutine __ANON__: called CC=1 SCAR=0.0
20 1 ▶has url => sub { Mojo::URL->new('https://www.biblegateway.com/passage/') };
Subroutine __ANON__: called CC=1 SCAR=0.0
21 1 ▶has ua => sub {
Subroutine __ANON__: called CC=2 SCAR=7.1
22 1 my $ua = Mojo::UserAgent->new( max_redirects => 3 );
23 1 ▶ $ua->transactor->name( __PACKAGE__ . '/' . ( __PACKAGE__->VERSION // '2.0' ) );
Condition50%1/2
__PACKAGE__->VERSION // "2.0"
l!l
10
MC/DC0%0/1
__PACKAGE__->VERSION // "2.0"
__PACKAGE__->VERSION
Truth table50%1/2
A
A= __PACKAGE__->VERSION
Aresult
11
00
24 1 return $ua;
25 2 };
26  
27 1 ▶sub translations ($self) {
Subroutine translations: called CC=1 SCAR=0.0
Pod documented
28 1 my $translations;
29  
30 2 ▶ $self->ua->get( $self->url )->result->dom->find('select.search-dropdown option')->each( sub {
Subroutine __ANON__: called CC=4 SCAR=13.9
31 2 ▶ my $class = $_->attr('class') || '';
Condition100%2/2
$_->attr('class') || ''
l!l
11
MC/DC100%1/1
$_->attr('class') || ''
$_->attr('class')
Truth table100%2/2
A
A= $_->attr('class')
Aresult
11
00
32  
33 2 ▶ if ( $class eq 'lang' ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($class eq 'lang') { } 1 1 2
elsif (not $class) { } 1 0 1
34 1 my @language = $_->text =~ /\-{3}(.+)\s\(([^\)]+)\)\-{3}/;
35 1 push( @$translations, {
36 language => $language[0],
37 acronym => $language[1],
38 } );
39 }
40 elsif ( not $class ) {
41 1 my @translation = $_->text =~ /\s*(.+)\s\(([^\)]+)\)/;
42 1 push( @{ $translations->[-1]{translations} }, {
43 translation => $translation[0],
44 acronym => $translation[1],
45 } );
46 }
47 1 } );
48  
49 1 return $translations;
50 }
51  
52 1 ▶sub structure ( $self, $translation = $self->translation ) {
Subroutine structure: called CC=2 SCAR=6.9
Pod documented
53 return $self->ua->get(
54 $self->url->clone->path( $self->url->path . 'bcv/' )->query( { version => $translation } )
55 1 )->result->json->{data}[0];
56 }
57  
58 21 ▶sub _retag ( $tag, $retag ) {
Subroutine _retag: called CC=2 SCAR=6.9
59 21 $tag->tag($retag);
60 21 delete $tag->attr->{$_} for ( keys %{ $tag->attr } );
61 }
62  
63 1 ▶sub fetch ( $self, $reference, $translation = $self->translation ) {
Subroutine fetch: called CC=6 SCAR=21.2
Pod documented
64 1 my $runs = $self->reference
65 ->acronyms(0)->require_chapter_match(0)->require_book_ucfirst(0)
66 ->clear->in($reference)->as_runs;
67 1 ▶ $reference = $runs->[0] unless ( @$runs != 1 or $runs->[0] !~ /\w\s*\d/ );
Branch: 1 branch
BranchTrueFalseTotal
unless @$runs != 1 or not $runs->[0] =~ /\w\s*\d/u 1 0 1
Condition33%1/3
@$runs != 1 or not $runs->[0] =~ /\w\s*\d/u
l!l&&r!l&&!r
001
MC/DC0%0/2
@$runs != 1 or not $runs->[0] =~ /\w\s*\d/u
@$runs != 1 not $runs->[0] =~ /\w\s*\d/u
Truth table33%1/3
A or not(B)
A= @$runs != 1B= not $runs->[0] =~ /\w\s*\d/u
ABresult
1X1
011
000
68  
69 1 my $result = $self->ua->get(
70 $self->url->query( {
71 version => $translation,
72 search => $reference,
73 } )
74 )->result;
75  
76 1 ▶ croak( $translation . ' "' . ( $reference // '(undef)' ) . '" did not match a chapter or run of verses' )
Branch: 1 branch
BranchTrueFalseTotal
if $result->dom->at("div.content-section") 0 1 1
Condition0%0/2
$reference // "(undef)"
l!l
00
MC/DC0%0/1
$reference // "(undef)"
$reference
Truth table0%0/2
A
A= $reference
Aresult
11
00
77 if ( $result->dom->at('div.content-section') );
78  
79 1 return Mojo::ByteStream->new( $result->body )->decode->to_string;
80 }
81  
82 1 ▶sub parse ( $self, $html ) {
Subroutine parse: called CC=12 SCAR=33.5
Pod documented
83 1 ▶ return unless ($html);
Branch: 1 branch
BranchTrueFalseTotal
unless $html 0 1 1
84  
85 1 my $dom = Mojo::DOM->new($html);
86  
87 1 my $ref_display = $dom->at('div.bcv div.dropdown-display-text');
88 1 ▶ croak('source appears to be invalid; check your inputs') unless ( $ref_display and $ref_display->text );
Branch: 1 branch
BranchTrueFalseTotal
unless $ref_display and $ref_display->text 0 1 1
Condition33%1/3
$ref_display and $ref_display->text
!ll&&!rl&&r
001
MC/DC0%0/2
$ref_display and $ref_display->text
$ref_display $ref_display->text
Truth table33%1/3
A and B
A= $ref_displayB= $ref_display->text
ABresult
0X0
100
111
89  
90 1 my $reference = $ref_display->text;
91 1 my $translation = $dom->at('div.passage-col')->attr('data-translation');
92  
93 1 ▶ croak('EXB (Extended Bible) translation not supported') if ( $translation eq 'EXB' );
Branch: 1 branch
BranchTrueFalseTotal
if $translation eq "EXB" 0 1 1
94  
95 1 my $block = $dom->at('div.passage-text div.passage-content div:first-child');
96 1 ▶ $block->find('*[data-link]')->each( sub { delete $_->attr->{'data-link'} } );
Subroutine __ANON__: called CC=1 SCAR=0.0
97  
98 1 $html = $block->to_string;
99  
100 1 $html =~ s`<sup>(\d+)</sup>.<sub>(\d+)</sub>`$1/$2`g;
101 1 $html =~ s`(?:&lt;){2,}(.*?)(?:\x{2019}&gt;|(?:&gt;){2,})`\x{201c}$1\x{201d}`g;
102 1 $html =~ s`(?:&lt;)(.*?)(?:&gt;|\x{2019})`\x{2018}$1\x{2019}`g;
103 1 $html =~ s`\\\w+``g;
104 1 $html =~ s/(?:\.\s*){2,}\./\x{2026}/;
105 1 $html =~ s/\x{200a}//g;
106  
107 1 $block = Mojo::DOM->new($html)->at('div');
108  
109 1 ▶ $_->parent->strip if ( $_ = $block->find('div.poetry > h2')->first );
Branch: 1 branch
BranchTrueFalseTotal
if $_ = $block->find("div.poetry > h2")->first 0 1 1
110  
111 1 ▶ $block->descendant_nodes->grep( sub { $_->type eq 'comment' } )->each('remove');
Subroutine __ANON__: called CC=1 SCAR=0.0
112 1 $block->find(
113 '.il-text, hidden, hr, .translation-note, span.inline-note, a.full-chap-link, b.inline-h3, top1'
114 )->each('remove');
115 1 $block->find('.std-text, hgroup, b, em, versenum, char')->each('strip');
116 $block
117 ->find('i, .italic, .trans-change, .idiom, .catch-word, selah, span.selah')
118 0 ▶ ->each( sub { _retag( $_, 'i' ) } );
Subroutine __ANON__: not called CC=1 SCAR=1.2
119 0 ▶ $block->find('.woj, u.jesus-speech')->each( sub { _retag( $_, 'woj' ) } );
Subroutine __ANON__: not called CC=1 SCAR=1.2
120 0 ▶ $block->find('.divine-name, .small-caps')->each( sub { _retag( $_, 'small_caps' ) } );
Subroutine __ANON__: not called CC=1 SCAR=1.2
121  
122 10 ▶ $block->find('sup')->grep( sub { length $_->text == 1 } )->each( sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
Subroutine __ANON__: not called CC=1 SCAR=2.6
123 0 $_->content( '-' . $_->content );
124 0 $_->strip;
125 1 } );
126  
127 1 $self->reference->acronyms(1)->require_chapter_match(1)->require_book_ucfirst(1);
128  
129 1 my $footnotes = $block->at('div.footnotes');
130 1 ▶ if ($footnotes) {
Branch: 1 branch
BranchTrueFalseTotal
if ($footnotes) 0 1 1
131 0 ▶ $footnotes->find('a.bibleref')->each( sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
132 0 ▶ ( my $ref = $_->attr('data-bibleref') // '' ) =~ s/\.(\d+)\.(\d+)/ $1:$2/g;
Condition0%0/2
$_->attr("data-bibleref") // ""
l!l
00
MC/DC0%0/1
$_->attr("data-bibleref") // ""
$_->attr("data-bibleref")
Truth table0%0/2
A
A= $_->attr("data-bibleref")
Aresult
11
00
133 0 $_->replace($ref);
134 0 } );
135 0 $footnotes->remove;
136 $footnotes = {
137 map {
138 0 '#' . $_->attr('id') => $self->reference->clear->in(
139 $_->at('span')->all_text
140 )->as_text
141 } $footnotes->find('ol li')->each
142 };
143 }
144  
145 1 my $crossrefs = $block->at('div.crossrefs');
146 1 ▶ if ($crossrefs) {
Branch: 1 branch
BranchTrueFalseTotal
if ($crossrefs) 1 0 1
147 0 ▶ $crossrefs->find('a.bibleref')->each( sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
148 0 ▶ ( my $ref = $_->attr('data-bibleref') // '' ) =~ s/\.(\d+)\.(\d+)/ $1:$2/g;
Condition0%0/2
$_->attr("data-bibleref") // ""
l!l
00
MC/DC0%0/1
$_->attr("data-bibleref") // ""
$_->attr("data-bibleref")
Truth table0%0/2
A
A= $_->attr("data-bibleref")
Aresult
11
00
149 0 $_->replace($ref);
150 1 } );
151 1 $crossrefs->remove;
152 $crossrefs = {
153 map {
154 1 '#' . $_->attr('id') => $self->reference->clear->in(
155 $_->at('a:last-child')->attr('data-bibleref')
156 )->refs
157 } $crossrefs->find('ol li')->each
158 };
159 }
160  
161 $block
162 ->find('span.text > a.bibleref')
163 ->map('parent')
164 0 ▶ ->grep( sub { $_->content =~ /^\[<a/ } )
Subroutine __ANON__: not called CC=1 SCAR=6.9
165 0 ▶ ->each( sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
166 0 ▶ $_->find('a')->each( sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
167 0 ▶ ( my $ref = $_->attr('data-bibleref') // '' ) =~ s/\.(\d+)\.(\d+)/ $1:$2/g;
Condition0%0/2
$_->attr("data-bibleref") // ""
l!l
00
MC/DC0%0/1
$_->attr("data-bibleref") // ""
$_->attr("data-bibleref")
Truth table0%0/2
A
A= $_->attr("data-bibleref")
Aresult
11
00
168 0 $_->replace($ref);
169 0 } );
170  
171 0 my $content = $_->content;
172 0 $content =~ s|\s+\[([^\]]+)\]|
173 0 '<footnote>' . $self->reference->clear->in($1)->as_text . '</footnote>'
174 |ge;
175  
176 0 $_->content($content);
177 1 } );
178  
179 $block
180 ->find('i > a.bibleref, crossref > a.bibleref')
181 ->map('parent')
182 0 ▶ ->grep( sub { $_->children->size == 1 } )
Subroutine __ANON__: not called CC=1 SCAR=6.9
183 0 ▶ ->each( sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
184 0 my $a = $_->at('a:last-child');
185 0 ▶ ( my $ref = $_->attr('data-bibleref') // '' ) =~ s/\.(\d+)\.(\d+)/ $1:$2/g;
Condition0%0/2
$_->attr("data-bibleref") // ""
l!l
00
MC/DC0%0/1
$_->attr("data-bibleref") // ""
$_->attr("data-bibleref")
Truth table0%0/2
A
A= $_->attr("data-bibleref")
Aresult
11
00
186  
187 0 $_->tag('sup');
188 0 $_->attr({
189 'class' => 'crossreference',
190 'data-cr' => $a->attr('data-bibleref'),
191 });
192  
193 0 $crossrefs = {
194 $a->attr('data-bibleref') => $self->reference->clear->in($ref)->refs
195 };
196 1 } );
197  
198 1 $block->find('a.bibleref')->each('strip');
199  
200 8 ▶ $block->find('sup.crossreference, sup.footnote')->each( sub {
Subroutine __ANON__: called CC=5 SCAR=22.0
201 8 ▶ if ( $_->attr('class') eq 'footnote' ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($_->attr('class') eq 'footnote') { } 0 8 8
elsif ($_->attr('class') eq 'crossreference') { } 8 0 8
202 $_->replace(
203 ( $footnotes->{ $_->attr('data-fn') } )
204 0 ▶ ? '<footnote>' . $footnotes->{ $_->attr('data-fn') } . '</footnote>'
Branch: 1 branch
BranchTrueFalseTotal
$$footnotes{$_->attr('data-fn')} ? : 0 0 0
205 : ''
206 );
207 }
208 elsif ( $_->attr('class') eq 'crossreference' ) {
209 $_->replace(
210 ( $crossrefs->{ $_->attr('data-cr') } )
211 8 ▶ ? '<crossref>' . $crossrefs->{ $_->attr('data-cr') } . '</crossref>'
Branch: 1 branch
BranchTrueFalseTotal
$$crossrefs{$_->attr('data-cr')} ? : 8 0 8
212 : ''
213 );
214 }
215 1 } );
216  
217 8 ▶ $block->find('footnote, crossref')->each( sub {
Subroutine __ANON__: called CC=17 SCAR=36.2
218 8 _retag( $_, $_->tag );
219  
220 # patch for if there's an error in the source HTML where some footnotes
221 # or crossrefs should have a space but don't
222  
223 8 my $previous = $_;
224 8 ▶ $previous = $previous->previous_node while (
Branch: 1 branch
BranchTrueFalseTotal
$previous and $previous->tag and $previous->tag eq "crossref" || $previous->tag eq "footnote" and do { $previous = $previous->previous_node } 8 8 16
Condition55%5/9
$previous and $previous->tag and $previous->tag eq "crossref" || $previous->tag eq "footnote"
!ll&&!rl&&r
808
$previous and $previous->tag
!ll&&!rl&&r
088
$previous->tag eq "crossref" or $previous->tag eq "footnote"
l!l&&r!l&&!r
800
MC/DC25%1/4
$previous and $previous->tag and $previous->tag eq "crossref" || $previous->tag eq "footnote"
$previous $previous->tag $previous->tag eq "crossref" $previous->tag eq "footnote"
Truth table40%2/5
A and B and C or D
A= $previousB= $previous->tagC= $previous->tag eq "crossref"D= $previous->tag eq "footnote"
ABCDresult
0XXX0
10XX0
11000
111X1
11011
225 $previous and $previous->tag and
226 ( $previous->tag eq 'crossref' or $previous->tag eq 'footnote' )
227 );
228 8 ▶ my $previous_char = substr( ( ($previous) ? $previous->all_text || $previous->content : '' ), -1 );
Branch: 1 branch
BranchTrueFalseTotal
$previous ? : 8 0 8
Condition33%1/3
$previous->all_text or $previous->content
l!l&&r!l&&!r
080
MC/DC0%0/2
$previous->all_text or $previous->content
$previous->all_text $previous->content
Truth table33%1/3
A or B
A= $previous->all_textB= $previous->content
ABresult
1X1
011
000
229  
230 8 my $next = $_;
231 8 ▶ $next = $next->next_node while (
Branch: 1 branch
BranchTrueFalseTotal
$next and $next->tag and $next->tag eq "crossref" || $next->tag eq "footnote" and do { $next = $next->next_node } 8 8 16
Condition55%5/9
$next and $next->tag and $next->tag eq "crossref" || $next->tag eq "footnote"
!ll&&!rl&&r
808
$next and $next->tag
!ll&&!rl&&r
088
$next->tag eq "crossref" or $next->tag eq "footnote"
l!l&&r!l&&!r
800
MC/DC25%1/4
$next and $next->tag and $next->tag eq "crossref" || $next->tag eq "footnote"
$next $next->tag $next->tag eq "crossref" $next->tag eq "footnote"
Truth table40%2/5
A and B and C or D
A= $nextB= $next->tagC= $next->tag eq "crossref"D= $next->tag eq "footnote"
ABCDresult
0XXX0
10XX0
11000
111X1
11011
232 $next and $next->tag and
233 ( $next->tag eq 'crossref' or $next->tag eq 'footnote' )
234 );
235 8 ▶ my $next_char = substr( ( ($next) ? $next->all_text || $next->content : '' ), 0, 1 );
Branch: 1 branch
BranchTrueFalseTotal
$next ? : 8 0 8
Condition33%1/3
$next->all_text or $next->content
l!l&&r!l&&!r
080
MC/DC0%0/2
$next->all_text or $next->content
$next->all_text $next->content
Truth table33%1/3
A or B
A= $next->all_textB= $next->content
ABresult
1X1
011
000
236  
237 8 ▶ $_->append(' ') if (
Branch: 1 branch
BranchTrueFalseTotal
if length $previous_char and length $next_char and $previous_char =~ /[:;,\w\!\.\?]/u and $next_char =~ /\w/u 0 8 8
Condition33%3/9
length $previous_char and length $next_char and $previous_char =~ /[:;,\w\!\.\?]/u and $next_char =~ /\w/u
!ll&&!rl&&r
080
length $previous_char and length $next_char and $previous_char =~ /[:;,\w\!\.\?]/u
!ll&&!rl&&r
008
length $previous_char and length $next_char
!ll&&!rl&&r
008
MC/DC0%0/4
length $previous_char and length $next_char and $previous_char =~ /[:;,\w\!\.\?]/u and $next_char =~ /\w/u
length $previous_char length $next_char $previous_char =~ /[:;,\w\!\.\?]/u $next_char =~ /\w/u
Truth table20%1/5
A and B and C and D
A= length $previous_charB= length $next_charC= $previous_char =~ /[:;,\w\!\.\?]/uD= $next_char =~ /\w/u
ABCDresult
0XXX0
10XX0
110X0
11100
11111
238 length $previous_char and
239 length $next_char and
240 $previous_char =~ /[:;,\w\!\.\?]/ and
241 $next_char =~ /\w/
242 );
243 1 } );
244  
245 1 _retag( $block, 'obml' );
246 1 $block->child_nodes->first->prepend( $block->new_tag( 'reference', $reference ) );
247  
248 1 $block->find('h3.chapter')->each('remove');
249 0 ▶ $block->find('h2 + h3')->each( sub { $_->tag('h4') } );
Subroutine __ANON__: not called CC=1 SCAR=1.2
250 1 ▶ $block->find('h2, h3')->each( sub { _retag( $_, 'header' ) } );
Subroutine __ANON__: called CC=1 SCAR=0.0
251 0 ▶ $block->find('h4')->each( sub { _retag( $_, 'sub_header' ) } );
Subroutine __ANON__: not called CC=1 SCAR=1.2
252  
253 1 ▶ $block->find('.versenum')->grep( sub { $_->text =~ /^\s*\(/ } )->each('remove');
Subroutine __ANON__: called CC=1 SCAR=0.0
254 0 ▶ $block->find('.chapternum + .versenum')->each( sub { $_->previous->remove } );
Subroutine __ANON__: not called CC=1 SCAR=1.2
255 0 ▶ $block->find('.chapternum + i > .versenum')->each( sub { $_->parent->previous->remove } );
Subroutine __ANON__: not called CC=1 SCAR=1.2
256  
257 1 ▶ $block->find('.chapternum')->each( sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
258 1 _retag( $_, 'verse_number' );
259 1 $_->content(1);
260 1 } );
261 2 ▶ $block->find('.versenum')->each( sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
262 2 _retag( $_, 'verse_number' );
263  
264 2 my $verse_number = $_->content;
265 2 $verse_number =~ s/^.*://g;
266 2 ($verse_number) = $verse_number =~ /(\d+)/;
267  
268 2 $_->content($verse_number);
269 1 } );
270  
271 1 ▶ $block->find('span.text')->each( sub { _retag( $_, 'text' ) } );
Subroutine __ANON__: called CC=1 SCAR=0.0
272  
273 0 ▶ $block->find('table')->each( sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
274 0 ▶ $_->find('tr')->each( sub {
Subroutine __ANON__: not called CC=5 SCAR=34.0
275 0 $_->find('th')->each('remove');
276 0 ▶ unless ( $_->child_nodes->size ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_->child_nodes->size) { } 0 0 0
277 0 $_->strip;
278 }
279 else {
280 0 ▶ $_->replace( join( '',
Branch: 3 branches
BranchTrueFalseTotal
$_->find('td text')->map('text')->last =~ /\W$/u ? : 0 0 0
$_->following_nodes->size ? : 0 0 0
$_->following_nodes->size ? : 0 0 0
281 '<text>',
282 $_->find('td text')->map('content')->join(', '),
283 (
284 ( $_->find('td text')->map('text')->last =~ /\W$/ ) ? '' :
285 ( $_->following_nodes->size ) ? '; ' : '.'
286 ),
287 ( ( $_->following_nodes->size ) ? '</text> ' : '</text>' ),
288 ) );
289 }
290 0 } );
291  
292 0 $_->tag('div');
293 0 $_->content( '<p>' . $_->content . '</p>' );
294 1 } );
295  
296 0 ▶ $block->find('ul, ol')->each( sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
297 0 ▶ $_->find('li')->each( sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
298 0 $_->tag('text');
299 0 $_->find('text > text')->each('strip');
300 0 ▶ $_->append_content('<br>') if ( $_->next and $_->next->tag eq 'li' );
Branch: 1 branch
BranchTrueFalseTotal
if $_->next and $_->next->tag eq "li" 0 0 0
Condition0%0/3
$_->next and $_->next->tag eq "li"
!ll&&!rl&&r
000
MC/DC0%0/2
$_->next and $_->next->tag eq "li"
$_->next $_->next->tag eq "li"
Truth table0%0/3
A and B
A= $_->nextB= $_->next->tag eq "li"
ABresult
0X0
100
111
301 0 } );
302  
303 0 $_->tag('div');
304 0 $_->attr( class => 'left-1' );
305 0 $_->content( '<p>' . $_->content . '</p>' );
306 1 } );
307  
308 9 ▶ $block->find( join( ', ', map { 'div.left-' . $_ } 1 .. 9 ) )->each( sub {
Subroutine __ANON__: not called CC=1 SCAR=4.1
309 0 my ($left) = $_->attr('class') =~ /\bleft\-(\d+)/;
310 0 ▶ $_->find('text')->each( sub { $_->attr( indent => $left ) } );
Subroutine __ANON__: not called CC=1 SCAR=6.9
311 0 $_->strip;
312 1 } );
313  
314 0 ▶ $block->find('div.poetry')->each( sub { $_->attr( class => 'indent-1' ) } );
Subroutine __ANON__: not called CC=1 SCAR=1.2
315 9 ▶ $block->find( join( ', ', map { '.indent-' . $_ } 1 .. 9 ) )->each( sub {
Subroutine __ANON__: not called CC=1 SCAR=4.9
316 0 my ($indent) = $_->attr('class') =~ /\bindent\-(\d+)/;
317 0 ▶ $_->find('text')->each( sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
318 0 ▶ $_->attr( indent => $indent + ( $_->attr('indent') || 0 ) );
Condition0%0/2
$_->attr('indent') || 0
l!l
00
MC/DC0%0/1
$_->attr('indent') || 0
$_->attr('indent')
Truth table0%0/2
A
A= $_->attr('indent')
Aresult
11
00
319 0 } );
320 0 $_->strip;
321 1 } );
322  
323 1 $block->find( join( ', ', map { '.indent-' . $_ . '-breaks' } 1 .. 5 ) )->each('remove');
324  
325 0 ▶ $block->find('text[indent]')->each( sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
326 0 my $level = $_->attr('indent');
327 0 _retag( $_, 'indent' );
328 0 $_->attr( level => $level );
329 1 } );
330 1 $block->find('text')->each('strip');
331  
332 0 ▶ $block->find('indent + indent')->each( sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
333 0 ▶ if ( $_->previous->attr('level') eq $_->attr('level') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_->previous->attr("level") eq $_->attr("level")) 0 0 0
334 0 $_->previous->append_content( ' ' . $_->content );
335 0 $_->remove;
336 }
337 1 } );
338  
339 1 ▶ $block->find('p')->each( sub { _retag( $_, 'p' ) } );
Subroutine __ANON__: called CC=1 SCAR=0.0
340  
341 1 ▶ $block->at('p')->prepend_content('<verse_number>1</verse_number>')
Branch: 1 branch
BranchTrueFalseTotal
if $block->at("p") and not $block->at("p")->at("verse_number") 0 1 1
Condition33%1/3
$block->at("p") and not $block->at("p")->at("verse_number")
!ll&&!rl&&r
010
MC/DC0%0/2
$block->at("p") and not $block->at("p")->at("verse_number")
$block->at("p") not $block->at("p")->at("verse_number")
Truth table33%1/3
A and not(B)
A= $block->at("p")B= not $block->at("p")->at("verse_number")
ABresult
0X0
100
111
342 if ( $block->at('p') and not $block->at('p')->at('verse_number') );
343  
344 1 $block->find('div, span, u, sup, bk, verse, start-chapter')->each('strip');
345  
346 1 ▶ $_->each('strip') while ( $_ = $block->find('i > i') and $_->size );
Branch: 1 branch
BranchTrueFalseTotal
$_ = $block->find("i > i") and $_->size and do { $_->each("strip") } 0 1 1
Condition33%1/3
$_ = $block->find("i > i") and $_->size
!ll&&!rl&&r
010
MC/DC0%0/2
$_ = $block->find("i > i") and $_->size
$_ = $block->find("i > i") $_->size
Truth table33%1/3
A and B
A= $_ = $block->find("i > i")B= $_->size
ABresult
0X0
100
111
347  
348 1 $html = html_unescape( $block->to_string );
349  
350 1 $html =~ s/<p>[ ]+/<p>/g; # remove spaces immediately after a "<p>"
351 1 $html =~ s/,([A-z]|<i>)/, $1/g; # fix missing spaces after commas (error in source HTML)
352 1 $html =~ s/([A-z])(<i>)/$1 $2/g; # fix missing spaces before <i> (error in source HTML)
353 1 $html =~ s/([a-z])([A-Z])/$1 $2/g; # fix missing spaces from collapsed words (error in source HTML)
354  
355 # hack: add back in any missing spaces after some punctuation
356 1 $html =~ s/([a-z])([:;,!?])([A-Za-z])/$1$2 $3/g;
357  
358 1 return $html;
359 }
360  
361 1 ▶sub get ( $self, $reference, $translation = $self->translation ) {
Subroutine get: called CC=2 SCAR=6.9
Pod documented
362 1 return Bible::OBML->new->html( $self->parse( $self->fetch( $reference, $translation ) ) );
363 }
364  
365 2 1;
366  
367 __END__
↑ Summary