blib/lib/Text/Trac/P.pm

filter: Statementstmt 100% 74 / 74 Branchbran 91.6% 22 / 24 Conditioncond 77.7% 7 / 9 MC/DCmcdc 50.0% 3 / 6 Subroutinesub 100% 5 / 5 Podpod 0.0% 0 / 1 totaltotal 93.2% 111 / 119 SCAR 30.0
CC
20
Cov
96%
parse
20.0
BEGIN
1.0
BEGIN
1.0
CRAP 20.0
« blib/lib/Text/Trac/InlineNode.pm ↑ Summary blib/lib/Text/Trac/Blockquote.pm »
1 package Text::Trac::P;
2 48 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 48 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 48 ▶use base qw(Text::Trac::BlockNode);
Subroutine BEGIN: called CC=1 SCAR=0.0
5 48 ▶use Text::Trac::Text;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 48 our $VERSION = '0.23';
8  
9 sub parse {
10 758 ▶ my ( $self, $l ) = @_;
Subroutine parse: called CC=20 SCAR=30.0
Pod undocumented
11 758 my $c = $self->{context};
12  
13 758 ▶ if ( !@{ $c->in_block_of } or $c->in_block_of->[-1] ne 'p' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not @{$c->in_block_of;} or $c->in_block_of->[-1] ne "p") 758 0 758
Condition66%2/3
not @{$c->in_block_of;} or $c->in_block_of->[-1] ne "p"
l!l&&r!l&&!r
684740
MC/DC0%0/2
not @{$c->in_block_of;} or $c->in_block_of->[-1] ne "p"
not @{$c->in_block_of;} $c->in_block_of->[-1] ne "p"
Truth table66%2/3
not(A) or B
A= not @{$c->in_block_of;}B= $c->in_block_of->[-1] ne "p"
ABresult
1X1
011
000
14 758 $c->htmllines('<p>');
15 758 push @{ $c->in_block_of }, 'p';
16 }
17  
18 # define block parsers called.
19 758 $self->block_nodes( [qw( blockquote hr )] );
20 758 $self->block_parsers( $self->_get_parsers('block') );
21  
22 758 my $cite_depth = 0;
23 758 $c->unshiftline;
24 758 ▶ while ( $c->hasnext ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($c->hasnext) 2219 127 2346
25 2219 ▶ last if $c->nextline =~ /^$/;
Branch: 1 branch
BranchTrueFalseTotal
if $c->nextline =~ /^$/ 513 1706 2219
26 1706 $l = $c->shiftline;
27 1706 ▶ last if $l =~ /^\s+$/;
Branch: 1 branch
BranchTrueFalseTotal
if $l =~ /^\s+$/ 2 1704 1706
28  
29 1704 my $blockquote_depth = 0;
30 1704 for ( @{ $c->in_block_of } ) {
31 1931 ▶ $blockquote_depth++ if $_ eq 'blockquote';
Branch: 1 branch
BranchTrueFalseTotal
if $_ eq "blockquote" 227 1704 1931
32 }
33  
34 1704 ▶ if ( $l =~ /^(>+)/ ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($l =~ /^(>+)/) { } 7 1697 1704
elsif (not $l =~ /^(?:>|\s+)/ and $blockquote_depth) { } 58 1870 1928
35 7 $cite_depth = length $1;
36 7 ▶ if ( $blockquote_depth != $cite_depth ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($blockquote_depth != $cite_depth) { } 1 6 7
37 1 $c->unshiftline;
38 1 last;
39 }
40 else {
41 6 $l =~ s/^>+//;
42 }
43 }
44 ▶ elsif ( $l !~ /^(?:>|\s+)/ and $blockquote_depth ) {
Condition100%3/3
not $l =~ /^(?:>|\s+)/ and $blockquote_depth
!ll&&!rl&&r
231140858
MC/DC100%2/2
not $l =~ /^(?:>|\s+)/ and $blockquote_depth
not $l =~ /^(?:>|\s+)/ $blockquote_depth
Truth table100%3/3
not(A) and B
A= not $l =~ /^(?:>|\s+)/B= $blockquote_depth
ABresult
0X0
100
111
45 58 $c->htmllines('</p>');
46 58 pop @{ $c->in_block_of };
47 58 for ( 1 .. $blockquote_depth ) {
48 59 $c->htmllines('</blockquote>');
49 59 pop @{ $c->in_block_of };
50 }
51  
52 58 $c->unshiftline;
53 58 last;
54 }
55  
56 # parse other block nodes
57 1645 my $parsers = $self->_get_matched_parsers( 'block', $l );
58 1645 ▶ if ( grep { ref($_) ne 'Text::Trac::P' } @{$parsers} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (grep {ref $_ ne "Text::Trac::P";} @{$parsers;}) 57 1588 1645
59 57 $c->htmllines('</p>');
60 57 pop @{ $c->in_block_of };
61 57 $c->unshiftline;
62 57 last;
63 }
64  
65 # parse inline nodes
66 1588 $l = $self->replace($l);
67 1588 $c->htmllines($l);
68 }
69  
70 758 ▶ if ( @{ $c->in_block_of } and $c->in_block_of->[-1] eq 'p' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@{$c->in_block_of;} and $c->in_block_of->[-1] eq "p") 643 115 758
Condition66%2/3
@{$c->in_block_of;} and $c->in_block_of->[-1] eq "p"
!ll&&!rl&&r
1150643
MC/DC50%1/2
@{$c->in_block_of;} and $c->in_block_of->[-1] eq "p"
@{$c->in_block_of;} $c->in_block_of->[-1] eq "p"
Truth table66%2/3
A and B
A= @{$c->in_block_of;}B= $c->in_block_of->[-1] eq "p"
ABresult
0X0
100
111
71 643 $c->htmllines('</p>');
72 643 pop @{ $c->in_block_of };
73  
74 643 my $blockquote_depth = 0;
75 643 for ( @{ $c->in_block_of } ) {
76 17 ▶ $blockquote_depth++ if $_ eq 'blockquote';
Branch: 1 branch
BranchTrueFalseTotal
if $_ eq "blockquote" 17 0 17
77 }
78  
79 643 ▶ if ($cite_depth) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cite_depth) 1 642 643
80 1 for ( $blockquote_depth .. length $1 ) {
81 1 $c->htmllines('</blockquote>');
82 1 pop @{ $c->in_block_of };
83 }
84 }
85 }
86  
87 758 return;
88 }
89  
90 48 1;
« blib/lib/Text/Trac/InlineNode.pm ↑ Summary blib/lib/Text/Trac/Blockquote.pm »