| 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
Condition66%2/3
not @{$c->in_block_of;} or $c->in_block_of->[-1] ne "p"
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"
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 25 | 2219 | ▶ | last if $c->nextline =~ /^$/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 26 | 1706 | $l = $c->shiftline; | |||||||||||||||||||||||||||
| 27 | 1706 | ▶ | last if $l =~ /^\s+$/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | 1704 | my $blockquote_depth = 0; | |||||||||||||||||||||||||||
| 30 | 1704 | for ( @{ $c->in_block_of } ) { | |||||||||||||||||||||||||||
| 31 | 1931 | ▶ | $blockquote_depth++ if $_ eq 'blockquote'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | 1704 | ▶ | if ( $l =~ /^(>+)/ ) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 35 | 7 | $cite_depth = length $1; | |||||||||||||||||||||||||||
| 36 | 7 | ▶ | if ( $blockquote_depth != $cite_depth ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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
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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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
Condition66%2/3
@{$c->in_block_of;} and $c->in_block_of->[-1] eq "p"
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"
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | 643 | ▶ | if ($cite_depth) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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; | |||||||||||||||||||||||||||