| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package PYX::SGML::Raw; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# Pragmas. |
|
4
|
8
|
|
|
8
|
|
249535
|
use strict; |
|
|
8
|
|
|
|
|
18
|
|
|
|
8
|
|
|
|
|
221
|
|
|
5
|
8
|
|
|
8
|
|
42
|
use warnings; |
|
|
8
|
|
|
|
|
14
|
|
|
|
8
|
|
|
|
|
255
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
# Modules. |
|
8
|
8
|
|
|
8
|
|
1803
|
use Class::Utils qw(set_params); |
|
|
8
|
|
|
|
|
60324
|
|
|
|
8
|
|
|
|
|
318
|
|
|
9
|
8
|
|
|
8
|
|
6373
|
use PYX::Parser; |
|
|
8
|
|
|
|
|
10956
|
|
|
|
8
|
|
|
|
|
271
|
|
|
10
|
8
|
|
|
8
|
|
6062
|
use PYX::Utils qw(encode entity_encode); |
|
|
8
|
|
|
|
|
69837
|
|
|
|
8
|
|
|
|
|
161
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
# Version. |
|
13
|
|
|
|
|
|
|
our $VERSION = 0.02; |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
# Constructor. |
|
16
|
|
|
|
|
|
|
sub new { |
|
17
|
8
|
|
|
8
|
1
|
3044
|
my ($class, @params) = @_; |
|
18
|
8
|
|
|
|
|
21
|
my $self = bless {}, $class; |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# Output handler. |
|
21
|
8
|
|
|
|
|
49
|
$self->{'output_handler'} = \*STDOUT; |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
# Process params. |
|
24
|
8
|
|
|
|
|
31
|
set_params($self, @params); |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
# PYX::Parser object. |
|
27
|
|
|
|
|
|
|
$self->{'pyx_parser'} = PYX::Parser->new( |
|
28
|
|
|
|
|
|
|
'callbacks' => { |
|
29
|
|
|
|
|
|
|
'start_element' => \&_start_element, |
|
30
|
|
|
|
|
|
|
'end_element' => \&_end_element, |
|
31
|
|
|
|
|
|
|
'data' => \&_data, |
|
32
|
|
|
|
|
|
|
'instruction' => \&_instruction, |
|
33
|
|
|
|
|
|
|
'attribute' => \&_attribute, |
|
34
|
|
|
|
|
|
|
'comment' => \&_comment, |
|
35
|
|
|
|
|
|
|
}, |
|
36
|
|
|
|
|
|
|
'non_parser_options' => { |
|
37
|
|
|
|
|
|
|
'tag_open' => 0, |
|
38
|
|
|
|
|
|
|
}, |
|
39
|
8
|
|
|
|
|
157
|
'output_handler' => $self->{'output_handler'}, |
|
40
|
|
|
|
|
|
|
); |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# Object. |
|
43
|
8
|
|
|
|
|
500
|
return $self; |
|
44
|
|
|
|
|
|
|
} |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
# Parse pyx text or array of pyx text. |
|
47
|
|
|
|
|
|
|
sub parse { |
|
48
|
0
|
|
|
0
|
1
|
0
|
my ($self, $pyx, $out) = @_; |
|
49
|
0
|
|
|
|
|
0
|
$self->{'pyx_parser'}->parse($pyx, $out); |
|
50
|
0
|
|
|
|
|
0
|
return; |
|
51
|
|
|
|
|
|
|
} |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
# Parse file with pyx text. |
|
54
|
|
|
|
|
|
|
sub parse_file { |
|
55
|
13
|
|
|
13
|
1
|
16322
|
my ($self, $file) = @_; |
|
56
|
13
|
|
|
|
|
60
|
$self->{'pyx_parser'}->parse_file($file); |
|
57
|
13
|
|
|
|
|
293
|
return; |
|
58
|
|
|
|
|
|
|
} |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
# Parse from handler. |
|
61
|
|
|
|
|
|
|
sub parse_handler { |
|
62
|
0
|
|
|
0
|
1
|
0
|
my ($self, $input_file_handler, $out) = @_; |
|
63
|
0
|
|
|
|
|
0
|
$self->{'pyx_parser'}->parse_handler($input_file_handler, $out); |
|
64
|
0
|
|
|
|
|
0
|
return; |
|
65
|
|
|
|
|
|
|
} |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
# Process start of element. |
|
68
|
|
|
|
|
|
|
sub _start_element { |
|
69
|
6
|
|
|
6
|
|
579
|
my ($pyx_parser_obj, $elem) = @_; |
|
70
|
6
|
|
|
|
|
15
|
my $out = $pyx_parser_obj->{'output_handler'}; |
|
71
|
6
|
|
|
|
|
18
|
_end_of_start_tag($pyx_parser_obj); |
|
72
|
6
|
|
|
|
|
9
|
print {$out} "<$elem"; |
|
|
6
|
|
|
|
|
242
|
|
|
73
|
6
|
|
|
|
|
16
|
$pyx_parser_obj->{'non_parser_options'}->{'tag_open'} = 1; |
|
74
|
6
|
|
|
|
|
16
|
return; |
|
75
|
|
|
|
|
|
|
} |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
# Process end of element. |
|
78
|
|
|
|
|
|
|
sub _end_element { |
|
79
|
4
|
|
|
4
|
|
181
|
my ($pyx_parser_obj, $elem) = @_; |
|
80
|
4
|
|
|
|
|
9
|
my $out = $pyx_parser_obj->{'output_handler'}; |
|
81
|
4
|
|
|
|
|
12
|
_end_of_start_tag($pyx_parser_obj); |
|
82
|
4
|
|
|
|
|
5
|
print {$out} "$elem>"; |
|
|
4
|
|
|
|
|
87
|
|
|
83
|
4
|
|
|
|
|
13
|
return; |
|
84
|
|
|
|
|
|
|
} |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
# Process data. |
|
87
|
|
|
|
|
|
|
sub _data { |
|
88
|
2
|
|
|
2
|
|
218
|
my ($pyx_parser_obj, $decoded_data) = @_; |
|
89
|
2
|
|
|
|
|
5
|
my $out = $pyx_parser_obj->{'output_handler'}; |
|
90
|
2
|
|
|
|
|
8
|
my $data = encode($decoded_data); |
|
91
|
2
|
|
|
|
|
17
|
_end_of_start_tag($pyx_parser_obj); |
|
92
|
2
|
|
|
|
|
2
|
print {$out} entity_encode($data); |
|
|
2
|
|
|
|
|
8
|
|
|
93
|
2
|
|
|
|
|
112
|
return; |
|
94
|
|
|
|
|
|
|
} |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
# Process attribute. |
|
97
|
|
|
|
|
|
|
sub _attribute { |
|
98
|
4
|
|
|
4
|
|
132
|
my ($pyx_parser_obj, $att, $attval) = @_; |
|
99
|
4
|
|
|
|
|
8
|
my $out = $pyx_parser_obj->{'output_handler'}; |
|
100
|
4
|
|
|
|
|
7
|
print {$out} " $att=\"", entity_encode($attval), '"'; |
|
|
4
|
|
|
|
|
61
|
|
|
101
|
4
|
|
|
|
|
109
|
return; |
|
102
|
|
|
|
|
|
|
} |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
# Process instruction. |
|
105
|
|
|
|
|
|
|
sub _instruction { |
|
106
|
2
|
|
|
2
|
|
195
|
my ($pyx_parser_obj, $target, $data) = @_; |
|
107
|
2
|
|
|
|
|
3
|
my $out = $pyx_parser_obj->{'output_handler'}; |
|
108
|
2
|
|
|
|
|
6
|
_end_of_start_tag($pyx_parser_obj); |
|
109
|
2
|
|
|
|
|
2
|
print {$out} "$target ", encode($data), "?>"; |
|
|
2
|
|
|
|
|
12
|
|
|
110
|
2
|
|
|
|
|
169
|
return; |
|
111
|
|
|
|
|
|
|
} |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
# Ends start tag. |
|
114
|
|
|
|
|
|
|
sub _end_of_start_tag { |
|
115
|
14
|
|
|
14
|
|
22
|
my $pyx_parser_obj = shift; |
|
116
|
14
|
|
|
|
|
26
|
my $out = $pyx_parser_obj->{'output_handler'}; |
|
117
|
14
|
100
|
|
|
|
53
|
if ($pyx_parser_obj->{'non_parser_options'}->{'tag_open'}) { |
|
118
|
3
|
|
|
|
|
4
|
print {$out} '>'; |
|
|
3
|
|
|
|
|
28
|
|
|
119
|
3
|
|
|
|
|
7
|
$pyx_parser_obj->{'non_parser_options'}->{'tag_open'} = 0; |
|
120
|
|
|
|
|
|
|
} |
|
121
|
14
|
|
|
|
|
28
|
return; |
|
122
|
|
|
|
|
|
|
} |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
# Process comment. |
|
125
|
|
|
|
|
|
|
sub _comment { |
|
126
|
2
|
|
|
2
|
|
176
|
my ($pyx_parser_obj, $comment) = @_; |
|
127
|
2
|
|
|
|
|
3
|
my $out = $pyx_parser_obj->{'output_handler'}; |
|
128
|
2
|
|
|
|
|
3
|
print {$out} ''; |
|
|
2
|
|
|
|
|
8
|
|
|
129
|
2
|
|
|
|
|
96
|
return; |
|
130
|
|
|
|
|
|
|
} |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
1; |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
__END__ |