| 1 | package HTML::Subtext; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use URI::Escape; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use vars qw($VERSION @ISA); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 1 | require HTML::Filter; | |||||||||||||||||||||||||||
| 8 | 1 | @ISA=qw(HTML::Filter); | |||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 1 | $VERSION = '1.03'; | |||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 2 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 13 | 2 | my $class = shift; | |||||||||||||||||||||||||||
| 14 | 2 | my $self = $class->SUPER::new(); | |||||||||||||||||||||||||||
| 15 | 2 | ▶ | while (@_) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 16 | 4 | my $key = shift; | |||||||||||||||||||||||||||
| 17 | 4 | my $val = shift; | |||||||||||||||||||||||||||
| 18 | 4 | $self->{$key} = $val; | |||||||||||||||||||||||||||
| 19 | } | ||||||||||||||||||||||||||||
| 20 | 2 | return $self; | |||||||||||||||||||||||||||
| 21 | } | ||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | 28 | ▶ | sub output { | ||||||||||||||||||||||||||
|
Subroutine
output: called CC=4 SCAR=14.5
Pod
undocumented
| |||||||||||||||||||||||||||||
| 24 | 28 | my $self = shift; | |||||||||||||||||||||||||||
| 25 | 28 | my $output = $self->{'OUTPUT'}; | |||||||||||||||||||||||||||
| 26 | 28 | ▶ | if ($output) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 27 | 28 | my $type = ref($output); | |||||||||||||||||||||||||||
| 28 | 28 | ▶ | if ($type eq 'ARRAY') { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 29 | 14 | push(@{$output}, $_[0]); | |||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||
| 31 | elsif ($type eq 'SCALAR') { | ||||||||||||||||||||||||||||
| 32 | 14 | $$output .= $_[0]; | |||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||
| 34 | else { | ||||||||||||||||||||||||||||
| 35 | 0 | print $output $_[0]; | |||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||
| 38 | else { | ||||||||||||||||||||||||||||
| 39 | 0 | $self->SUPER::output(@_); | |||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | 12 | ▶ | sub start { | ||||||||||||||||||||||||||
|
Subroutine
start: called CC=4 SCAR=14.8
Pod
documented
| |||||||||||||||||||||||||||||
| 44 | 12 | my $self = shift; | |||||||||||||||||||||||||||
| 45 | 12 | my $tag = $_[0]; | |||||||||||||||||||||||||||
| 46 | 12 | ▶ | if ($tag eq 'a' && $_[1]{'href'} =~ /^subtext:(.*)/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$tag eq "a" and $_[1]{"href"} =~ /^subtext:(.*)/
MC/DC50%1/2
$tag eq "a" and $_[1]{"href"} =~ /^subtext:(.*)/
$tag eq "a"
$_[1]{"href"} =~ /^subtext:(.*)/
Truth table66%2/3
A and B
A= $tag eq "a"B= $_[1]{"href"} =~ /^subtext:(.*)/
| |||||||||||||||||||||||||||||
| 47 | ($self->{subtext} = $self->{'CONTEXT'}{uri_unescape($1)}) | ||||||||||||||||||||||||||||
| 48 | 0 | ▶ | || do { warn "WARNING: HTML::Subtext -- no context for " . $_[3] . "\n"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 49 | 0 | $self->SUPER::start(@_); } | |||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||
| 51 | else { | ||||||||||||||||||||||||||||
| 52 | 8 | $self->SUPER::start(@_); | |||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | 12 | ▶ | sub text { | ||||||||||||||||||||||||||
|
Subroutine
text: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 57 | 12 | my $self = shift; | |||||||||||||||||||||||||||
| 58 | 12 | ▶ | if ($self->{subtext}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 59 | 4 | $self->output($self->{subtext}); | |||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||
| 61 | else { | ||||||||||||||||||||||||||||
| 62 | 8 | $self->SUPER::text(@_); | |||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | 12 | ▶ | sub end { | ||||||||||||||||||||||||||
|
Subroutine
end: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 67 | 12 | my $self = shift; | |||||||||||||||||||||||||||
| 68 | 12 | my $tag = $_[0]; | |||||||||||||||||||||||||||
| 69 | 12 | ▶ | if ($self->{subtext} && $tag eq 'a') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$self->{"subtext"} and $tag eq "a"
MC/DC50%1/2
$self->{"subtext"} and $tag eq "a"
$self->{"subtext"}
$tag eq "a"
Truth table66%2/3
A and B
A= $self->{"subtext"}B= $tag eq "a"
| |||||||||||||||||||||||||||||
| 70 | 4 | $self->{subtext} = 0; | |||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||
| 72 | else { | ||||||||||||||||||||||||||||
| 73 | 8 | $self->SUPER::end(@_); | |||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | 1 | 1; | |||||||||||||||||||||||||||
| 78 | __END__ | ||||||||||||||||||||||||||||