| 1 | package HTML::Packer; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 3 | ▶ | use 5.008009; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 3 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 3 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 3 | ▶ | use Regexp::RegGrp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 3 | our $VERSION = '1.003_001'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 3 | our @BOOLEAN_ACCESSORS = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 'remove_comments', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 'remove_newlines', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 'no_compress_comment', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 'html5', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 3 | our @JAVASCRIPT_OPTS = ( 'clean', 'obfuscate', 'shrink', 'best' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 3 | our @CSS_OPTS = ( 'minify', 'pretty' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 3 | our $REQUIRED_JAVASCRIPT_PACKER = '1.002001'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 3 | our $REQUIRED_CSS_PACKER = '1.000001'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 3 | our @SAVE_SPACE_ELEMENTS = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 'a', 'abbr', 'acronym', 'address', 'b', 'bdo', 'big', 'button', 'cite', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 'del', 'dfn', 'em', 'font', 'i', 'input', 'ins', 'kbd', 'label', 'q', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 's', 'samp', 'select', 'small', 'strike', 'strong', 'sub', 'sup', 'u', 'var' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 3 | our @VOID_ELEMENTS = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 'area', 'base', 'br', 'col', 'command', 'embed', 'hr', 'img', 'input', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 'keygen', 'link', 'meta', 'param', 'source', 'track', 'wbr' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | # Some regular expressions are from HTML::Clean | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 3 | our $COMMENT = '((?>\s*))(<!--(?:(?![#\[]| google_ad_section_).*?)?-->)((?>\s*))'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 3 | our $PACKER_COMMENT = '<!--\s*HTML::Packer\s*(\w+)\s*-->'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 3 | our $DOCTYPE = '<\!DOCTYPE[^>]*>'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 3 | our $DONT_CLEAN = '(<\s*(pre|code|textarea|script|style)[^>]*>)(.*?)(<\s*\/\2[^>]*>)'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | our $WHITESPACES = [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | regexp => qr/^\s*/s, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | replacement => '' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | regexp => qr/\s*$/s, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | replacement => '' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | regexp => '^\s*', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | replacement => '', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | modifier => 'm' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | regexp => '[^\S\n]*$', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | replacement => '', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | modifier => 'm' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | regexp => qr/(?<=>)[^<>]*(?=<)/sm, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | replacement => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 50 | ▶ | my $match = $_[0]->{match}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 50 | $match =~ s/[^\S\n]{2,}/ /sg; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 50 | $match =~ s/\s*\n+\s*/\n/sg; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 50 | return $match; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | regexp => '<\s*(\/)?\s*', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | replacement => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 70 | ▶ | return sprintf( '<%s', $_[0]->{submatches}->[0] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | modifier => 's' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | regexp => '\s*(\/)?\s*>', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | replacement => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 70 | ▶ | return sprintf( '%s>', $_[0]->{submatches}->[0] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 3 | modifier => 's' | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | our $NEWLINES_TAGS = [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | regexp => '(\s*)(<\s*\/?\s*(?:' . join( '|', @SAVE_SPACE_ELEMENTS ) . ')\b[^>]*>)(\s*)', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | replacement => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 32 | ▶ | return sprintf( '%s%s%s', $_[0]->{submatches}->[0] ? ' ' : '', $_[0]->{submatches}->[1], $_[0]->{submatches}->[2] ? ' ' : '' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 3 | modifier => 'is' | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | our $NEWLINES = [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | regexp => '(.)\n(.)', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | replacement => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 10 | ▶ | my ( $pre, $post ) = @{$_[0]->{submatches}}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=5 SCAR=17.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 10 | my $ret; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 10 | ▶ | if ( $pre eq '>' or $post eq '<' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%2/3
$pre eq ">" or $post eq "<"
MC/DC50%1/2
$pre eq ">" or $post eq "<"
$pre eq ">"
$post eq "<"
Truth table66%2/3
A or B
A= $pre eq ">"B= $post eq "<"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 2 | $ret = $pre . $post; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | ▶ | elsif ( $pre =~ /[\w-]/ and $post =~ /[\w-]/ ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$pre =~ /[\w-]/ and $post =~ /[\w-]/
MC/DC0%0/2
$pre =~ /[\w-]/ and $post =~ /[\w-]/
$pre =~ /[\w-]/
$post =~ /[\w-]/
Truth table33%1/3
A and B
A= $pre =~ /[\w-]/B= $post =~ /[\w-]/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 8 | $ret = $pre . ' ' . $post; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | $ret = $pre . $post; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 10 | return $ret; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 3 | ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 3 | our @REGGRPS = ( 'newlines', 'newlines_tags', 'whitespaces', 'void_elements' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 3 | our $GLOBAL_REGGRP = 'global'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | ########################################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 3 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 3 | foreach my $field ( @BOOLEAN_ACCESSORS ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 12 | ▶ | next if defined *{ __PACKAGE__ . '::' . $field }{CODE}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 12 | *{ __PACKAGE__ . '::' . $field} = sub { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 146 | ▶ | my ( $self, $value ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 146 | ▶ | $self->{'_' . $field} = $value ? 1 : undef if ( defined( $value ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 146 | return $self->{'_' . $field}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 12 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 3 | foreach my $reggrp ( @REGGRPS, $GLOBAL_REGGRP ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 15 | ▶ | next if defined *{ __PACKAGE__ . '::reggrp_' . $reggrp }{CODE}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 15 | *{ __PACKAGE__ . '::reggrp_' . $reggrp } = sub { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 68 | ▶ | my ( $self ) = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 68 | return $self->{ '_reggrp_' . $reggrp }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 15 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | sub do_javascript { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 19 | ▶ | my ( $self, $value ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
do_javascript: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 19 | ▶ | if ( defined( $value ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 10 | ▶ | if ( grep( $value eq $_, @JAVASCRIPT_OPTS ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 7 | $self->{_do_javascript} = $value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | elsif ( ! $value ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 1 | $self->{_do_javascript} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 19 | return $self->{_do_javascript}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | sub do_stylesheet { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 16 | ▶ | my ( $self, $value ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
do_stylesheet: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 16 | ▶ | if ( defined( $value ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 8 | ▶ | if ( grep( $value eq $_, @CSS_OPTS ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 5 | $self->{_do_stylesheet} = $value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | elsif ( ! $value ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 1 | $self->{_do_stylesheet} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 16 | return $self->{_do_stylesheet}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | sub init { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 8 | ▶ | my $class = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
init: called CC=2 SCAR=7.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 8 | my $self = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 8 | bless( $self, $class ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 8 | $self->{whitespaces}->{reggrp_data} = $WHITESPACES; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 8 | $self->{newlines}->{reggrp_data} = $NEWLINES; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 8 | $self->{newlines_tags}->{reggrp_data} = $NEWLINES_TAGS; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | $self->{global}->{reggrp_data} = [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | regexp => $DOCTYPE, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | replacement => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | ▶ | return '<!--~' . $_[0]->{store_index} . '~-->'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | store => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | ▶ | my $doctype = $_[0]->{match}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | $doctype =~ s/\s+/ /gsm; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | return $doctype; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | regexp => $COMMENT, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | replacement => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | return $self->remove_comments() ? ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | $self->remove_newlines() ? ' ' : ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | ( $_[0]->{submatches}->[0] =~ /\n/s or $_[0]->{submatches}->[2] =~ /\n/s ) ? "\n" : '' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 12 | ▶ | ) : '<!--~' . $_[0]->{store_index} . '~-->'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=5 SCAR=17.4
Branch: 3 branches
Condition33%1/3
$_[0]{"submatches"}[0] =~ /\n/s or $_[0]{"submatches"}[2] =~ /\n/s
MC/DC0%0/2
$_[0]{"submatches"}[0] =~ /\n/s or $_[0]{"submatches"}[2] =~ /\n/s
$_[0]{"submatches"}[0] =~ /\n/s
$_[0]{"submatches"}[2] =~ /\n/s
Truth table33%1/3
A or B
A= $_[0]{"submatches"}[0] =~ /\n/sB= $_[0]{"submatches"}[2] =~ /\n/s
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | store => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | my $ret = $self->remove_comments() ? '' : ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | ( ( not $self->remove_newlines() and $_[0]->{submatches}->[0] =~ /\n/s ) ? "\n" : '' ) . | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | $_[0]->{submatches}->[1] . | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 12 | ▶ | ( ( not $self->remove_newlines() and $_[0]->{submatches}->[2] =~ /\n/s ) ? "\n" : '' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=6 SCAR=17.9
Branch: 3 branches
Condition83%5/6
not $self->remove_newlines and $_[0]{"submatches"}[0] =~ /\n/s
not $self->remove_newlines and $_[0]{"submatches"}[2] =~ /\n/s
MC/DC50%1/2
not $self->remove_newlines and $_[0]{"submatches"}[0] =~ /\n/s
not $self->remove_newlines
$_[0]{"submatches"}[0] =~ /\n/s
MC/DC100%2/2
not $self->remove_newlines and $_[0]{"submatches"}[2] =~ /\n/s
not $self->remove_newlines
$_[0]{"submatches"}[2] =~ /\n/s
Truth table66%2/3
not(A) and B
A= not $self->remove_newlinesB= $_[0]{"submatches"}[0] =~ /\n/s
Truth table100%3/3
not(A) and B
A= not $self->remove_newlinesB= $_[0]{"submatches"}[2] =~ /\n/s
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 12 | return $ret; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | regexp => $DONT_CLEAN, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | replacement => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 5 | ▶ | return '<!--~' . $_[0]->{store_index} . '~-->'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | store => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 5 | ▶ | my ( $opening, undef, $content, $closing ) = @{$_[0]->{submatches}}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=14 SCAR=32.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 5 | ▶ | if ( $content ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 5 | ▶ | my $opening_script_re = '<\s*script' . ( $self->html5() ? '[^>]*>' : '[^>]*(?:java|ecma)script[^>]*>' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 5 | ▶ | my $opening_style_re = '<\s*style' . ( $self->html5() ? '[^>]*>' : '[^>]*text\/css[^>]*>' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 5 | ▶ | if ( $opening =~ /$opening_script_re/i ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 3 | ▶ | $opening =~ s/ type="(text\/)?(java|ecma)script"//i if ( $self->html5() ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 3 | ▶ | if ( $self->javascript_packer() and $self->do_javascript() ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->javascript_packer and $self->do_javascript
MC/DC0%0/2
$self->javascript_packer and $self->do_javascript
$self->javascript_packer
$self->do_javascript
Truth table33%1/3
A and B
A= $self->javascript_packerB= $self->do_javascript
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 0 | $self->javascript_packer()->minify( \$content, { compress => $self->do_javascript() } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 0 | ▶ | unless ( $self->html5() ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 0 | $content = '/*<![CDATA[*/' . $content . '/*]]>*/'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | elsif ( $opening =~ /$opening_style_re/i ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 2 | ▶ | $opening =~ s/ type="text\/css"//i if ( $self->html5() ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 2 | ▶ | if ( $self->css_packer() and $self->do_stylesheet() ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->css_packer and $self->do_stylesheet
MC/DC0%0/2
$self->css_packer and $self->do_stylesheet
$self->css_packer
$self->do_stylesheet
Truth table33%1/3
A and B
A= $self->css_packerB= $self->do_stylesheet
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 0 | $self->css_packer()->minify( \$content, { compress => $self->do_stylesheet() } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 0 | ▶ | $content = "\n" . $content if ( $self->do_stylesheet() eq 'pretty' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 0 | $content = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 5 | $self->reggrp_whitespaces()->exec( \$opening ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 5 | $self->reggrp_whitespaces()->exec( \$closing ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 5 | return $opening . $content . $closing; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 8 | modifier => 'ism' | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | $self->{void_elements}->{reggrp_data} = [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | regexp => '<\s*((?:' . join( '|', @VOID_ELEMENTS ) . ')\b[^>]*)\s*\/>', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | replacement => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 2 | ▶ | return '<' . $_[0]->{submatches}->[0] . '>'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 8 | modifier => 'ism' | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 8 | foreach ( @HTML::Packer::REGGRPS ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 32 | $self->{ '_reggrp_' . $_ } = Regexp::RegGrp->new( { reggrp => $self->{$_}->{reggrp_data} } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | $self->{ '_reggrp_' . $GLOBAL_REGGRP } = Regexp::RegGrp->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | reggrp => $self->{$GLOBAL_REGGRP}->{reggrp_data}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 8 | restore_pattern => qr/<!--~(\d+)~-->/ | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 8 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | sub minify { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 13 | ▶ | my ( $self, $input, $opts ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
minify: called CC=20 SCAR=35.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 13 | ▶ | unless ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
ref $_[0] and ref $_[0] eq __PACKAGE__
MC/DC0%0/2
ref $_[0] and ref $_[0] eq __PACKAGE__
ref $_[0]
ref $_[0] eq __PACKAGE__
Truth table33%1/3
A and B
A= ref $_[0]B= ref $_[0] eq __PACKAGE__
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | ref( $_[0] ) and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | ref( $_[0] ) eq __PACKAGE__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 0 | $self = __PACKAGE__->init(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 0 | ▶ | shift( @_ ) unless ( ref( $_[0] ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 0 | ( $input, $opts ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 13 | ( $self, $input, $opts ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 13 | ▶ | if ( ref( $input ) ne 'SCALAR' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 0 | carp( 'First argument must be a scalarref!' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 13 | my $html; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 13 | my $cont = 'void'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 13 | ▶ | if ( defined( wantarray ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 0 | ▶ | my $tmp_input = ref( $input ) ? ${$input} : $input; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 0 | $html = \$tmp_input; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 0 | $cont = 'scalar'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 13 | ▶ | $html = ref( $input ) ? $input : \$input; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 13 | ▶ | if ( ref( $opts ) eq 'HASH' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 13 | foreach my $field ( @BOOLEAN_ACCESSORS ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 52 | ▶ | $self->$field( $opts->{$field} ) if ( defined( $opts->{$field} ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 13 | ▶ | $self->do_javascript( $opts->{do_javascript} ) if ( defined( $opts->{do_javascript} ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 13 | ▶ | $self->do_stylesheet( $opts->{do_stylesheet} ) if ( defined( $opts->{do_stylesheet} ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 13 | ▶ | if ( not $self->no_compress_comment() and ${$html} =~ /$PACKER_COMMENT/s ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not $self->no_compress_comment and ${$html;} =~ /$PACKER_COMMENT/s
MC/DC100%2/2
not $self->no_compress_comment and ${$html;} =~ /$PACKER_COMMENT/s
not $self->no_compress_comment
${$html;} =~ /$PACKER_COMMENT/s
Truth table100%3/3
not(A) and B
A= not $self->no_compress_commentB= ${$html;} =~ /$PACKER_COMMENT/s
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 1 | my $compress = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 1 | ▶ | if ( $compress eq '_no_compress_' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 1 | ▶ | return ( $cont eq 'scalar' ) ? ${$html} : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 12 | $self->reggrp_global()->exec( $html ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 12 | $self->reggrp_whitespaces()->exec( $html ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 12 | ▶ | if ( $self->remove_newlines() ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 9 | $self->reggrp_newlines_tags()->exec( $html ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 9 | $self->reggrp_newlines()->exec( $html ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 12 | ▶ | if ( $self->html5() ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 4 | $self->reggrp_void_elements()->exec( $html ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 12 | $self->reggrp_global()->restore_stored( $html ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 12 | ▶ | return ${$html} if ( $cont eq 'scalar' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | sub javascript_packer { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 4 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
javascript_packer: called CC=3 SCAR=12.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | 4 | ▶ | unless ( $self->{_checked_javascript_packer} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 2 | ▶ | eval "use JavaScript::Packer $REQUIRED_JAVASCRIPT_PACKER;"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 2 | ▶ | unless ( $@ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 0 | $self->{_javascript_packer} = eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 0 | JavaScript::Packer->init(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 2 | $self->{_checked_javascript_packer} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 4 | return $self->{_javascript_packer}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | sub css_packer { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | 3 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
css_packer: called CC=3 SCAR=12.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | 3 | ▶ | unless ( $self->{_checked_css_packer} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | 2 | ▶ | eval "use CSS::Packer $REQUIRED_CSS_PACKER;"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 2 | ▶ | unless ( $@ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 0 | $self->{_css_packer} = eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 0 | CSS::Packer->init(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 2 | $self->{_checked_css_packer} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | 3 | return $self->{_css_packer}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 3 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||