blib/lib/Text/Trac/Heading.pm

filter: Statementstmt 100% 24 / 24 Branchbran 75.0% 3 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod 0.0% 0 / 2 totaltotal 91.6% 33 / 36 SCAR 11.0
CC
3
Cov
96%
parse
3.0
BEGIN
1.0
BEGIN
1.0
CRAP 3.0
« blib/lib/Text/Trac/Table.pm ↑ Summary blib/lib/Text/Trac/Text.pm »
1 package Text::Trac::Heading;
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  
6 48 our $VERSION = '0.23';
7  
8 sub init {
9 160 ▶ my $self = shift;
Subroutine init: called CC=1 SCAR=0.0
Pod undocumented
10 160 $self->pattern(qr/^(=+) \s (.*) \s (=+)$/xms);
11 }
12  
13 sub parse {
14 228 ▶ my ( $self, $l ) = @_;
Subroutine parse: called CC=3 SCAR=11.0
Pod undocumented
15 228 my $c = $self->context;
16  
17 228 ▶ $l =~ $self->pattern or return;
Branch: 1 branch
BranchTrueFalseTotal
$l =~ $self->pattern or return 0 228 228
18 228 my $level = length($1) + $c->min_heading_level - 1;
19  
20 228 my $id = $self->_strip($2);
21 228 ▶ my $attr = $c->{id} ? qq{ id="$id"} : '';
Branch: 1 branch
BranchTrueFalseTotal
$c->{'id'} ? : 106 122 228
22 228 $l = qq(<h$level$attr>) . $self->replace($2) . qq(</h$level>);
23  
24 228 $c->htmllines($l);
25 }
26  
27 sub _strip {
28 228 ▶ my ( $self, $word ) = @_;
Subroutine _strip: called CC=1 SCAR=0.0
29 228 $word =~ s/[\s,_`'{}!]//g;
30 228 return $word;
31 }
32  
33 48 1;
« blib/lib/Text/Trac/Table.pm ↑ Summary blib/lib/Text/Trac/Text.pm »