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