line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package PYX::SGML::Raw; |
2
|
|
|
|
|
|
|
|
3
|
8
|
|
|
8
|
|
293796
|
use strict; |
|
8
|
|
|
|
|
74
|
|
|
8
|
|
|
|
|
246
|
|
4
|
8
|
|
|
8
|
|
43
|
use warnings; |
|
8
|
|
|
|
|
12
|
|
|
8
|
|
|
|
|
242
|
|
5
|
|
|
|
|
|
|
|
6
|
8
|
|
|
8
|
|
1060
|
use Class::Utils qw(set_params); |
|
8
|
|
|
|
|
58646
|
|
|
8
|
|
|
|
|
325
|
|
7
|
8
|
|
|
8
|
|
4112
|
use PYX::Parser; |
|
8
|
|
|
|
|
102334
|
|
|
8
|
|
|
|
|
335
|
|
8
|
8
|
|
|
8
|
|
3791
|
use PYX::Utils qw(encode entity_encode); |
|
8
|
|
|
|
|
57750
|
|
|
8
|
|
|
|
|
157
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = 0.03; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
# Constructor. |
13
|
|
|
|
|
|
|
sub new { |
14
|
8
|
|
|
8
|
1
|
3288
|
my ($class, @params) = @_; |
15
|
8
|
|
|
|
|
26
|
my $self = bless {}, $class; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
# Output handler. |
18
|
8
|
|
|
|
|
38
|
$self->{'output_handler'} = \*STDOUT; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# Process params. |
21
|
8
|
|
|
|
|
32
|
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
|
|
|
|
|
141
|
'output_handler' => $self->{'output_handler'}, |
37
|
|
|
|
|
|
|
); |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# Object. |
40
|
8
|
|
|
|
|
459
|
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
|
22482
|
my ($self, $file) = @_; |
53
|
13
|
|
|
|
|
92
|
$self->{'pyx_parser'}->parse_file($file); |
54
|
13
|
|
|
|
|
459
|
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
|
|
1403
|
my ($pyx_parser_obj, $elem) = @_; |
73
|
6
|
|
|
|
|
14
|
my $out = $pyx_parser_obj->{'output_handler'}; |
74
|
6
|
|
|
|
|
17
|
_end_of_start_tag($pyx_parser_obj); |
75
|
6
|
|
|
|
|
10
|
print {$out} "<$elem"; |
|
6
|
|
|
|
|
273
|
|
76
|
6
|
|
|
|
|
29
|
$pyx_parser_obj->{'non_parser_options'}->{'tag_open'} = 1; |
77
|
6
|
|
|
|
|
23
|
return; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
# Process end of element. |
81
|
|
|
|
|
|
|
sub _end_element { |
82
|
4
|
|
|
4
|
|
634
|
my ($pyx_parser_obj, $elem) = @_; |
83
|
4
|
|
|
|
|
15
|
my $out = $pyx_parser_obj->{'output_handler'}; |
84
|
4
|
|
|
|
|
13
|
_end_of_start_tag($pyx_parser_obj); |
85
|
4
|
|
|
|
|
6
|
print {$out} "$elem>"; |
|
4
|
|
|
|
|
116
|
|
86
|
4
|
|
|
|
|
22
|
return; |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
# Process data. |
90
|
|
|
|
|
|
|
sub _data { |
91
|
2
|
|
|
2
|
|
538
|
my ($pyx_parser_obj, $decoded_data) = @_; |
92
|
2
|
|
|
|
|
4
|
my $out = $pyx_parser_obj->{'output_handler'}; |
93
|
2
|
|
|
|
|
7
|
my $data = encode($decoded_data); |
94
|
2
|
|
|
|
|
21
|
_end_of_start_tag($pyx_parser_obj); |
95
|
2
|
|
|
|
|
4
|
print {$out} entity_encode($data); |
|
2
|
|
|
|
|
6
|
|
96
|
2
|
|
|
|
|
138
|
return; |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
# Process attribute. |
100
|
|
|
|
|
|
|
sub _attribute { |
101
|
4
|
|
|
4
|
|
371
|
my ($pyx_parser_obj, $att, $attval) = @_; |
102
|
4
|
|
|
|
|
11
|
my $out = $pyx_parser_obj->{'output_handler'}; |
103
|
4
|
|
|
|
|
8
|
print {$out} " $att=\"", entity_encode($attval), '"'; |
|
4
|
|
|
|
|
25
|
|
104
|
4
|
|
|
|
|
141
|
return; |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
# Process instruction. |
108
|
|
|
|
|
|
|
sub _instruction { |
109
|
2
|
|
|
2
|
|
535
|
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
|
|
|
|
|
11
|
|
113
|
2
|
|
|
|
|
127
|
return; |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
# Ends start tag. |
117
|
|
|
|
|
|
|
sub _end_of_start_tag { |
118
|
14
|
|
|
14
|
|
28
|
my $pyx_parser_obj = shift; |
119
|
14
|
|
|
|
|
29
|
my $out = $pyx_parser_obj->{'output_handler'}; |
120
|
14
|
100
|
|
|
|
45
|
if ($pyx_parser_obj->{'non_parser_options'}->{'tag_open'}) { |
121
|
3
|
|
|
|
|
5
|
print {$out} '>'; |
|
3
|
|
|
|
|
43
|
|
122
|
3
|
|
|
|
|
10
|
$pyx_parser_obj->{'non_parser_options'}->{'tag_open'} = 0; |
123
|
|
|
|
|
|
|
} |
124
|
14
|
|
|
|
|
28
|
return; |
125
|
|
|
|
|
|
|
} |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
# Process comment. |
128
|
|
|
|
|
|
|
sub _comment { |
129
|
2
|
|
|
2
|
|
510
|
my ($pyx_parser_obj, $comment) = @_; |
130
|
2
|
|
|
|
|
5
|
my $out = $pyx_parser_obj->{'output_handler'}; |
131
|
2
|
|
|
|
|
2
|
print {$out} ''; |
|
2
|
|
|
|
|
9
|
|
132
|
2
|
|
|
|
|
120
|
return; |
133
|
|
|
|
|
|
|
} |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
1; |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
__END__ |