TextHighlight/HTML.pm

filter: Statementstmt 12.7% 11 / 86 Branchbran 0.0% 0 / 42 Conditioncond 0.0% 0 / 12 MC/DCmcdc 0.0% 0 / 7 Subroutinesub 60.0% 3 / 5 Podpod 50.0% 1 / 2 totaltotal 9.7% 15 / 154 CC 27 SCAR 62.6
CC
27
Cov
8%
highlight
650.0
new
12.0
BEGIN
1.0
CRAP 525.5
↑ Summary TextHighlight/Bash.pm »
1 package Tk::TextHighlight::HTML;
2  
3 1 ▶use vars qw($VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 $VERSION = '0.2';
5  
6 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use base('Tk::TextHighlight::Template');
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 0 ▶sub new {
Subroutine new: not called CC=3 SCAR=24.8
Pod undocumented
10 0 my ($proto, $rules) = @_;
11 0 ▶ my $class = ref($proto) || $proto;
Condition0%0/3
ref $proto || $proto
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $proto || $proto
ref $proto $proto
Truth table0%0/3
A || B
A= ref $protoB= $proto
ABresult
1X1
011
000
12 0 ▶ if (not defined($rules)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $rules) 0 0 0
13 0 $rules = [
14 ['Text'],
15 ['Tag', -foreground => 'brown'],
16 ['Attr', -foreground => 'darkblue'],
17 ['Comment', -foreground => 'lightblue'],
18 ['Value', -foreground => 'orange'],
19 ['String', -foreground => 'red'],
20 ['SpChar', -foreground => 'magenta'],
21 ];
22 };
23 0 my $self = $class->SUPER::new($rules);
24 0 $self->stackPush('Text');
25 0 bless ($self, $class);
26 0 return $self;
27 }
28  
29 0 ▶sub highlight {
Subroutine highlight: not called CC=25 SCAR=64.8
Pod documented
30 0 my $hlt = shift;
31 0 my @in = split //o, shift;
32 0 $hlt->snippetParse;
33 0 my $out = $hlt->out;
34 0 @$out = ();
35 0 foreach my $c (@in) {
36 0 ▶ if ($c eq '<') {
Branch: 8 branches
BranchTrueFalseTotal
if ($c eq '<') { } 0 0 0
elsif ($c eq '>') { } 0 0 0
elsif ($c eq '"') { } 0 0 0
elsif ($c eq '!') { } 0 0 0
elsif ($c eq '&') { } 0 0 0
elsif ($c eq ';') { } 0 0 0
elsif ($c eq '=') { } 0 0 0
elsif ($c =~ /\s/o) { } 0 0 0
37 0 ▶ if ($hlt->stackTop eq 'Text') {
Branch: 1 branch
BranchTrueFalseTotal
if ($hlt->stackTop eq 'Text') { } 0 0 0
38 # print "opening Tag\n";
39 0 $hlt->snippetParse;
40 0 $hlt->snippetAppend($c);
41 0 $hlt->stackPush('Tag');
42 } else {
43 0 $hlt->snippetAppend($c)
44 }
45 } elsif ($c eq '>') {
46 0 ▶ if ($hlt->stackTop eq 'Tag') {
Branch: 2 branches
BranchTrueFalseTotal
if ($hlt->stackTop eq 'Tag') { } 0 0 0
elsif ($hlt->stackTop eq 'Value' or $hlt->stackTop eq 'Attr' or $hlt->stackTop eq 'Comment') { } 0 0 0
47 # print "closing Tag\n";
48 0 $hlt->snippetAppend($c);
49 0 $hlt->snippetParse;
50 0 $hlt->stackPull;
51 ▶ } elsif (($hlt->stackTop eq 'Value') or ($hlt->stackTop eq 'Attr') or ($hlt->stackTop eq 'Comment')) {
Condition0%0/6
$hlt->stackTop eq "Value" or $hlt->stackTop eq "Attr" or $hlt->stackTop eq "Comment"
l!l&&r!l&&!r
000
$hlt->stackTop eq "Value" or $hlt->stackTop eq "Attr"
l!l&&r!l&&!r
000
MC/DC0%0/3
$hlt->stackTop eq "Value" or $hlt->stackTop eq "Attr" or $hlt->stackTop eq "Comment"
$hlt->stackTop eq "Value" $hlt->stackTop eq "Attr" $hlt->stackTop eq "Comment"
Truth table0%0/4
A or B or C
A= $hlt->stackTop eq "Value"B= $hlt->stackTop eq "Attr"C= $hlt->stackTop eq "Comment"
ABCresult
1XX1
01X1
0011
0000
52 # print "closing Tag\n";
53 0 $hlt->snippetParse;
54 0 $hlt->stackPull;
55 0 $hlt->snippetAppend($c);
56 0 $hlt->snippetParse;
57 0 $hlt->stackPull;
58 } else {
59 0 $hlt->snippetAppend($c);
60 }
61 } elsif ($c eq '"') {
62 0 ▶ if (($hlt->stackTop eq 'Value') or ($hlt->stackTop eq 'Comment')) {
Branch: 2 branches
BranchTrueFalseTotal
if ($hlt->stackTop eq 'Value' or $hlt->stackTop eq 'Comment') { } 0 0 0
elsif ($hlt->stackTop eq 'String') { } 0 0 0
Condition0%0/3
$hlt->stackTop eq "Value" or $hlt->stackTop eq "Comment"
l!l&&r!l&&!r
000
MC/DC0%0/2
$hlt->stackTop eq "Value" or $hlt->stackTop eq "Comment"
$hlt->stackTop eq "Value" $hlt->stackTop eq "Comment"
Truth table0%0/3
A or B
A= $hlt->stackTop eq "Value"B= $hlt->stackTop eq "Comment"
ABresult
1X1
011
000
63 # print "opening String\n";
64 0 $hlt->snippetParse;
65 0 $hlt->snippetAppend($c);
66 0 $hlt->stackPush('String');
67 } elsif ($hlt->stackTop eq 'String') {
68 # print "closing String\n";
69 0 $hlt->snippetAppend($c);
70 0 $hlt->snippetParse;
71 0 $hlt->stackPull;
72 } else {
73 0 $hlt->snippetAppend($c);
74 }
75 } elsif ($c eq '!') {
76 0 ▶ if ($hlt->stackTop eq 'Tag') {
Branch: 1 branch
BranchTrueFalseTotal
if ($hlt->stackTop eq 'Tag') { } 0 0 0
77 # print "opening Comment\n";
78 0 $hlt->snippetParse;
79 0 $hlt->snippetAppend($c);
80 0 $hlt->stackPush('Comment');
81 } else {
82 0 $hlt->snippetAppend($c);
83 }
84 } elsif ($c eq '&') {
85 0 ▶ if ($hlt->stackTop eq 'Text') {
Branch: 1 branch
BranchTrueFalseTotal
if ($hlt->stackTop eq 'Text') { } 0 0 0
86 # print "opening SpChar\n";
87 0 $hlt->snippetParse;
88 0 $hlt->snippetAppend($c);
89 0 $hlt->stackPush('SpChar');
90 } else {
91 0 $hlt->snippetAppend($c);
92 }
93 } elsif ($c eq ';') {
94 0 ▶ if ($hlt->stackTop eq 'SpChar') {
Branch: 1 branch
BranchTrueFalseTotal
if ($hlt->stackTop eq 'SpChar') { } 0 0 0
95 # print "closing SpChar\n";
96 0 $hlt->snippetAppend($c);
97 0 $hlt->snippetParse;
98 0 $hlt->stackPull;
99 } else {
100 0 $hlt->snippetAppend($c);
101 }
102 } elsif ($c eq '=') {
103 0 ▶ if ($hlt->stackTop eq 'Attr') {
Branch: 1 branch
BranchTrueFalseTotal
if ($hlt->stackTop eq 'Attr') { } 0 0 0
104 # print "opening Value\n";
105 0 $hlt->snippetParse;
106 0 $hlt->stackPull;
107 0 $hlt->snippetAppend($c);
108 0 $hlt->snippetParse;
109 0 $hlt->stackPush('Value');
110 } else {
111 0 $hlt->snippetAppend($c);
112 }
113 } elsif ($c =~ /\s/o) {
114 0 ▶ if ($hlt->stackTop eq 'Tag') {
Branch: 3 branches
BranchTrueFalseTotal
if ($hlt->stackTop eq 'Tag') { } 0 0 0
elsif ($hlt->stackTop eq 'Value') { } 0 0 0
elsif ($hlt->stackTop eq 'SpChar') { } 0 0 0
115 # print "opening Attr\n";
116 0 $hlt->snippetParse;
117 0 $hlt->snippetAppend($c);
118 0 $hlt->stackPush('Attr');
119 } elsif ($hlt->stackTop eq 'Value') {
120 0 $hlt->snippetParse;
121 0 $hlt->snippetAppend($c);
122 0 $hlt->stackPull;
123 0 $hlt->stackPush('Attr');
124 } elsif ($hlt->stackTop eq 'SpChar') {
125 0 $hlt->snippetParse;
126 0 $hlt->snippetAppend($c);
127 0 $hlt->stackPull;
128 } else {
129 0 $hlt->snippetAppend($c);
130 }
131 } else {
132 0 $hlt->snippetAppend($c);
133 }
134 }
135 0 $hlt->snippetParse;
136 0 return @$out;
137 }
138  
139 1 1;
140  
141 __END__
↑ Summary TextHighlight/Bash.pm »