line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Pod::Simple::XMLOutStream; |
2
|
29
|
|
|
29
|
|
297283
|
use strict; |
|
29
|
|
|
|
|
103
|
|
|
29
|
|
|
|
|
951
|
|
3
|
29
|
|
|
29
|
|
154
|
use warnings; |
|
29
|
|
|
|
|
69
|
|
|
29
|
|
|
|
|
713
|
|
4
|
29
|
|
|
29
|
|
152
|
use Carp (); |
|
29
|
|
|
|
|
49
|
|
|
29
|
|
|
|
|
387
|
|
5
|
29
|
|
|
29
|
|
2572
|
use Pod::Simple (); |
|
29
|
|
|
|
|
62
|
|
|
29
|
|
|
|
|
1853
|
|
6
|
|
|
|
|
|
|
our $VERSION = '3.45'; |
7
|
|
|
|
|
|
|
BEGIN { |
8
|
29
|
|
|
29
|
|
604
|
our @ISA = ('Pod::Simple'); |
9
|
29
|
50
|
|
|
|
21118
|
*DEBUG = \&Pod::Simple::DEBUG unless defined &DEBUG; |
10
|
|
|
|
|
|
|
} |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $ATTR_PAD; |
13
|
|
|
|
|
|
|
$ATTR_PAD = "\n" unless defined $ATTR_PAD; |
14
|
|
|
|
|
|
|
# Don't mess with this unless you know what you're doing. |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
our $SORT_ATTRS; |
17
|
|
|
|
|
|
|
$SORT_ATTRS = 0 unless defined $SORT_ATTRS; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub new { |
20
|
469
|
|
|
469
|
1
|
8785
|
my $self = shift; |
21
|
469
|
|
|
|
|
1595
|
my $new = $self->SUPER::new(@_); |
22
|
469
|
|
50
|
|
|
2430
|
$new->{'output_fh'} ||= *STDOUT{IO}; |
23
|
469
|
|
|
|
|
1431
|
$new->keep_encoding_directive(1); |
24
|
|
|
|
|
|
|
#$new->accept_codes('VerbatimFormatted'); |
25
|
469
|
|
|
|
|
1013
|
return $new; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub _handle_element_start { |
31
|
|
|
|
|
|
|
# ($self, $element_name, $attr_hash_r) |
32
|
1870
|
|
|
1870
|
|
3291
|
my $fh = $_[0]{'output_fh'}; |
33
|
1870
|
|
|
|
|
2776
|
my($key, $value); |
34
|
1870
|
|
|
|
|
2358
|
DEBUG and print STDERR "++ $_[1]\n"; |
35
|
1870
|
|
|
|
|
5807
|
print $fh "<", $_[1]; |
36
|
1870
|
100
|
|
|
|
3624
|
if($SORT_ATTRS) { |
37
|
1160
|
|
|
|
|
1567
|
foreach my $key (sort keys %{$_[2]}) { |
|
1160
|
|
|
|
|
4153
|
|
38
|
2043
|
100
|
|
|
|
5008
|
unless($key =~ m/^~/s) { |
39
|
1602
|
50
|
66
|
|
|
5194
|
next if $key eq 'start_line' and $_[0]{'hide_line_numbers'}; |
40
|
695
|
|
|
|
|
1859
|
_xml_escape($value = $_[2]{$key}); |
41
|
695
|
|
|
|
|
1700
|
print $fh $ATTR_PAD, $key, '="', $value, '"'; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
} else { # faster |
45
|
710
|
|
|
|
|
1042
|
while(($key,$value) = each %{$_[2]}) { |
|
1544
|
|
|
|
|
4975
|
|
46
|
834
|
100
|
|
|
|
2170
|
unless($key =~ m/^~/s) { |
47
|
764
|
100
|
100
|
|
|
3061
|
next if $key eq 'start_line' and $_[0]{'hide_line_numbers'}; |
48
|
197
|
|
|
|
|
510
|
_xml_escape($value); |
49
|
197
|
|
|
|
|
511
|
print $fh $ATTR_PAD, $key, '="', $value, '"'; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
} |
53
|
1870
|
|
|
|
|
4696
|
print $fh ">"; |
54
|
1870
|
|
|
|
|
3817
|
return; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub _handle_text { |
58
|
1278
|
|
|
1278
|
|
1728
|
DEBUG and print STDERR "== \"$_[1]\"\n"; |
59
|
1278
|
100
|
|
|
|
2507
|
if(length $_[1]) { |
60
|
1267
|
|
|
|
|
1958
|
my $text = $_[1]; |
61
|
1267
|
|
|
|
|
2699
|
_xml_escape($text); |
62
|
1267
|
|
|
|
|
1668
|
print {$_[0]{'output_fh'}} $text; |
|
1267
|
|
|
|
|
3374
|
|
63
|
|
|
|
|
|
|
} |
64
|
1278
|
|
|
|
|
3337
|
return; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub _handle_element_end { |
68
|
1870
|
|
|
1870
|
|
2382
|
DEBUG and print STDERR "-- $_[1]\n"; |
69
|
1870
|
|
|
|
|
2473
|
print {$_[0]{'output_fh'}} "", $_[1], ">"; |
|
1870
|
|
|
|
|
4558
|
|
70
|
1870
|
|
|
|
|
3451
|
return; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
# . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
74
|
|
|
|
|
|
|
#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub _xml_escape { |
77
|
2159
|
|
|
2159
|
|
3504
|
foreach my $x (@_) { |
78
|
|
|
|
|
|
|
# Escape things very cautiously: |
79
|
2159
|
50
|
|
|
|
7962
|
if ($] ge 5.007_003) { |
80
|
2159
|
|
|
|
|
7556
|
$x =~ s/([^-\n\t !\#\$\%\(\)\*\+,\.\~\/\:\;=\?\@\[\\\]\^_\`\{\|\}abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789])/''.(utf8::native_to_unicode(ord($1))).';'/eg; |
|
862
|
|
|
|
|
2909
|
|
81
|
|
|
|
|
|
|
} else { # Is broken for non-ASCII platforms on early perls |
82
|
0
|
|
|
|
|
0
|
$x =~ s/([^-\n\t !\#\$\%\(\)\*\+,\.\~\/\:\;=\?\@\[\\\]\^_\`\{\|\}abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789])/''.(ord($1)).';'/eg; |
|
0
|
|
|
|
|
0
|
|
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
# Yes, stipulate the list without a range, so that this can work right on |
85
|
|
|
|
|
|
|
# all charsets that this module happens to run under. |
86
|
|
|
|
|
|
|
} |
87
|
2159
|
|
|
|
|
3004
|
return; |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ |
91
|
|
|
|
|
|
|
1; |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
__END__ |