DokuWikiFCK.pm

filter: Statementstmt 4.0% 31 / 769 Branchbran 0.0% 0 / 400 Conditioncond 0.0% 0 / 138 MC/DCmcdc 0.0% 0 / 79 Subroutinesub 11.3% 5 / 44 Podpod 7.6% 1 / 13 totaltotal 2.5% 37 / 1443 CC 264 SCAR 62.2
CC
264
Cov
2%
_get_type
1332.0
_link
1190.0
_p_alignment
702.0
CRAP 504.9
↑ Summary DokuWikiFCKN.pm »
1 package HTML::WikiConverter::DokuWikiFCK;
2  
3 #
4 #
5 # DokuWikFCK - A WikiCoverter Dialect for interfacing DokuWiki
6 # and the FCKEditor (http://www.fckeditor.net)
7 # which seeks to implement the graphic features of FCKEditor
8 #
9 # Myron Turner <turnermm02@shaw.ca>
10 #
11 # GNU General Public License Version 2 or later (the "GPL")
12 # http://www.gnu.org/licenses/gpl.html
13 #
14 #
15  
16 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 1 ▶use base 'HTML::WikiConverter::DokuWiki';
Subroutine BEGIN: called CC=1 SCAR=0.0
19 1 ▶use HTML::Element;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 1 ▶use HTML::Entities;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 1 ▶use Params::Validate ':types';
Subroutine BEGIN: called CC=1 SCAR=0.0
22  
23  
24 1 our $VERSION = '0.32';
25  
26 1 my $SPACEBAR_NUDGING = 0;
27 1 my $color_pattern = qr/
28 ([a-zA-z]+)| #colorname
29 (\#([0-9a-fA-F]{3}|[0-9a-fA-F]{6}))| #colorvalue
30 (rgb\(([0-9]{1,3}%?,){2}[0-9]{1,3}%?\)) #rgb triplet
31 /x;
32
33 1 my $font_pattern = qr//;
34 1 my %style_patterns = ( 'color' => \$color_pattern, 'font' => \$font_pattern );
35  
36 1 my $nudge_char = '&#183;';
37
38 1 my $NL_marker = '~~~';
39 1 my $EOL = '=~=';
40 1 my $code_NL = '-NLn-';
41  
42 1 my %_formats = ( 'b' => '**',
43 'em' => '//',
44 'i' => '//',
45 'u' => '__',
46 'ins' => '__'
47 );
48  
49 1 my %_format_regex = ( 'b' => qr/\*\*/,
50 'em' => qr/\/\//,
51 'i' => qr/\/\//,
52 'u' => qr/__/,
53 'ins' => qr/__/
54 );
55  
56 1 my %_format_esc = ( 'b' => '%%**%%',
57 'em' => '%%//%%',
58 'i' => '%%//%%',
59 'u' => '%%__%%',
60 'ins' => '%%__%%'
61 );
62  
63 1 my %dw_code = ( 'regex' => qr/\'\'/,
64 'esc' => "%%\'\'%%"
65 );
66  
67 1 my $kbd_start = '<font _dummy_/AmerType Md BT,American Typewriter,courier New>';
68 1 my $kbd_end = '</font>';
69  
70  
71 0 ▶sub attributes {
Subroutine attributes: not called CC=1 SCAR=6.9
Pod undocumented
72 return {
73 0 browser => { default => 'IE5', type => SCALAR },
74 group => { default => 'ANY', type => SCALAR },
75 };
76 }
77
78 0 ▶sub new {
Subroutine new: not called CC=2 SCAR=17.9
Pod documented
79 0 my $class = shift;
80 0 my $self = $class->SUPER::new(@_);
81 0 $self->{'strike_out'} = 0; # this prevents deletions from being paragraphed
82 0 $self->{'list_type'} = "";
83 0 $self->{'list_output'} = 0; # tells postprocess_output to clean up lists, if 1
84 0 $self->{'in_table'} = 0;
85 0 $self->{'colspan'} = "";
86 0 $self->{'code'} = 0;
87 0 $self->{'block'} = 0;
88 0 $self->{'share'} = 0;
89 0 $self->{'do_nudge'} = $SPACEBAR_NUDGING;
90  
91 0 ▶ if(!$self->{'do_nudge'}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"do_nudge"}) 0 0 0
92 0 $nudge_char = ' ';
93 }
94 0 $self->{'err'} = "NOERR\n";
95 0 $self->{'_fh'} = 0; # turn off debugging
96 # $self->{'_fh'} = getFH();
97 0 $self->{'os'} = $^O;
98 0 return $self;
99 }
100  
101  
102  
103  
104 0 ▶sub getFH {
Subroutine getFH: not called CC=2 SCAR=17.9
Pod undocumented
105 0 my($self) = @_;
106 0 local *FH;
107 # if(open(FH, '>> C:\\Windows\\Temp\\dwfckg.log')) {
108 0 ▶ if(open(FH, ">> /var/tmp/dwfckg.log")) {
Branch: 1 branch
BranchTrueFalseTotal
if (open FH, ">> /var/tmp/dwfckg.log") 0 0 0
109 0 return *FH;
110 }
111 0 $self->{'err'} = "$! \n";
112 0 return 0;
113 }
114  
115  
116  
117 0 ▶sub rules {
Subroutine rules: not called CC=3 SCAR=24.8
Pod undocumented
118 0 my $self = shift;
119 0 my $rules = $self->SUPER::rules();
120
121 0 $rules->{ 'span' } = { replace => \&_span_contents };
122 0 $rules->{ 'p' } = {replace => \&_p_alignment };
123 0 $rules->{ 'div' } = {replace => \&_p_alignment };
124 0 $rules->{ 'img' } = {replace => \&_image };
125 0 $rules->{ 'a' } = { replace => \&_link };
126 0 $rules->{ 'blockquote' } = { replace => \&_block };
127 0 $rules->{ 'pre' } = { replace => \&_code_types };
128 0 $rules->{ 'var' } = { start => '//', end => '//' };
129  
130 0 $rules->{ 'address' } = { start => '//', end => '//' };
131 0 $rules->{ 'strike' } = { start => '<del>', end => '</del>' };
132 0 $rules->{ 'cite' } = { start => '//', end => '//' };
133 0 $rules->{ 'del' } = { alias => 'strike' };
134  
135 0 $rules->{ 'kbd' } = { start => $kbd_start, end => $kbd_end };
136 0 $rules->{ 'tt' } = { start => '<font 120%/sans-serif>', end => '</font>' };
137 0 $rules->{ 'samp' } = { start => '<font 120%/courier New>', end => '</font>' };
138 0 $rules->{ 'q' } = { start => '"', end => '"' };
139 0 $rules->{ 'li' } = { replace => \&_li_start };
140 $rules->{ 'ul' } = { line_format => 'multi', block => 1, line_prefix => ' ',
141 end => "\n<align left></align>\n" },
142 0 $rules->{ 'ol' } = { alias => 'ul' };
143 0 $rules->{ 'hr' } = { replace => "$NL_marker\n----${NL_marker}\n" };
144  
145 0 ▶ if($self->{'do_nudge'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'do_nudge'}) { } 0 0 0
146 0 $rules->{ 'indent' } = { replace => \&_indent };
147 }
148 else {
149 0 $rules->{ 'indent' } = { preserve => 1 };
150 }
151 0 $rules->{ 'dwfckg' } = { preserve => 1 };
152 0 $rules->{ 'header' } = { preserve => 1 };
153 0 $rules->{ 'td' } = { replace => \&_td_start };
154 0 $rules->{ 'th' } = { alias => 'td' };
155 0 $rules->{ 'tr' } = { start => "$NL_marker\n", line_format => 'single', end => \&_row_end };
156 0 for( 1..5 ) {
157 0 $rules->{"h$_"} = { replace => \&_header };
158 }
159 0 $rules->{'plugin'} = { replace => \&_plugin};
160 # $rules->{ 'table' } = { start =>"<align left></align>", end => "<align left><br /></align>" };
161 0 $rules->{ 'table' } = { replace => \&_table };
162 0 $rules->{'ins'} = { alias => 'u'};
163 0 $rules->{'b'} = { replace => \&_formats };
164 0 $rules->{'i'} = { replace => \&_formats };
165 0 $rules->{'u'} = { replace => \&_formats };
166
167 0 $rules->{'sup'} = { replace => \&_sup };
168  
169 0 return $rules;
170
171 }
172  
173  
174 0 ▶sub _formats {
Subroutine _formats: not called CC=5 SCAR=34.0
175 0 my($self, $node, $rules ) = @_;
176  
177 0 my $text = $self->get_elem_contents($node);
178  
179 # $text = $self->trim($text);
180 0 ▶ return "" if ! $text;
Branch: 1 branch
BranchTrueFalseTotal
unless $text 0 0 0
181 0 ▶ return "" if $text !~ /[\p{IsDigit}\p{IsAlpha}\p{IsXDigit}\\]/;
Branch: 1 branch
BranchTrueFalseTotal
unless $text =~ /[\p{IsDigit}\p{IsAlpha}\p{IsXDigit}\\]/ 0 0 0
182  
183 0 my @count = $text =~ /\\/g;
184 0 ▶ if(scalar @count) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @count) 0 0 0
185 0 my $count = scalar @count;
186 0 $text = "_<em_>dwfckgBACKSLASH_<em_>" x $count;
187 0 return $text;
188 }
189 0 $text =~ s/^$_format_regex{$node->tag}//;
190 0 $text =~ s/$_format_regex{$node->tag}$//;
191
192 0 my $tag = $node->tag;
193
194 0 ▶ $tag = 'b' if $tag eq 'strong';
Branch: 1 branch
BranchTrueFalseTotal
if $tag eq "strong" 0 0 0
195
196 0 return ("_<". $tag . "_>". $text . "_<" . $tag . "_>");
197
198 }
199  
200 0 ▶sub _plugin {
Subroutine _plugin: not called CC=5 SCAR=34.0
201 0 my($self, $node, $rules ) = @_;
202 0 my $text = $self->get_elem_contents($node); # text is the plugin pattern
203
204 0 $text = $self->trim($text);
205 0 ▶ return "" if !$text;
Branch: 1 branch
BranchTrueFalseTotal
unless $text 0 0 0
206  
207 0 my $title = $node->attr('title');
208 0 $title=$self->trim($title);
209 0 ▶ if(!$title) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($title) 0 0 0
210 0 return "";
211 }
212  
213 0 ▶ $text =~ s/((&lt;)+)/~$1~/g if $text !~ /[~]&lt;/;
Branch: 1 branch
BranchTrueFalseTotal
unless $text =~ /[~]&lt;/ 0 0 0
214 0 ▶ $text =~ s/((&gt;)+)/~$1~/g if $text !~ /&gt;[~]/;
Branch: 1 branch
BranchTrueFalseTotal
unless $text =~ /&gt;[~]/ 0 0 0
215  
216 0 return '<plugin title="' . $title . '">' . "$text</plugin>";
217 }
218  
219  
220 0 ▶sub _row_end {
Subroutine _row_end: not called CC=2 SCAR=17.9
221 0 my($self, $node, $rules ) = @_;
222  
223 0 ▶ if($self->{'colspan'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"colspan"}) 0 0 0
224 0 return $self->{'colspan'};
225 }
226 0 $self->{'colspan'} = ""
227 }
228  
229  
230 0 ▶sub _td_start {
Subroutine _td_start: not called CC=22 SCAR=62.3
231 0 my($self, $node, $rules ) = @_;
232 0 my $text = $self->get_elem_contents($node);
233  
234 0 $text =~ s/\<br\>\s*$//m; # for Word tables pasted into editor
235 0 $text =~ s/\<br\>\s*/<br \/>/gm;
236 0 $text =~ s/\\\\/<br \/>/gm; # see _p_alignment() comment
237 0 $text =~ s/&lt;/dwfckgTableOpenBRACKET/gm;
238 0 $self->{'colspan'} = "";
239 0 my $prefix = $self->SUPER::_td_start($node, $rules);
240  
241 0 $self->{'in_table'} = 1;
242 0 ▶ $self->{'colspan'} = $node->attr('colspan') || "";
Condition0%0/2
$node->attr('colspan') || ''
l!l
00
MC/DC0%0/1
$node->attr('colspan') || ''
$node->attr('colspan')
Truth table0%0/2
A
A= $node->attr('colspan')
Aresult
11
00
243  
244 0 my $td_backcolor = "";
245 0 my %table_header = $self->_get_type($node, ['th', 'th'], 'font');
246  
247 0 ▶ my $align = $node->attr('align') || 'left';
Condition0%0/2
$node->attr('align') || 'left'
l!l
00
MC/DC0%0/1
$node->attr('align') || 'left'
$node->attr('align')
Truth table0%0/2
A
A= $node->attr('align')
Aresult
11
00
248 0 $align =~ /^(\w)\w+/;
249 0 $align = uc($1);
250  
251  
252  
253 0 ▶ if(!%table_header && $prefix !~ /\s*\^\s/) {
Branch: 1 branch
BranchTrueFalseTotal
if (not %table_header || $prefix =~ /\s*\^\s/) { } 0 0 0
Condition0%0/3
%table_header || $prefix =~ /\s*\^\s/
l!l&&r!l&&!r
000
MC/DC0%0/2
%table_header || $prefix =~ /\s*\^\s/
%table_header $prefix =~ /\s*\^\s/
Truth table0%0/3
A || B
A= %table_headerB= $prefix =~ /\s*\^\s/
ABresult
1X1
011
000
254 0 ▶ my $style = $node->attr('style') || '';
Condition0%0/2
$node->attr('style') || ''
l!l
00
MC/DC0%0/1
$node->attr('style') || ''
$node->attr('style')
Truth table0%0/2
A
A= $node->attr('style')
Aresult
11
00
255 0 ▶ if($style) {
Branch: 1 branch
BranchTrueFalseTotal
if ($style) { } 0 0 0
256 0 my @styles = split ';', $style;
257 0 my $td_w; my $td_bg; my $td_a; my $back_color = ""; my $td_width = "";
258 0 foreach my $s (@styles) {
259 0 ▶ if($s =~ /background-color/) {
Branch: 3 branches
BranchTrueFalseTotal
if ($s =~ /background-color/) { } 0 0 0
elsif ($s =~ /width/) { } 0 0 0
elsif ($s =~ /text-align/) { } 0 0 0
260 0 $td_bg = $s;
261 }
262 elsif($s =~ /width/) {
263 0 $td_w = $s;
264 }
265 elsif($s =~ /text-align/) {
266 0 $td_a = $s;
267 }
268 }
269 0 ▶ $back_color = $self->_extract_style_value($td_bg, 'background-color') if $td_bg;
Branch: 1 branch
BranchTrueFalseTotal
if $td_bg 0 0 0
270  
271 0 ▶ $td_width = $self->_extract_style_value($td_w, 'width') if $td_w;
Branch: 1 branch
BranchTrueFalseTotal
if $td_w 0 0 0
272
273 0 ▶ if(($align eq 'L') && ($td_a = $self->_extract_style_value($td_a, 'text-align'))) {
Branch: 1 branch
BranchTrueFalseTotal
if ($align eq "L" and $td_a = $self->_extract_style_value($td_a, "text-align")) 0 0 0
Condition0%0/3
$align eq "L" and $td_a = $self->_extract_style_value($td_a, "text-align")
!ll&&!rl&&r
000
MC/DC0%0/2
$align eq "L" and $td_a = $self->_extract_style_value($td_a, "text-align")
$align eq "L" $td_a = $self->_extract_style_value($td_a, "text-align")
Truth table0%0/3
A and B
A= $align eq "L"B= $td_a = $self->_extract_style_value($td_a, "text-align")
ABresult
0X0
100
111
274 0 $td_a =~ /^(\w)\w+/;
275 0 $align = uc($1);
276 }
277  
278 0 ▶ if($back_color || $td_width || $align) {
Branch: 1 branch
BranchTrueFalseTotal
if ($back_color or $td_width or $align) 0 0 0
Condition0%0/6
$back_color or $td_width or $align
l!l&&r!l&&!r
000
$back_color or $td_width
l!l&&r!l&&!r
000
MC/DC0%0/3
$back_color or $td_width or $align
$back_color $td_width $align
Truth table0%0/4
A or B or C
A= $back_colorB= $td_widthC= $align
ABCresult
1XX1
01X1
0011
0000
279 0 $td_backcolor = " #$align" . $back_color . $td_width . '# ';
280 }
281 }
282 else {
283 0 $align = "#$align#";
284 }
285 }
286 else {
287 0 $align = ""; $td_backcolor = "";
288 }
289  
290  
291  
292 0 ▶ if(%table_header) {
Branch: 1 branch
BranchTrueFalseTotal
if (%table_header) 0 0 0
293
294 0 ▶ if($table_header{'th'} =~ 'th') {
Branch: 1 branch
BranchTrueFalseTotal
if ($table_header{'th'} =~ /th/) { } 0 0 0
295 0 $prefix = ' ^ ' ;
296
297 }
298 else {
299 0 $prefix = ' | ' ;
300 }
301  
302 0 $text = $self->trim($text);
303 }
304  
305  
306 0 my $suffix = $self->_td_end($node,$rules);
307  
308 0 ▶ if($self->{'colspan'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"colspan"}) 0 0 0
309 0 $self->{'colspan'} = chop $suffix; # save suffix marker for _row_end
310
311 }
312
313 0 $text =~ s/\n/ /gm;
314  
315 0 ▶ $td_backcolor = $align if !$td_backcolor;
Branch: 1 branch
BranchTrueFalseTotal
unless $td_backcolor 0 0 0
316  
317 0 return $prefix . $td_backcolor . $text . $suffix;
318
319 }
320  
321  
322 0 ▶sub _extract_values {
Subroutine _extract_values: not called CC=4 SCAR=30.0
323 0 my ($self, $attr, $values) = @_;
324 0 my $HTML_Elements = scalar @$values;
325  
326 0 ▶ return $values->[0]->{$attr} if exists $values->[0]->{$attr};
Branch: 1 branch
BranchTrueFalseTotal
if exists $values->[0]{$attr} 0 0 0
327  
328 0 $HTML_Elements--;
329 0 ▶ if($HTML_Elements) {
Branch: 1 branch
BranchTrueFalseTotal
if ($HTML_Elements) 0 0 0
330 0 ▶ return $values->[$HTML_Elements]->{$attr} if exists $values->[$HTML_Elements]->{$attr};
Branch: 1 branch
BranchTrueFalseTotal
if exists $values->[$HTML_Elements]{$attr} 0 0 0
331 }
332
333 0 return "";
334 }
335  
336 0 ▶sub _extract_style_value {
Subroutine _extract_style_value: not called CC=3 SCAR=24.8
337 0 my($self, $at, $search_term) = @_;
338  
339 0 my($attribute, $value) = split /:/, $at;
340  
341 0 $attribute =~ s/^\s+//;
342 0 $attribute =~ s/\s+$//;
343  
344 0 $value =~ s/^\s+//;
345 0 $value =~ s/\s+$//;
346  
347 0 ▶ return $value if $search_term && $attribute eq $search_term;
Branch: 1 branch
BranchTrueFalseTotal
if $search_term and $attribute eq $search_term 0 0 0
Condition0%0/3
$search_term and $attribute eq $search_term
!ll&&!rl&&r
000
MC/DC0%0/2
$search_term and $attribute eq $search_term
$search_term $attribute eq $search_term
Truth table0%0/3
A and B
A= $search_termB= $attribute eq $search_term
ABresult
0X0
100
111
348 0 return 0;
349 }
350  
351  
352 0 ▶sub _get_type {
Subroutine _get_type: not called CC=36 SCAR=71.9
353 0 my ($self, $node, $attrs,$type) = @_;
354  
355 0 my $valuepat = ${$style_patterns{$type}};
356 0 my %ret_values=();
357  
358  
359 0 my @values_1 = $node->look_down($attrs->[0], $valuepat);
360 0 ▶ if(@values_1) {
Branch: 1 branch
BranchTrueFalseTotal
if (@values_1) 0 0 0
361 0 my $retv = $self->_extract_values($attrs->[0],\@values_1);
362 0 ▶ if($retv) {
Branch: 1 branch
BranchTrueFalseTotal
if ($retv) 0 0 0
363 0 $ret_values{$attrs->[0]} = $retv;
364 }
365 }
366
367
368 0 ▶ my @values_2 = $node->look_down($attrs->[1], $valuepat) if scalar @$attrs == 2;
Branch: 1 branch
BranchTrueFalseTotal
if scalar @$attrs == 2 0 0 0
369  
370 0 ▶ if(@values_2) {
Branch: 1 branch
BranchTrueFalseTotal
if (@values_2) 0 0 0
371 0 my $retv = $self->_extract_values($attrs->[1],\@values_2);
372 0 ▶ if($retv) {
Branch: 1 branch
BranchTrueFalseTotal
if ($retv) 0 0 0
373 0 $ret_values{$attrs->[1]} = $retv;
374 }
375 }
376  
377 0 ▶ if(!exists $ret_values{$attrs->[1]} || !exists $ret_values{$attrs->[0]}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $ret_values{$attrs->[1]} and exists $ret_values{$attrs->[0]}) 0 0 0
Condition0%0/3
exists $ret_values{$attrs->[1]} and exists $ret_values{$attrs->[0]}
!ll&&!rl&&r
000
MC/DC0%0/2
exists $ret_values{$attrs->[1]} and exists $ret_values{$attrs->[0]}
exists $ret_values{$attrs->[1]} exists $ret_values{$attrs->[0]}
Truth table0%0/3
A and B
A= exists $ret_values{$attrs->[1]}B= exists $ret_values{$attrs->[0]}
ABresult
0X0
100
111
378 0 my @style_values = $node->look_down('style',$font_pattern);
379 0 ▶ if(@style_values) {
Branch: 1 branch
BranchTrueFalseTotal
if (@style_values) 0 0 0
380 0 my $retv = $self->_extract_values('style',\@style_values);
381
382 0 ▶ if(!exists $ret_values{$attrs->[0]}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $ret_values{$attrs->[0]}) 0 0 0
383 0 my $attr_val =$self->_extract_style_value($retv, $attrs->[0]);
384 0 ▶ if($attr_val) {
Branch: 1 branch
BranchTrueFalseTotal
if ($attr_val) 0 0 0
385 0 $ret_values{$attrs->[0]} = $attr_val;
386 }
387 }
388 0 ▶ if($attrs->[1] && !exists $ret_values{$attrs->[1]}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($attrs->[1] and not exists $ret_values{$attrs->[1]}) 0 0 0
Condition0%0/3
$attrs->[1] and not exists $ret_values{$attrs->[1]}
!ll&&!rl&&r
000
MC/DC0%0/2
$attrs->[1] and not exists $ret_values{$attrs->[1]}
$attrs->[1] not exists $ret_values{$attrs->[1]}
Truth table0%0/3
A and not(B)
A= $attrs->[1]B= not exists $ret_values{$attrs->[1]}
ABresult
0X0
100
111
389 0 my $attr_val =$self->_extract_style_value($retv, $attrs->[1]);
390 0 ▶ if($attr_val) {
Branch: 1 branch
BranchTrueFalseTotal
if ($attr_val) 0 0 0
391 0 $ret_values{$attrs->[1]} = $attr_val;
392 }
393 }
394
395 }
396 }
397  
398  
399  
400 0 ▶ if(!exists $ret_values{$attrs->[0]}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $ret_values{$attrs->[0]}) 0 0 0
401 0 my @values_1a = $node->look_up($attrs->[0], $valuepat);
402 0 ▶ if(@values_1a) {
Branch: 1 branch
BranchTrueFalseTotal
if (@values_1a) 0 0 0
403 0 my $retv = $self->_extract_values($attrs->[0],\@values_1a);
404 0 ▶ if($retv) {
Branch: 1 branch
BranchTrueFalseTotal
if ($retv) 0 0 0
405 0 $ret_values{$attrs->[0]} = $retv;
406 }
407 }
408 }
409
410 0 ▶ if($attrs->[1] && !exists $ret_values{$attrs->[1]}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($attrs->[1] and not exists $ret_values{$attrs->[1]}) 0 0 0
Condition0%0/3
$attrs->[1] and not exists $ret_values{$attrs->[1]}
!ll&&!rl&&r
000
MC/DC0%0/2
$attrs->[1] and not exists $ret_values{$attrs->[1]}
$attrs->[1] not exists $ret_values{$attrs->[1]}
Truth table0%0/3
A and not(B)
A= $attrs->[1]B= not exists $ret_values{$attrs->[1]}
ABresult
0X0
100
111
411 0 my @values_2a = $node->look_up($attrs->[1], $valuepat);
412 0 ▶ if(@values_2a) {
Branch: 1 branch
BranchTrueFalseTotal
if (@values_2a) 0 0 0
413 0 my $retv = $self->_extract_values($attrs->[1],\@values_2a);
414 0 ▶ if($retv) {
Branch: 1 branch
BranchTrueFalseTotal
if ($retv) 0 0 0
415 0 $ret_values{$attrs->[1]} = $retv;
416 }
417 }
418 }
419
420 0 ▶ if(!exists $ret_values{$attrs->[0]}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $ret_values{$attrs->[0]}) 0 0 0
421 0 my @values_3 = $node->attr_get_i($attrs->[0]);
422 0 foreach my $val(@values_3) {
423 0 $ret_values{$attrs->[0]} = $val; # if there is a hit, take the first one, there
424 0 last; # shouldn't be more
425 }
426 }
427
428 0 ▶ if($attrs->[1] && !exists $ret_values{$attrs->[1]}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($attrs->[1] and not exists $ret_values{$attrs->[1]}) 0 0 0
Condition0%0/3
$attrs->[1] and not exists $ret_values{$attrs->[1]}
!ll&&!rl&&r
000
MC/DC0%0/2
$attrs->[1] and not exists $ret_values{$attrs->[1]}
$attrs->[1] not exists $ret_values{$attrs->[1]}
Truth table0%0/3
A and not(B)
A= $attrs->[1]B= not exists $ret_values{$attrs->[1]}
ABresult
0X0
100
111
429 0 my @values_4 = $node->attr_get_i($attrs->[1]);
430 0 foreach my $val(@values_4) {
431  
432 0 $ret_values{$attrs->[1]} = $val;
433 0 last; # ditto to above
434 }
435 }
436  
437  
438 0 ▶ if(!exists $ret_values{$attrs->[1]} || !exists $ret_values{$attrs->[0]}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $ret_values{$attrs->[1]} and exists $ret_values{$attrs->[0]}) 0 0 0
Condition0%0/3
exists $ret_values{$attrs->[1]} and exists $ret_values{$attrs->[0]}
!ll&&!rl&&r
000
MC/DC0%0/2
exists $ret_values{$attrs->[1]} and exists $ret_values{$attrs->[0]}
exists $ret_values{$attrs->[1]} exists $ret_values{$attrs->[0]}
Truth table0%0/3
A and B
A= exists $ret_values{$attrs->[1]}B= exists $ret_values{$attrs->[0]}
ABresult
0X0
100
111
439 0 my @values_5 = $node->attr_get_i("style");
440 0 foreach my $at(@values_5) {
441  
442 0 ▶ if(!exists $ret_values{$attrs->[0]}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $ret_values{$attrs->[0]}) 0 0 0
443 0 ▶ if($at =~ /$attrs->[0]/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($at =~ /$attrs->[0]/) 0 0 0
444 0 my $attr_val =$self->_extract_style_value($at,$attrs->[0]);
445 0 ▶ if($attr_val) {
Branch: 1 branch
BranchTrueFalseTotal
if ($attr_val) 0 0 0
446 0 $ret_values{$attrs->[0]} = $attr_val;
447 0 last;
448 }
449 }
450 }
451  
452 0 ▶ if($attrs->[1] && !exists $ret_values{$attrs->[1]}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($attrs->[1] and not exists $ret_values{$attrs->[1]}) 0 0 0
Condition0%0/3
$attrs->[1] and not exists $ret_values{$attrs->[1]}
!ll&&!rl&&r
000
MC/DC0%0/2
$attrs->[1] and not exists $ret_values{$attrs->[1]}
$attrs->[1] not exists $ret_values{$attrs->[1]}
Truth table0%0/3
A and not(B)
A= $attrs->[1]B= not exists $ret_values{$attrs->[1]}
ABresult
0X0
100
111
453 0 ▶ if($at =~ /$attrs->[1]/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($at =~ /$attrs->[1]/) 0 0 0
454 0 my $attr_val =$self->_extract_style_value($at, $attrs->[1]);
455 0 ▶ if($attr_val) {
Branch: 1 branch
BranchTrueFalseTotal
if ($attr_val) 0 0 0
456 0 $ret_values{$attrs->[1]} = $attr_val;
457 0 last;
458 }
459 }
460 }
461
462 }
463 }
464
465
466 0 return %ret_values;
467 }
468  
469  
470  
471  
472 0 ▶sub _span_contents {
Subroutine _span_contents: not called CC=21 SCAR=61.4
473 0 my($self, $node, $rules ) = @_;
474  
475 0 my $text = $self->get_elem_contents($node);
476 0 my $current_text = ""; # used where more than one span occurs in the markup retrieved as $text
477  
478 0 ▶ if($text =~ /^\s*<(color|font).*?\/(color|font)/) {
Branch: 2 branches
BranchTrueFalseTotal
if ($text =~ m[^\s*<(color|font).*?/(color|font)]) { } 0 0 0
elsif ($text =~ m[(.*?)<(color|font).*?/(color|font)]) { } 0 0 0
479 0 return $text;
480 }
481  
482 elsif($text =~ /(.*?)<(color|font).*?\/(color|font)/) {
483 0 $current_text = $1;
484 0 my $tmp = $current_text;
485 0 $tmp =~ s/([*\/\-'"{\[\]\(\)])/\\$1/gms; # escape regex pattern characters
486 0 $text =~ s/^$tmp//;
487 0 $current_text = $self->trim($current_text);
488 }
489
490  
491 0 my %color_atts = $self->_get_type($node, ['color','background-color'], 'color');
492 0 ▶ if(%color_atts) {
Branch: 2 branches
BranchTrueFalseTotal
if (%color_atts) { } 0 0 0
elsif ($current_text) { } 0 0 0
493 0 ▶ my $fg = (exists $color_atts{'color'}) ? ($color_atts{'color'}) : "";
Branch: 1 branch
BranchTrueFalseTotal
exists $color_atts{'color'} ? : 0 0 0
494 0 ▶ my $bg = (exists $color_atts{'background-color'}) ? ($color_atts{'background-color'}) : "";
Branch: 1 branch
BranchTrueFalseTotal
exists $color_atts{'background-color'} ? : 0 0 0
495  
496 0 ▶ $fg = 'black' if($fg eq 'white' && !$bg);
Branch: 1 branch
BranchTrueFalseTotal
if $fg eq "white" and not $bg 0 0 0
Condition0%0/3
$fg eq "white" and not $bg
!ll&&!rl&&r
000
MC/DC0%0/2
$fg eq "white" and not $bg
$fg eq "white" not $bg
Truth table0%0/3
A and not(B)
A= $fg eq "white"B= not $bg
ABresult
0X0
100
111
497  
498 0 ▶ if($fg eq $bg && $text =~ /<indent/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($fg eq $bg and $text =~ /<indent/) 0 0 0
Condition0%0/3
$fg eq $bg and $text =~ /<indent/
!ll&&!rl&&r
000
MC/DC0%0/2
$fg eq $bg and $text =~ /<indent/
$fg eq $bg $text =~ /<indent/
Truth table0%0/3
A and B
A= $fg eq $bgB= $text =~ /<indent/
ABresult
0X0
100
111
499 0 $fg = '_dummy_';
500 }
501 0 ▶ if($fg eq $bg && $text =~ /<redact/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($fg eq $bg and $text =~ /<redact/) 0 0 0
Condition0%0/3
$fg eq $bg and $text =~ /<redact/
!ll&&!rl&&r
000
MC/DC0%0/2
$fg eq $bg and $text =~ /<redact/
$fg eq $bg $text =~ /<redact/
Truth table0%0/3
A and B
A= $fg eq $bgB= $text =~ /<redact/
ABresult
0X0
100
111
502 0 $fg = '_dummy_';
503 }
504 0 ▶ if($current_text) {
Branch: 1 branch
BranchTrueFalseTotal
if ($current_text) 0 0 0
505 0 $current_text = "<color $fg/$bg>$current_text</color>";
506 }
507 0 $text = "$current_text<color $fg/$bg>$text</color>";
508 }
509  
510 elsif($current_text) {
511
512 }
513  
514 0 my $pat = qr/<color\s+rgb\(\d+, \d+, \d+\)\/rgb\(\d+, \d+, \d+\)>/;
515 0 $text =~ s/($pat)\s*$pat(.*?)<\/color>/$1$2/;
516
517  
518 0 my %font_atts = $self->_get_type($node, ['size', 'face'], 'font');
519 0 ▶ if(%font_atts) {
Branch: 1 branch
BranchTrueFalseTotal
if (%font_atts) 0 0 0
520 0 ▶ my $size = (exists $font_atts{'size'}) ? ($font_atts{'size'}) : "_dummy_";
Branch: 1 branch
BranchTrueFalseTotal
exists $font_atts{'size'} ? : 0 0 0
521 0 ▶ my $face = (exists $font_atts{'face'}) ? ($font_atts{'face'}) : "_dummy_";
Branch: 1 branch
BranchTrueFalseTotal
exists $font_atts{'face'} ? : 0 0 0
522 0 ▶ if($current_text) {
Branch: 1 branch
BranchTrueFalseTotal
if ($current_text) { } 0 0 0
523 0 $text = "<font $size/$face>$current_text</font><font $size/$face>$text</font>";
524 }
525 else {
526 0 $text = "<font $size/$face>$text</font>";
527 }
528 }
529  
530 0 ▶ if(!%font_atts && !%color_atts && $current_text) {
Branch: 1 branch
BranchTrueFalseTotal
if (not %font_atts || %color_atts and $current_text) 0 0 0
Condition0%0/6
not %font_atts || %color_atts and $current_text
!ll&&!rl&&r
000
%font_atts || %color_atts
l!l&&r!l&&!r
000
MC/DC0%0/3
not %font_atts || %color_atts and $current_text
%font_atts %color_atts $current_text
Truth table0%0/4
not(A || B) and C
A= %font_attsB= %color_attsC= $current_text
ABCresult
1XX0
01X0
0000
0011
531 0 $text = "$current_text$text";
532 }
533  
534 0 return $text;
535 }
536  
537 0 ▶sub clean_text {
Subroutine clean_text: not called CC=1 SCAR=6.9
Pod undocumented
538 0 my($self, $text) = @_;
539 0 $text =~ s/<.*?>/ /gs;
540 0 $text =~ s/\s+/ /gs;
541
542 0 return $text;
543 }
544  
545 0 ▶sub _sup {
Subroutine _sup: not called CC=3 SCAR=24.8
546 0 my($self, $node, $rules ) = @_;
547  
548 0 ▶ my $text = $self->get_elem_contents($node) || "";
Condition0%0/2
$self->get_elem_contents($node) || ''
l!l
00
MC/DC0%0/1
$self->get_elem_contents($node) || ''
$self->get_elem_contents($node)
Truth table0%0/2
A
A= $self->get_elem_contents($node)
Aresult
11
00
549 0 ▶ return "" if $text =~ /Anchor/i;
Branch: 1 branch
BranchTrueFalseTotal
if $text =~ /Anchor/i 0 0 0
550 0 $text = $self->trim($text);
551 0 return "<sup>$text</sup>";
552  
553 }
554  
555 0 ▶sub _code_types {
Subroutine _code_types: not called CC=3 SCAR=24.8
556 0 my($self, $node, $rules ) = @_;
557 0 ▶ my $text = $self->get_elem_contents($node) || "";
Condition0%0/2
$self->get_elem_contents($node) || ''
l!l
00
MC/DC0%0/1
$self->get_elem_contents($node) || ''
$self->get_elem_contents($node)
Truth table0%0/2
A
A= $self->get_elem_contents($node)
Aresult
11
00
558  
559 0 $text = $self->trim($text);
560 0 $text =~ s/[\\]{2}/\n/g; # required for IE which places <br> at end of each line
561 0 $text =~ s/\n/$NL_marker\n/gms;
562  
563
564 0 $text =~ s/&lt;/dwfckgOpenPAREN/gms; # substitution for open angle bracket
565 0 $text =~ s/\/\*/dwfckgOpen_C_COMMENT/gms;
566 0 $text =~ s/\*\//dwfckgClosed_C_COMMENT/gms;
567
568 0 $text = $self->replace_formats($text);
569  
570 0 $text =~ s/<.*?>/ /gs; # remove all tags
571  
572 0 $text =~ s/(?<![\w[:punct:]:])[\s](?![\w[:punct:]:])/x\00/gms;
573  
574 0 ▶ return "" if ! $text;
Branch: 1 branch
BranchTrueFalseTotal
unless $text 0 0 0
575 0 $self->{'code'} = 1;
576 0 return "$NL_marker\n<code>${NL_marker}\n$text $NL_marker\n</code>\n";
577 }
578  
579  
580 0 ▶sub _li_start {
Subroutine _li_start: not called CC=2 SCAR=17.9
581 0 my($self, $node, $rules ) = @_;
582 0 ▶ my $text = $self->get_elem_contents($node) || "";
Condition0%0/2
$self->get_elem_contents($node) || ''
l!l
00
MC/DC0%0/1
$self->get_elem_contents($node) || ''
$self->get_elem_contents($node)
Truth table0%0/2
A
A= $self->get_elem_contents($node)
Aresult
11
00
583 0 $text =~ s/<align\s*\w*>//gm;
584 0 $text =~ s/<\/align>//gm;
585 0 $text =~ s/^\s*//m;
586 0 $text =~ s/\n{2,}/\n/gm;
587 0 my $type = $self->SUPER::_li_start($node, $rules);
588 0 $self->{'list_output'} = 1; # signal postprocess_output to clean up lists
589 0 return "$NL_marker\n$type" . $text . $EOL;
590 }
591  
592  
593 0 ▶sub _hanging_formats {
Subroutine _hanging_formats: not called CC=3 SCAR=24.8
594 0 my ($self,$str, $search, $format) = @_;
595
596 0 my @matches = $str =~ /$_format_regex{$format}/g;
597
598 0 my $instances = scalar @matches;
599  
600 0 ▶ return $str if($instances % 2 == 0);
Branch: 1 branch
BranchTrueFalseTotal
if $instances % 2 == 0 0 0 0
601 0 ▶ if($instances == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($instances == 1) 0 0 0
602 0 $str =~ s/$_format_regex{$format}/$_format_esc{$format}/;
603
604 0 return $str;
605 }
606  
607 0 return $str;
608 }
609  
610 0 ▶sub replace_formats {
Subroutine replace_formats: not called CC=4 SCAR=30.0
Pod undocumented
611 0 my ($self, $output) = @_;
612  
613 0 my @format_ids = ( 'b', 'i', 'u');
614 0 foreach my $format(@format_ids) {
615 0 ▶ if($output =~ /$_format_regex{$format}/gms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($output =~ /$_format_regex{$format}/gms) 0 0 0
616 0 $output =~ s/(?<!http:)($_format_regex{$format}(.*))/$self->_hanging_formats($1,$2, $format)/mse;
617 }
618 }
619  
620 0 $output =~ s/_<(\w+)_>/$_formats{$1}/g;
621  
622 0 ▶ if($output =~ /$dw_code{'regex'}/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($output =~ /$dw_code{"regex"}/) 0 0 0
623 0 $output =~ s/$dw_code{'regex'}/$dw_code{'esc'}/gms;
624 }
625  
626 0 return $output;
627 }
628  
629 0 ▶sub _p_alignment {
Subroutine _p_alignment: not called CC=26 SCAR=65.5
630 0 my($self, $node, $rules ) = @_;
631
632 0 ▶ my $output = $self->get_elem_contents($node) || "";
Condition0%0/2
$self->get_elem_contents($node) || ''
l!l
00
MC/DC0%0/1
$self->get_elem_contents($node) || ''
$self->get_elem_contents($node)
Truth table0%0/2
A
A= $self->get_elem_contents($node)
Aresult
11
00
633  
634 0 $output =~ s/<[\/]*indent>//gm;
635 0 $output =~ s/^([\s\x{a0}]+)/<indent>$1<\/indent>/m;
636 0 $output =~ s/<indent><\/indent>//;
637 0 $output =~ s/\\\\/<br \/>/gm; # replace \\ with <br /> for p-to-line-break tool
638  
639 0 $output = $self->replace_formats($output);
640  
641 0 ▶ if($output =~ /^\s*[*\-]{1}\s+/gms) {
Branch: 2 branches
BranchTrueFalseTotal
if ($output =~ /^\s*[*\-]{1}\s+/gms) { } 0 0 0
elsif ($output =~ /\<code/) { } 0 0 0
642
643 0 $self->{'list_output'} = 1;
644 0 return "\n $output$EOL";
645 }
646 elsif($output =~/\<code/) {
647 0 return $output;
648 }
649  
650 0 ▶ if($output =~ /<align/gms || $output =~ /<\/align/gms || $output =~ /\{\{.*?\}\}/gms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($output =~ /<align/gms or $output =~ m[</align]gms or $output =~ /\{\{.*?\}\}/gms) 0 0 0
Condition0%0/6
$output =~ /<align/gms or $output =~ m[</align]gms or $output =~ /\{\{.*?\}\}/gms
l!l&&r!l&&!r
000
$output =~ /<align/gms or $output =~ m[</align]gms
l!l&&r!l&&!r
000
MC/DC0%0/3
$output =~ /<align/gms or $output =~ m[</align]gms or $output =~ /\{\{.*?\}\}/gms
$output =~ /<align/gms $output =~ m[</align]gms $output =~ /\{\{.*?\}\}/gms
Truth table0%0/4
A or B or C
A= $output =~ /<align/gmsB= $output =~ m[</align]gmsC= $output =~ /\{\{.*?\}\}/gms
ABCresult
1XX1
01X1
0011
0000
651  
652 0 return $output;
653 }
654  
655  
656 0 ▶ if($node->parent) {
Branch: 1 branch
BranchTrueFalseTotal
if ($node->parent) 0 0 0
657 0 my $tag = $node->parent->tag();
658 0 ▶ if($tag eq 'td') {
Branch: 1 branch
BranchTrueFalseTotal
if ($tag eq "td") 0 0 0
659 0 return $output . "<br>"; ## use <br>, not <br /> so it doesn't getlopped of in postprocess
660 ## converted to <br /> in _td_start and since I don't see
661 ## where it would get lopped off, this could probably be <br />`
662 }
663 }
664  
665
666  
667 0 my $newline = "";
668 0 ▶ if($self->{'do_nudge'} && $output =~ /^\s{3,}/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"do_nudge"} and $output =~ /^\s{3,}/) 0 0 0
Condition0%0/3
$self->{"do_nudge"} and $output =~ /^\s{3,}/
!ll&&!rl&&r
000
MC/DC0%0/2
$self->{"do_nudge"} and $output =~ /^\s{3,}/
$self->{"do_nudge"} $output =~ /^\s{3,}/
Truth table0%0/3
A and B
A= $self->{"do_nudge"}B= $output =~ /^\s{3,}/
ABresult
0X0
100
111
669 0 $newline = "<align 1px></align>";
670 }
671  
672  
673 0 ▶ if($output =~ /^(\s*|([\\][\\]))\s*<indent.*?>.*?<\/indent>\s*$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($output =~ m(^(\s*|([\\][\\]))\s*<indent.*?>.*?</indent>\s*$)) 0 0 0
674 0 return "";
675 }
676  
677 0 ▶ if($self->{'strike_out'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"strike_out"}) 0 0 0
678 0 $self->{'strike_out'} = 0;
679 0 return $output;
680 }
681  
682 0 ▶ my $align = $node->{'style'} if exists $node->{'style'};
Branch: 1 branch
BranchTrueFalseTotal
if exists $node->{"style"} 0 0 0
683
684 0 my $align_tag = "";
685  
686 0 my $aligns_cnt = 0;
687 0 ▶ if($align) { # there have been some styles with multiple attributes, hence this code
Branch: 1 branch
BranchTrueFalseTotal
if ($align) 0 0 0
688 0 ▶ my @styles = split ';', $align if($align);
Branch: 1 branch
BranchTrueFalseTotal
if $align 0 0 0
689 0 foreach my $style(@styles) {
690 0 my ($att, $val) = split ':', $style;
691
692 0 ▶ if ($att && $val)
Branch: 1 branch
BranchTrueFalseTotal
if ($att and $val) 0 0 0
Condition0%0/3
$att and $val
!ll&&!rl&&r
000
MC/DC0%0/2
$att and $val
$att $val
Truth table0%0/3
A and B
A= $attB= $val
ABresult
0X0
100
111
693 {
694 0 $att =~ s/^\s//;
695 0 $att =~ s/\s$//;
696 0 ▶ if($att =~ /(text\-align|margin\-left)/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($att =~ /(text\-align|margin\-left)/) 0 0 0
697 0 $val =~ s/^\s//;
698 0 $val =~ s/\s$//;
699 0 $align_tag .= " <align $val>";
700 0 $aligns_cnt++;
701 }
702 }
703 }
704 }
705
706 0 ▶ if(!$align_tag) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($align_tag) 0 0 0
707 0 $align_tag = "<align>";
708 }
709
710
711  
712 0 $output = "${align_tag}\n${output}\n</align>";
713
714 0 $aligns_cnt--;
715 0 ▶ if($aligns_cnt) {
Branch: 1 branch
BranchTrueFalseTotal
if ($aligns_cnt) 0 0 0
716 0 for(1...$aligns_cnt) {
717 0 $output .= " </align> ";
718 }
719 }
720
721  
722 0 $output=~s/http\:(?!\/\/)/http:\/\//gsm;
723 0 $output =~ s/\/{3,}/\/\//g; # removes extra newline markers at start and end of images
724  
725  
726 0 ▶ if($output =~ s/<align left>[\x{a0}\x{b7}]+<\/align>/<align left><\/align>/gms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($output =~ s[<align left>[\x{a0}\x{b7}]+</align>][<align left></align>]gms) 0 0 0
727 0 return $output;
728 }
729  
730 0 $output =~ s/<align center>[\s\n\x{a0}\x{b7}]+<\/align>//gms;
731 0 $output =~ s/<align right>[\s\n\x{a0}\x{b7}]+<\/align>//gms;
732 0 $output =~ s/<align \d+px>[\s\n\x{a0}\x{b7}]+<\/align>//gms;
733 0 ▶ return "" if(!$output);
Branch: 1 branch
BranchTrueFalseTotal
unless $output 0 0 0
734  
735 0 ▶ if($output =~/<align>[\s\n]*<\/align>/gms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($output =~ m[<align>[\s\n]*</align>]gms) 0 0 0
736 0 $output = '<br />';
737 }
738 0 return $newline . $output;
739 }
740  
741  
742 0 ▶sub _dwimage_markup {
Subroutine _dwimage_markup: not called CC=8 SCAR=42.8
743 0 my ($self, $src, $align) = @_;
744 0 ▶ if($src !~ /^http:/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($src =~ /^http:/) 0 0 0
745 0 $src =~ s/\//:/g;
746 0 ▶ if($src !~ /^:/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($src =~ /^:/) 0 0 0
747 0 $src = ":$src";
748 }
749 }
750  
751 0 ▶ if($align eq 'center') {
Branch: 1 branch
BranchTrueFalseTotal
if ($align eq "center") 0 0 0
752 0 return "\n<align center>\n{{ $src }}\n</align>\n";
753 }
754 0 ▶ if($align eq 'right') {
Branch: 1 branch
BranchTrueFalseTotal
if ($align eq "right") 0 0 0
755 0 return "<align right>\n{{ $src}} </align>";
756 }
757 0 ▶ if($align eq 'left') {
Branch: 1 branch
BranchTrueFalseTotal
if ($align eq "left") 0 0 0
758 0 return "<align left>\n{{$src }}</align>";
759 }
760 0 ▶ if($align =~ /\d+px/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($align =~ /\d+px/) 0 0 0
761 0 return "<align $align>\n{{$src}}\n</align>";
762 }
763  
764 0 ▶ if($align =~ /bottom|baseline/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($align =~ /bottom|baseline/) 0 0 0
765 0 return "<align $align>\n{{$src}}\n</align>";
766 }
767
768 0 return "{{$src}} ";
769 }
770  
771 0 ▶sub _image {
Subroutine _image: not called CC=24 SCAR=64.0
772 0 my($self, $node, $rules ) = @_;
773  
774 0 ▶ my $src = $node->attr('src') || '';
Condition0%0/2
$node->attr('src') || ''
l!l
00
MC/DC0%0/1
$node->attr('src') || ''
$node->attr('src')
Truth table0%0/2
A
A= $node->attr('src')
Aresult
11
00
775  
776 0 ▶ return "" if(!$src);
Branch: 1 branch
BranchTrueFalseTotal
unless $src 0 0 0
777  
778 0 my $alignment = $self->_image_alignment($node);
779 0 ▶ if(!$alignment && $node->parent) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $alignment and $node->parent) 0 0 0
Condition0%0/3
not $alignment and $node->parent
!ll&&!rl&&r
000
MC/DC0%0/2
not $alignment and $node->parent
not $alignment $node->parent
Truth table0%0/3
not(A) and B
A= not $alignmentB= $node->parent
ABresult
0X0
100
111
780 0 $alignment = $self->_image_alignment($node->parent);
781 }
782 0 ▶ my $w = $node->attr('width') || 0;
Condition0%0/2
$node->attr('width') || 0
l!l
00
MC/DC0%0/1
$node->attr('width') || 0
$node->attr('width')
Truth table0%0/2
A
A= $node->attr('width')
Aresult
11
00
783 0 ▶ my $h = $node->attr('height') || 0;
Condition0%0/2
$node->attr('height') || 0
l!l
00
MC/DC0%0/1
$node->attr('height') || 0
$node->attr('height')
Truth table0%0/2
A
A= $node->attr('height')
Aresult
11
00
784  
785 0 ▶ if(!$w) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($w) 0 0 0
786 0 ▶ $w = $node->attr('w') || 0;
Condition0%0/2
$node->attr('w') || 0
l!l
00
MC/DC0%0/1
$node->attr('w') || 0
$node->attr('w')
Truth table0%0/2
A
A= $node->attr('w')
Aresult
11
00
787 }
788 0 ▶ if(!$h) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($h) 0 0 0
789 0 ▶ $h = $node->attr('h') || 0;
Condition0%0/2
$node->attr('h') || 0
l!l
00
MC/DC0%0/1
$node->attr('h') || 0
$node->attr('h')
Truth table0%0/2
A
A= $node->attr('h')
Aresult
11
00
790 }
791  
792 0 ▶ if( $w and $h ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($w and $h) { } 0 0 0
elsif ($w) { } 0 0 0
Condition0%0/3
$w and $h
!ll&&!rl&&r
000
MC/DC0%0/2
$w and $h
$w $h
Truth table0%0/3
A and B
A= $wB= $h
ABresult
0X0
100
111
793 0 $src .= "?${w}x${h}";
794 } elsif( $w ) {
795 0 $src .= "?${w}";
796 }
797  
798 0 ▶ if($src =~ /editor\/images\/smiley\/msn/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($src =~ m[editor/images/smiley/msn]) 0 0 0
799 0 ▶ if($src =~ /media=(http:.*?\.gif)/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($src =~ /media=(http:.*?\.gif)/) { } 0 0 0
800 0 $src = $1;
801  
802 }
803 else {
804 0 my $HOST = $self->base_uri;
805 0 ▶ $src = 'http://' . $HOST . $src if($src !~ /$HOST/);
Branch: 1 branch
BranchTrueFalseTotal
unless $src =~ /$HOST/ 0 0 0
806  
807 }
808  
809 0 return "{{$src}} ";
810 }
811  
812  
813 0 ▶ if($src !~ /userfiles\/image/ && $src !~ /\/data\/media/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($src =~ m[userfiles/image] or $src =~ m[/data/media]) 0 0 0
Condition0%0/3
$src =~ m[userfiles/image] or $src =~ m[/data/media]
l!l&&r!l&&!r
000
MC/DC0%0/2
$src =~ m[userfiles/image] or $src =~ m[/data/media]
$src =~ m[userfiles/image] $src =~ m[/data/media]
Truth table0%0/3
A or B
A= $src =~ m[userfiles/image]B= $src =~ m[/data/media]
ABresult
1X1
011
000
814 0 my @elems = split /=/, $src;
815 0 $src = pop @elems;
816 0 ▶ return $self->_dwimage_markup($src,$alignment) if($src !~ /^http:/);
Branch: 1 branch
BranchTrueFalseTotal
unless $src =~ /^http:/ 0 0 0
817 0 return $self->_dwimage_markup($src,$alignment);
818 }
819  
820  
821 0 ▶ if($src =~ s/^(.*?)\/userfiles\/image\///) {
Branch: 1 branch
BranchTrueFalseTotal
if ($src =~ s[^(.*?)/userfiles/image/][]) 0 0 0
822 0 return $self->_dwimage_markup($src,$alignment);
823 }
824  
825 0 ▶ if($src =~ s/^(.*?)\/data\/media\///) {
Branch: 1 branch
BranchTrueFalseTotal
if ($src =~ s[^(.*?)/data/media/][]) 0 0 0
826 0 return $self->_dwimage_markup($src,$alignment);
827 }
828  
829 0 my $img_url = $self->SUPER::_image($node, $rules);
830  
831 0 $img_url =~ s/%25/%/g;
832 0 $img_url =~ s/%([0-9A-Fa-f]{2})/chr(hex($1))/eg;
833 0 $img_url =~ s/%25/%/g;
834 0 $img_url =~ s/%([0-9A-Fa-f]{2})/chr(hex($1))/eg;
835  
836  
837 0 my @elems = split /media/, $img_url;
838 0 ▶ if (scalar @elems > 2) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @elems > 2) 0 0 0
839 0 my $last_el = pop @elems;
840 0 my $dw_markup = $last_el;
841 0 ▶ if($dw_markup =~ s/^(.*?)userfiles\/image\///) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dw_markup =~ s[^(.*?)userfiles/image/][]) 0 0 0
842 0 return $self->_dwimage_markup($dw_markup, $alignment);
843 }
844 0 $img_url = $elems[0] . 'media' . $last_el;
845 }
846  
847  
848 0 return $img_url;
849
850 }
851  
852 0 ▶sub _image_alignment {
Subroutine _image_alignment: not called CC=10 SCAR=47.0
853 0 my ($self, $node) = @_;
854 0 ▶ my $align = $node->attr('align') || "";
Condition0%0/2
$node->attr('align') || ''
l!l
00
MC/DC0%0/1
$node->attr('align') || ''
$node->attr('align')
Truth table0%0/2
A
A= $node->attr('align')
Aresult
11
00
855 0 ▶ if($align) {
Branch: 1 branch
BranchTrueFalseTotal
if ($align) 0 0 0
856 0 ▶ $align = 'center' if $align eq 'middle';
Branch: 1 branch
BranchTrueFalseTotal
if $align eq "middle" 0 0 0
857 0 return $align;
858 }
859 0 ▶ if($node->parent) {
Branch: 1 branch
BranchTrueFalseTotal
if ($node->parent) 0 0 0
860 0 my $p = $node->parent;
861 0 my %atts = $p->all_external_attr();
862 0 foreach my $at(keys %atts) {
863  
864 0 ▶ if($at eq 'style') {
Branch: 1 branch
BranchTrueFalseTotal
if ($at eq "style") 0 0 0
865  
866 0 ▶ if($atts{$at} =~ /margin-left:\s+(\d+px)/) {
Branch: 3 branches
BranchTrueFalseTotal
if ($atts{$at} =~ /margin-left:\s+(\d+px)/) { } 0 0 0
elsif ($atts{$at} =~ /text-align:\s+(\w+)/) { } 0 0 0
elsif ($atts{$at} =~ /bottom|base/) { } 0 0 0
867 0 return $1;
868 }
869 elsif($atts{$at} =~ /text-align:\s+(\w+)/) {
870 0 return $1;
871 }
872 elsif($atts{$at} =~ /bottom|base/) {
873 0 return 'bottom';
874 }
875  
876 }
877 }
878 }
879  
880 0 return "";
881 }
882  
883  
884 0 ▶sub format_InternalLink {
Subroutine format_InternalLink: not called CC=4 SCAR=30.0
Pod undocumented
885 0 my($self, $node, $file) = @_;
886  
887 0 ▶ my $inner_text = $self->get_elem_contents($node) || "";
Condition0%0/2
$self->get_elem_contents($node) || ''
l!l
00
MC/DC0%0/1
$self->get_elem_contents($node) || ''
$self->get_elem_contents($node)
Truth table0%0/2
A
A= $self->get_elem_contents($node)
Aresult
11
00
888 0 ▶ $file = ":$file" if $file !~/^:/;
Branch: 1 branch
BranchTrueFalseTotal
unless $file =~ /^:/ 0 0 0
889 0 ▶ if($inner_text) {
Branch: 1 branch
BranchTrueFalseTotal
if ($inner_text) 0 0 0
890 0 return "$file|$inner_text";
891 }
892 0 return $file;
893 }
894  
895 0 ▶sub _link {
Subroutine _link: not called CC=34 SCAR=70.8
896 0 my($self, $node, $rules ) = @_;
897 0 ▶ my $url = $node->attr('href') || '';
Condition0%0/2
$node->attr('href') || ''
l!l
00
MC/DC0%0/1
$node->attr('href') || ''
$node->attr('href')
Truth table0%0/2
A
A= $node->attr('href')
Aresult
11
00
898  
899 0 ▶ my $name = $node->attr('name') || '';
Condition0%0/2
$node->attr('name') || ''
l!l
00
MC/DC0%0/1
$node->attr('name') || ''
$node->attr('name')
Truth table0%0/2
A
A= $node->attr('name')
Aresult
11
00
900  
901 0 my $internal_link = "";
902 0 ▶ my $_text = $self->get_elem_contents($node) || "";
Condition0%0/2
$self->get_elem_contents($node) || ''
l!l
00
MC/DC0%0/1
$self->get_elem_contents($node) || ''
$self->get_elem_contents($node)
Truth table0%0/2
A
A= $self->get_elem_contents($node)
Aresult
11
00
903
904 # these manage shares
905 0 ▶ if($url =~ /file:/) {
Branch: 2 branches
BranchTrueFalseTotal
if ($url =~ /file:/) { } 0 0 0
elsif ($url =~ /[\\]{2,}/) { } 0 0 0
906 0 $url =~ s/^file:[\/]+/__SHARE__/;
907 0 $url =~ s/\//\\/g;
908 0 $self->{'share'} = 1;
909 0 return "[[$url|$_text]]";
910 }
911 elsif($url =~/[\\]{2,}/) {
912 0 $url =~ s/^[\/]+//;
913 0 $url =~ s/^[\\]+/__SHARE__/;
914 0 ▶ $_text = $url if(!$_text);
Branch: 1 branch
BranchTrueFalseTotal
unless $_text 0 0 0
915 0 $_text =~ s/\\{2,}/\\/g;
916  
917 0 $self->{'share'} = 1;
918 0 return "[[$url|$_text]]";
919 }
920  
921 0 ▶ if($name) {
Branch: 1 branch
BranchTrueFalseTotal
if ($name) 0 0 0
922 0 return '~~ANCHOR:' . $name . ':::' . $_text .'~~';
923 }
924  
925 0 ▶ if ($url !~ /^\W*http:/ && $url =~ /\/(doku\.php\?id=)?:?((((\w)(\w|_)*)*:)*(\w(\w|_)*)*)$/) {
Branch: 6 branches
BranchTrueFalseTotal
if (not $url =~ /^\W*http:/ and $url =~ m[/(doku\.php\?id=)?:?((((\w)(\w|_)*)*:)*(\w(\w|_)*)*)$]) { } 0 0 0
elsif (not $url =~ /^\W*http:/ and $url =~ m[/(doku\.php\?id=)?:?(\w+\#[\-\.\w]+)$]) { } 0 0 0
elsif (not $url =~ /^\W*http:/ and $url =~ m[/(doku\.php\?id=)?:(.*?)\.(.*)] and not $3 =~ /gif|png|txt|jpg|jpeg/) { } 0 0 0
elsif ($url =~ /^mailto:(.*)(\?.*)?/) { } 0 0 0
elsif ($url =~ m[/lib/exe/fetch.php\?]) { } 0 0 0
elsif ($url =~ m[/lib/exe/detail.php\?]) { } 0 0 0
Condition0%0/3
not $url =~ /^\W*http:/ and $url =~ m[/(doku\.php\?id=)?:?((((\w)(\w|_)*)*:)*(\w(\w|_)*)*)$]
!ll&&!rl&&r
000
MC/DC0%0/2
not $url =~ /^\W*http:/ and $url =~ m[/(doku\.php\?id=)?:?((((\w)(\w|_)*)*:)*(\w(\w|_)*)*)$]
not $url =~ /^\W*http:/ $url =~ m[/(doku\.php\?id=)?:?((((\w)(\w|_)*)*:)*(\w(\w|_)*)*)$]
Truth table0%0/3
not(A) and B
A= not $url =~ /^\W*http:/B= $url =~ m[/(doku\.php\?id=)?:?((((\w)(\w|_)*)*:)*(\w(\w|_)*)*)$]
ABresult
0X0
100
111
926  
927 0 my $format = $self->format_InternalLink($node,$2);
928 0 $node->attr('href', $format);
929 0 $internal_link = "[[$format]]";
930 }
931 ▶ elsif($url !~ /^\W*http:/ && $url =~ /\/(doku\.php\?id=)?:?(\w+\#[\-\.\w]+)$/) {
Condition0%0/3
not $url =~ /^\W*http:/ and $url =~ m[/(doku\.php\?id=)?:?(\w+\#[\-\.\w]+)$]
!ll&&!rl&&r
000
MC/DC0%0/2
not $url =~ /^\W*http:/ and $url =~ m[/(doku\.php\?id=)?:?(\w+\#[\-\.\w]+)$]
not $url =~ /^\W*http:/ $url =~ m[/(doku\.php\?id=)?:?(\w+\#[\-\.\w]+)$]
Truth table0%0/3
not(A) and B
A= not $url =~ /^\W*http:/B= $url =~ m[/(doku\.php\?id=)?:?(\w+\#[\-\.\w]+)$]
ABresult
0X0
100
111
932  
933 0 my $format = $self->format_InternalLink($node,$2);
934 0 $node->attr('href', $format);
935 0 $internal_link = "[[$format]]";
936  
937 }
938  
939 ▶ elsif($url !~ /^\W*http:/ && $url =~ /\/(doku\.php\?id=)?:(.*?)\.(.*)/ && $3 !~/gif|png|txt|jpg|jpeg/) {
Condition0%0/6
not $url =~ /^\W*http:/ and $url =~ m[/(doku\.php\?id=)?:(.*?)\.(.*)] and not $3 =~ /gif|png|txt|jpg|jpeg/
!ll&&!rl&&r
000
not $url =~ /^\W*http:/ and $url =~ m[/(doku\.php\?id=)?:(.*?)\.(.*)]
!ll&&!rl&&r
000
MC/DC0%0/3
not $url =~ /^\W*http:/ and $url =~ m[/(doku\.php\?id=)?:(.*?)\.(.*)] and not $3 =~ /gif|png|txt|jpg|jpeg/
not $url =~ /^\W*http:/ $url =~ m[/(doku\.php\?id=)?:(.*?)\.(.*)] not $3 =~ /gif|png|txt|jpg|jpeg/
Truth table0%0/4
not(A) and B and not(C)
A= not $url =~ /^\W*http:/B= $url =~ m[/(doku\.php\?id=)?:(.*?)\.(.*)]C= not $3 =~ /gif|png|txt|jpg|jpeg/
ABCresult
0XX0
10X0
1100
1111
940  
941 0 my $format = $self->format_InternalLink($node,"$2.$3");
942 0 $node->attr('href', $format);
943 0 $internal_link = "{{$format}}";
944 }
945  
946 elsif ($url =~ /^mailto:(.*)(\?.*)?/) {
947 0 return "<" . $1 . ">";
948 }
949 elsif ($url =~ /\/lib\/exe\/fetch.php\?/) {
950 0 my $content = $self->get_elem_contents($node);
951 0 ▶ if ($content =~ /\{\{.*\}\}/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($content =~ /\{\{.*\}\}/) 0 0 0
952 0 return $content;
953 }
954 0 ▶ if ($url =~ /media=(.*)(&.*)?/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($url =~ /media=(.*)(&.*)?/) 0 0 0
955 0 ▶ return "{{" . $1 . "}}" if lc $1 eq lc $content;
Branch: 1 branch
BranchTrueFalseTotal
if lc $1 eq lc $content 0 0 0
956 0 return "{{" . $1 . "|" . $self->_as_text($node) . "}}";
957 }
958 }
959 elsif ($url =~ /\/lib\/exe\/detail.php\?/) {
960 0 my $content = $self->get_elem_contents($node);
961 0 return $content;
962 }
963  
964 0 ▶ my $output= $internal_link? $internal_link : $self->SUPER::_link($node, $rules);
Branch: 1 branch
BranchTrueFalseTotal
$internal_link ? : 0 0 0
965  
966 0 ▶ my $text = $self->get_elem_contents($node) || "";
Condition0%0/2
$self->get_elem_contents($node) || ''
l!l
00
MC/DC0%0/1
$self->get_elem_contents($node) || ''
$self->get_elem_contents($node)
Truth table0%0/2
A
A= $self->get_elem_contents($node)
Aresult
11
00
967  
968 0 my $left_alignment = ""; #actually any alignment, not just left
969 0 ▶ if($text =~ s/(\<align \d+px>)//) {
Branch: 2 branches
BranchTrueFalseTotal
if ($text =~ s/(\<align \d+px>)//) { } 0 0 0
elsif ($text =~ s/(\<align \w+>)//) { } 0 0 0
970 0 $left_alignment = $1;
971 0 $text =~ s/<\/align>//;
972 0 $output =~ s/\<align \d+px>//;
973 0 $output =~ s/<\/align>//;
974 }
975  
976 elsif($text =~ s/(\<align \w+>)//) {
977 0 $left_alignment = $1;
978 0 $text =~ s/<\/align>//;
979 0 $output =~ s/\<align \w+>//;
980 0 $output =~ s/<\/align>//;
981  
982 }
983  
984  
985 0 my $external_open; my $external_closed;
986
987 0 ▶ if($text =~ /(\<(font|color).*?\>)(.*?)(<\/\2>)/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($text =~ m[(\<(font|color).*?\>)(.*?)(</\2>)]) 0 0 0
988 0 $external_open = $1;
989 0 $external_closed = $4;
990 0 my $interior = $3;
991 0 $text = $3;
992  
993 0 ▶ if($interior =~ /(\<(font|color).*?\>)(.*?)(<\/\2>)/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($interior =~ m[(\<(font|color).*?\>)(.*?)(</\2>)]) 0 0 0
994 0 $text = $3;
995 0 $external_open = "${external_open}$1";
996 0 $external_closed = "$4${external_closed}";
997 }
998
999 }
1000  
1001 0 ▶ if($text =~ /^\s*[\\]{2}s*/) { return ""; }
Branch: 1 branch
BranchTrueFalseTotal
if ($text =~ /^\s*[\\]{2}s*/) 0 0 0
1002
1003 0 my $emphasis = "";
1004
1005 0 ▶ if($text =~ /(_<\w_>)/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($text =~ /(_<\w_>)/) 0 0 0
1006 0 $emphasis = "$1";
1007 }
1008 # $emphasis = "" if $emphasis =~ /$_format_regex{'i'}/;
1009
1010 0 ▶ if($text =~ /^(<.*?\w>).*?(<\/.*?>)$/) {
Branch: 2 branches
BranchTrueFalseTotal
if ($text =~ m[^(<.*?\w>).*?(</.*?>)$]) { } 0 0 0
elsif ($emphasis) { } 0 0 0
1011 0 my $start = $1;
1012 0 my $end = $2;
1013  
1014 0 my $start_pat = $start;
1015 0 my $end_pat = $end;
1016 0 $start_pat =~ s/(\W)/\\$1/g;
1017 0 $end_pat =~ s/(\W)/\\$1/g;
1018  
1019 0 $text =~ /^$start_pat(.*?)$end_pat$/;
1020  
1021 0 $text = $1;
1022 0 ▶ if($text =~ /\W{2}(.*?)\W{2}/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($text =~ /\W{2}(.*?)\W{2}/) 0 0 0
1023 0 $text= $1;
1024 }
1025 0 $output =~ s/\|$start_pat.*?$end_pat/|$text/;
1026 0 $output = "$start${emphasis}${output}${emphasis}$end";
1027 }
1028 elsif($emphasis) {
1029 0 $output =~ s/${emphasis}//g;
1030 0 $output = "${emphasis}${output}${emphasis}";
1031 }
1032  
1033 0 ▶ if($left_alignment) {
Branch: 1 branch
BranchTrueFalseTotal
if ($left_alignment) 0 0 0
1034 0 $output = "$left_alignment${output}</align>";
1035 }
1036  
1037  
1038 0 ▶ if($external_open) {
Branch: 1 branch
BranchTrueFalseTotal
if ($external_open) 0 0 0
1039 0 my($url, $name) = split /\|/, $output;
1040  
1041 0 $name =~ s/<.*?>//g;
1042  
1043 0 $output = $url . '|' . $name;
1044 0 $output = $external_open . $output . $external_closed;
1045 }
1046  
1047 0 return $output;
1048 }
1049  
1050  
1051 0 ▶sub _block {
Subroutine _block: not called CC=20 SCAR=60.4
1052 0 my($self, $node, $rules ) = @_;
1053 0 ▶ my $text = $self->get_elem_contents($node) || "";
Condition0%0/2
$self->get_elem_contents($node) || ''
l!l
00
MC/DC0%0/1
$self->get_elem_contents($node) || ''
$self->get_elem_contents($node)
Truth table0%0/2
A
A= $self->get_elem_contents($node)
Aresult
11
00
1054  
1055 0 ▶ if($text =~ /<block/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($text =~ /<block/) 0 0 0
1056 0 return $text;
1057 }
1058  
1059 0 $self->{'block'} = 1;
1060 0 my $bg = "";
1061 0 my $fg = "";
1062 0 my $width = '80';
1063 0 my $border = "";
1064 0 my $font = "";
1065 0 my $face = "";
1066 0 my $size = "";
1067 0 my $margin = "40";
1068  
1069 0 my $style = $node->attr('style');
1070 0 my @styles = split(';',$style);
1071 0 foreach my $at(@styles) {
1072 0 my $val = "";
1073 0 ▶ if($val = $self->_extract_style_value($at,'width') ) {
Branch: 6 branches
BranchTrueFalseTotal
if ($val = $self->_extract_style_value($at, 'width')) { } 0 0 0
elsif ($val = $self->_extract_style_value($at, 'background-color')) { } 0 0 0
elsif ($val = $self->_extract_style_value($at, 'color')) { } 0 0 0
elsif ($val = $self->_extract_style_value($at, 'border')) { } 0 0 0
elsif ($val = $self->_extract_style_value($at, 'border-left')) { } 0 0 0
elsif ($val = $self->_extract_style_value($at, 'margin-left')) { } 0 0 0
1074 0 $val =~ s/\%//;
1075 0 $width = int($val);
1076 }
1077 elsif($val = $self->_extract_style_value($at,'background-color') ) {
1078 0 $bg = $val;
1079 }
1080 elsif($val = $self->_extract_style_value($at,'color') ) {
1081 0 $fg = $val;
1082 }
1083 elsif($val = $self->_extract_style_value($at,'border') ) {
1084 0 $border = "$val";
1085 }
1086  
1087 elsif($val = $self->_extract_style_value($at,'border-left') ) {
1088 0 $border = "$val";
1089 }
1090  
1091 elsif($val = $self->_extract_style_value($at,'margin-left') ) {
1092 0 ▶ if($val =~/(\d+)/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($val =~ /(\d+)/) 0 0 0
1093 0 $margin = $1;
1094 }
1095 }
1096
1097 }
1098  
1099 0 my $basics = $self->_get_basic_attributes ($node);
1100 0 ▶ if(!$fg) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($fg) 0 0 0
1101 0 $fg = $basics->{'color'};
1102 }
1103 0 $face = $basics->{'face'};
1104 0 $size = $basics->{'size'};
1105 0 ▶ if($face || $size) {
Branch: 1 branch
BranchTrueFalseTotal
if ($face or $size) 0 0 0
Condition0%0/3
$face or $size
l!l&&r!l&&!r
000
MC/DC0%0/2
$face or $size
$face $size
Truth table0%0/3
A or B
A= $faceB= $size
ABresult
1X1
011
000
1106 0 $font = "$face/$size";
1107 }
1108  
1109 0 ▶ $fg = 'black' if($fg eq 'white' && (!$bg || !$fg || $bg eq 'white'));
Branch: 1 branch
BranchTrueFalseTotal
if $fg eq "white" and !($bg && $fg) || $bg eq "white" 0 0 0
Condition0%0/9
$fg eq "white" and !($bg && $fg) || $bg eq "white"
!ll&&!rl&&r
000
not $bg && $fg or $bg eq "white"
l!l&&r!l&&!r
000
$bg && $fg
!ll&&!rl&&r
000
MC/DC0%0/4
$fg eq "white" and !($bg && $fg) || $bg eq "white"
$fg eq "white" $bg $fg $bg eq "white"
Truth table0%0/5
A and not(B && C) or D
A= $fg eq "white"B= $bgC= $fgD= $bg eq "white"
ABCDresult
0XXX0
11100
10XX1
110X1
11111
1110  
1111 0 ▶ if(!$bg) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($bg) 0 0 0
1112 0 ▶ if($text =~ /<color.*?\/(.*?)>/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($text =~ m[<color.*?/(.*?)>]) 0 0 0
1113 0 $bg = $1;
1114 }
1115 }
1116  
1117 0 my $block = "<block $width:$margin:${bg};$fg;$border;$font>";
1118 0 $text =~ s/^\s+//; # trim
1119 0 $text =~ s/\s+$//;
1120 0 $text =~ s/\n{2,}/\n/g; # multi
1121  
1122 0 return $block . $text . '</block><br />';
1123  
1124 }
1125 0 ▶ sub _table {
Subroutine _table: not called CC=5 SCAR=34.0
1126 0 my($self, $node, $rules ) = @_;
1127 0 ▶ my $text = $self->get_elem_contents($node) || "";
Condition0%0/2
$self->get_elem_contents($node) || ''
l!l
00
MC/DC0%0/1
$self->get_elem_contents($node) || ''
$self->get_elem_contents($node)
Truth table0%0/2
A
A= $self->get_elem_contents($node)
Aresult
11
00
1128
1129 0 my $table_header = "";
1130 0 my $align = $node->attr('align');
1131 0 ▶ if($align) {
Branch: 1 branch
BranchTrueFalseTotal
if ($align) 0 0 0
1132  
1133 0 ▶ if($text=~/$NL_marker(.*?)$NL_marker/gms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($text =~ /$NL_marker(.*?)$NL_marker/gms) 0 0 0
1134 0 my $row = $1;
1135 0 my @cols = $row=~/[\|\^]/g;
1136 0 my $cols = scalar @cols;
1137 0 ▶ if($cols) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cols) 0 0 0
1138 0 $cols--;
1139 0 $table_header = $NL_marker . "|++THEAD++ ALIGN=$align" . '|' x $cols ;
1140 }
1141 }
1142 }
1143
1144 # return "<align left></align>${table_header}$text<align left><br /></align>";
1145 0 return "<align left></align>${table_header}$text<align left></align>++END_TABLE++";
1146
1147 }
1148  
1149 0 ▶ sub postprocess_output {
Subroutine postprocess_output: not called CC=10 SCAR=47.0
Pod undocumented
1150
1151 0 my($self, $outref ) = @_;
1152  
1153 0 $$outref =~ s/^[\s\xa0]+//; # trim
1154 0 $$outref =~ s/[\s\xa0]+$//;
1155 0 $$outref =~ s/\n{2,}/\n/g; # multi
1156 0 $$outref =~ s/\x{b7}/\x{a0}/gm;
1157
1158 0 $$outref =~ s/(?<=<\/align>)\s+(?=<align>)//gms; #### ???? ####
1159 0 $$outref =~ s/\s+$//gms;
1160 0 $$outref=~s/http\:(?!\/\/)/http:\/\//gsm; # replace missing forward slashes
1161 0 $$outref=~s/__(\/\/[\[\{])/$1/gsm; # remove underlining markup
1162 0 $$outref=~s/([\}\]]\/\/)__/$1/gsm; # ditto
1163
1164 0 $$outref =~ s/<dwfckg><\/dwfckg>//gms;
1165  
1166 0 $$outref =~ s/\^<align 0px><\/align>//g; # remove aligns at top of file
1167 0 $$outref =~ s/[\s\n]*<align>[\s\n]*<\/align>[\s\n]*//gsm; # remove empty aligns
1168 0 $$outref =~ s/<indent>\n*<\/indent>//gms;
1169
1170
1171 0 $$outref =~ s/(?<!\w\>)(?<!$NL_marker)\n(?!\<\W\w)/\n<align left><\/align> /gms;
1172 0 $$outref =~ s/$NL_marker/\n/gms;
1173  
1174 0 $$outref =~ s/\n\s*(?=\|\n)//gms;
1175  
1176 0 $$outref =~ s/^\s+//gms; # delete spaces at start of lines
1177 0 $$outref =~ s/(<align 0px>[\n\s]*<\/align>[\n\s]*)+//gms;
1178 0 $$outref =~ s/(<align 1px>[\n\s]*<\/align>[\n\s]*)+//gms;
1179  
1180 0 $$outref =~ s/\n[\\](2)s*/\n/gms;
1181
1182 0 $$outref =~ s/(?<=<align>)[\n\s]+(?=<\/align>)//gms;
1183 0 $$outref =~ s/\n{3,}/\n/gms;
1184  
1185 0 $$outref =~ s/<align left>[\n\s]+<\/align>[\\]{2}\s*//gms;
1186  
1187 0 $$outref =~ s/([\s\n]*<align><\/align>[\s\n]*){2,}/<align><\/align>/gms;
1188 0 $$outref =~ s/([\s\n]*<align center><\/align>[\s\n]*){2,}/<align center><\/align>/gms;
1189 0 $$outref =~ s/([\s\n]*<align right><\/align>[\s\n]*){2,}/<align right><\/align>/gms;
1190 0 ▶ $$outref =~ s/([\s\n]*<align left><\/align>([\s\n])*){2,}/$2 ? "<align left><\/align>$2" : "<align left><\/align>"/gmse;
Branch: 1 branch
BranchTrueFalseTotal
$2 ? : 0 0 0
1191  
1192  
1193 0 ▶ if($self->{'list_output'}) { # start with look behind for bold
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"list_output"}) 0 0 0
1194 0 $$outref =~ s/(?<![\*\-])([\*\-])(?:\s)(.*?)($EOL[\s\n]*)/$self->_format_list($1,$2, $3)/gmse;
1195 }
1196  
1197 0 $$outref =~ s/(?!\n)<align left>/\n<align left>/gms;
1198 0 $$outref =~ s/<font _dummy_\/courier New>\s*<\/font>//gms;
1199  
1200 0 $$outref =~ s/([\/\{]{2})*(\s*)(?<!\[\[)\s*(http:\/\/[_\p{IsDigit}\p{IsAlpha}\p{IsXDigit};&?:.\-='"\/]{7,})(?!\|)/$self->_clean_url($3,$1, $2)/egms;
1201  
1202 0 ▶ $$outref =~ s/__SHARE__/\\\\/gms if $self->{'share'};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"share"} 0 0 0
1203  
1204 0 $$outref =~s/$EOL//g;
1205  
1206 0 $$outref =~ s/<code><\/code>//gms;
1207 0 $$outref =~ s/<code>[\W]+<\/code>//gms;
1208
1209 0 $$outref =~ s/<align \w+>[\n\s]*(<align \w+>.*?<\/align>[\n\s]*)<\/align>/$1/gms;
1210  
1211 0 $self->del_xtra_c_aligns($$outref);
1212  
1213 0 $$outref =~ s/<\/align>\s*<br \/>/<\/align>/gms;
1214 0 $$outref =~ s/\n+/\n/gms;
1215  
1216  
1217 0 ▶ if($self->{'in_table'}) { # insure tables start with newline
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"in_table"}) 0 0 0
1218 0 $$outref =~ s/align>\s*(\||\^)/align>\n$1/gms;
1219 0 $$outref =~ s/[\\]{2}(?=\s+\|)//gms; # remove line breaks at ends of cells
1220 }
1221  
1222  
1223 0 $$outref =~ s/(?<=\<\/align>)(\s*[\\]{2}\s*)+//gms;
1224 0 $$outref =~ s/(?<=\<\/align>)\s*<br \/>\s*//gms;
1225  
1226 0 ▶ if($self->{'code'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"code"}) 0 0 0
1227 0 $$outref =~ s/x\00/ /gms;
1228 0 $$outref =~ s/(?<=<code>)(.*?)(?=<\/code>)/$self->fix_code($1)/gmse;
1229 0 $$outref =~ s/<\/code>[\s\n]*$/<\/code><br \/>/;
1230 }
1231  
1232 0 ▶ $$outref =~ s/<\/block>/<\/block><align left><\/align>/gm if $self->{'block'};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"block"} 0 0 0
1233 0 ▶ $$outref .= "\n" unless $$outref =~ /\n\n$/m;
Branch: 1 branch
BranchTrueFalseTotal
unless $$outref =~ /\n\n$/m 0 0 0
1234
1235 0 ▶ if($$outref !~ /<align|<dwfckg.*?dwfckg>/gms) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($$outref =~ /<align|<dwfckg.*?dwfckg>/gms) 0 0 0
1236 0 $$outref = '<dwfckg></dwfckg>' . $$outref;
1237 }
1238
1239
1240 0 ▶ if($self->{'in_table'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"in_table"}) 0 0 0
1241 0 $$outref =~ s/\+\+END_TABLE\+\+[\s\n]*$/<br \/>/;
1242 0 $$outref =~ s/\++END_TABLE\+\+//g;
1243 }
1244  
1245 }
1246  
1247  
1248 0 ▶ sub del_xtra_c_aligns {
Subroutine del_xtra_c_aligns: not called CC=2 SCAR=17.9
Pod undocumented
1249 0 my ($self, $text) = @_;
1250  
1251 0 my @left = $text=~ /(<align)/gs;
1252 0 my @right = $text=~ /(<\/align)/gms;
1253  
1254  
1255 0 ▶ if(scalar @right > scalar @left) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @right > scalar @left) 0 0 0
1256 0 my $oCount = 0;
1257 0 my $cCount = 0;
1258  
1259 0 $text =~ s/((<align \w+>)|(<\/align>))/$self->fix_aligns($1, \$oCount, \$cCount)/egms;
1260 }
1261 }
1262  
1263  
1264 0 ▶ sub fix_aligns {
Subroutine fix_aligns: not called CC=4 SCAR=30.0
Pod undocumented
1265 0 my ($self, $align, $open, $close) = @_;
1266 0 ▶ $$close++ if $align =~ /<\/align/;
Branch: 1 branch
BranchTrueFalseTotal
if $align =~ m[</align] 0 0 0
1267 0 ▶ $$open++ if $align =~ /<align \w+>/;
Branch: 1 branch
BranchTrueFalseTotal
if $align =~ /<align \w+>/ 0 0 0
1268  
1269 0 ▶ if ($$close > $$open) {
Branch: 1 branch
BranchTrueFalseTotal
if ($$close > $$open) 0 0 0
1270 0 $$close--;
1271 0 return ""
1272 }
1273  
1274 0 return $align;
1275 }
1276  
1277 0 ▶ sub _clean_url {
Subroutine _clean_url: not called CC=4 SCAR=30.0
1278 0 my($self,$url, $markup, $spaces) = @_;
1279 0 ▶ return "{{$url" if $url=~/editor\/images\/smiley\/msn/;
Branch: 1 branch
BranchTrueFalseTotal
if $url =~ m[editor/images/smiley/msn] 0 0 0
1280  
1281 0 ▶ if($markup =~/\{\{/) { ## an external image, the first pair of brackets have been removed by regex
Branch: 1 branch
BranchTrueFalseTotal
if ($markup =~ /\{\{/) 0 0 0
1282 0 return $markup . $spaces . $url;
1283 }
1284  
1285 0 my $italics="";
1286 0 ▶ if($markup =~ /\//) {
Branch: 1 branch
BranchTrueFalseTotal
if ($markup =~ m[/]) 0 0 0
1287 0 $italics='//';
1288 }
1289  
1290 0 $url =~ s/^[^h]+//ms;
1291 0 $url =~ s/['"\/*_]{2,}$//ms;
1292  
1293 0 return $italics .'[[' . $url . ']]' . $italics;
1294 }
1295  
1296 0 ▶ sub _format_list {
Subroutine _format_list: not called CC=6 SCAR=37.4
1297 0 my($self,$type, $item, $rest_of_sel) = @_;
1298 0 my $text = "${type} ${item}${rest_of_sel}";
1299 0 ▶ return $text if($text =~ /-&gt;/);
Branch: 1 branch
BranchTrueFalseTotal
if $text =~ /-&gt;/ 0 0 0
1300 0 my $prefix = ""; # any matter which precedes list
1301  
1302 0 my $p = 0;
1303 0 pos($text) = 0;
1304 0 ▶ while($text =~ /(.*?)(?<!\-\-\-)(?=\s+[\*\-]\s+.*?$EOL)/gms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($text =~ /(.*?)(?<!\-\-\-)(?=\s+[\*\-]\s+.*?$EOL)/gms) 0 0 0
1305 0 $prefix .= $1;
1306 0 $p = pos($text);
1307 }
1308 0 pos($text) = $p;
1309 0 $text =~ /(.*?)$EOL/gms;
1310 0 ▶ $item = $self->trim($1) if $1;
Branch: 1 branch
BranchTrueFalseTotal
if $1 0 0 0
1311 0 ▶ if($item eq '-' || $item eq '*') {
Branch: 1 branch
BranchTrueFalseTotal
if ($item eq "-" or $item eq "*") 0 0 0
Condition0%0/3
$item eq "-" or $item eq "*"
l!l&&r!l&&!r
000
MC/DC0%0/2
$item eq "-" or $item eq "*"
$item eq "-" $item eq "*"
Truth table0%0/3
A or B
A= $item eq "-"B= $item eq "*"
ABresult
1X1
011
000
1312 0 $item = ""; #remove empty list items,they overlap previous line
1313 }
1314 0 $item =~ s/<align\s*\w*>\s*<\/align>\s*$//gm;
1315 0 return "$prefix\n $item";
1316  
1317 }
1318  
1319 0 ▶ sub fix_code {
Subroutine fix_code: not called CC=2 SCAR=17.9
Pod undocumented
1320 0 my ($self, $text) = @_;
1321 0 $text =~ s/<indent.*?>($nudge_char)*<\/indent>//gms;
1322 # $text =~ s/$code_NL/\n/gms;
1323 0 ▶ $text =~ s/[\x{b7}\x{a0}]//gms if $self->{'do_nudge'} ;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"do_nudge"} 0 0 0
1324 0 return $text;
1325 }
1326  
1327  
1328 0 ▶ sub trim {
Subroutine trim: not called CC=1 SCAR=6.9
Pod undocumented
1329 0 my($self,$text) = @_;
1330 0 $text =~ s/^\s+//;
1331 0 $text =~ s/\s+$//;
1332 0 return $text;
1333 }
1334  
1335 0 ▶ sub log {
Subroutine log: not called CC=4 SCAR=30.0
Pod undocumented
1336 0 my($self, $where, $data) = @_;
1337 0 my $fh = $self->{'_fh'};
1338 0 ▶ $where = "" if ! $where;
Branch: 1 branch
BranchTrueFalseTotal
unless $where 0 0 0
1339 0 ▶ $data = "" if ! $data;
Branch: 1 branch
BranchTrueFalseTotal
unless $data 0 0 0
1340 0 ▶ if( $fh ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($fh) 0 0 0
1341 0 print $fh "$where: $data\n";
1342 }
1343 }
1344  
1345  
1346 0 ▶ sub DESTROY {
Subroutine DESTROY: not called CC=2 SCAR=17.9
1347 0 my $self=shift;
1348 0 my $fh = $self->{_fh};
1349  
1350 0 ▶ if( $fh ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($fh) 0 0 0
1351 0 print $fh "\n-----------\n\n";
1352 0 close($fh);
1353 }
1354  
1355 }
1356  
1357  
1358 0 ▶ sub _get_basic_attributes {
Subroutine _get_basic_attributes: not called CC=7 SCAR=40.3
1359 0 my($self, $node) = @_;
1360  
1361 0 my $fg = '';
1362 0 my $bg = '';
1363 0 my %color_atts = $self->_get_type($node, ['color','background-color'], 'color');
1364 0 ▶ if(%color_atts) {
Branch: 1 branch
BranchTrueFalseTotal
if (%color_atts) 0 0 0
1365 0 ▶ $fg = (exists $color_atts{'color'}) ? ($color_atts{'color'}) : "";
Branch: 1 branch
BranchTrueFalseTotal
exists $color_atts{'color'} ? : 0 0 0
1366 0 ▶ $bg = (exists $color_atts{'background-color'}) ? ($color_atts{'background-color'}) : "";
Branch: 1 branch
BranchTrueFalseTotal
exists $color_atts{'background-color'} ? : 0 0 0
1367 }
1368  
1369
1370 0 my $face = '';
1371 0 my $size = '';
1372 0 my %font_atts = $self->_get_type($node, ['size', 'face'], 'font');
1373 0 ▶ if(%font_atts) {
Branch: 1 branch
BranchTrueFalseTotal
if (%font_atts) 0 0 0
1374 0 ▶ $face = (exists $font_atts{'face'}) ? ($font_atts{'face'}) : '';
Branch: 1 branch
BranchTrueFalseTotal
exists $font_atts{'face'} ? : 0 0 0
1375 0 ▶ $size = (exists $font_atts{'size'}) ? ($font_atts{'size'}) : "";
Branch: 1 branch
BranchTrueFalseTotal
exists $font_atts{'size'} ? : 0 0 0
1376 }
1377 0 return { 'face'=>$face, 'size'=>$size,'color'=>$fg, 'background'=>$bg };
1378 }
1379  
1380 0 ▶ sub _header {
Subroutine _header: not called CC=1 SCAR=6.9
1381 0 my($self, $node, $rules ) = @_;
1382  
1383 0 my $text = $self->_as_text($node);
1384  
1385 0 $node->tag =~ /(\d)/;
1386  
1387 0 my $pre_and_post_fix = "=" x (7 - $1);
1388  
1389 0 my $str = "\n" . "$NL_marker\n$pre_and_post_fix" . $text . "$pre_and_post_fix\n\n<align left></align>";
1390 0 return $str;
1391 }
1392  
1393 0 ▶ sub _as_text {
Subroutine _as_text: not called CC=2 SCAR=17.9
1394 0 my($self, $node) = @_;
1395 0 my $text = join '', map { $self->__get_text($_) } $node->content_list;
1396 0 ▶ return defined $text ? $text : '';
Branch: 1 branch
BranchTrueFalseTotal
defined $text ? : 0 0 0
1397 }
1398  
1399 0 ▶ sub __get_text {
Subroutine __get_text: not called CC=4 SCAR=30.0
1400 0 my($self, $node) = @_;
1401 0 $node->normalize_content();
1402 0 ▶ if( $node->tag eq '~text' ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($node->tag eq '~text') { } 0 0 0
elsif ($node->tag eq '~comment') { } 0 0 0
1403 0 return $node->attr('text');
1404 } elsif( $node->tag eq '~comment' ) {
1405 0 return '<!--' . $node->attr('text') . '-->';
1406 } else {
1407 0 ▶ my $output = $self->_as_text($node)||'';
Condition0%0/2
$self->_as_text($node) || ''
l!l
00
MC/DC0%0/1
$self->_as_text($node) || ''
$self->_as_text($node)
Truth table0%0/2
A
A= $self->_as_text($node)
Aresult
11
00
1408 0 return $output;
1409 }
1410 }
1411  
1412  
1413  
1414 1 1;
1415  
1416  
1417  
1418  
↑ Summary DokuWikiFCKN.pm »