| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Data::HTML::Element::A; |
|
2
|
|
|
|
|
|
|
|
|
3
|
9
|
|
|
9
|
|
163663
|
use strict; |
|
|
9
|
|
|
|
|
21
|
|
|
|
9
|
|
|
|
|
411
|
|
|
4
|
9
|
|
|
9
|
|
47
|
use warnings; |
|
|
9
|
|
|
|
|
20
|
|
|
|
9
|
|
|
|
|
598
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
9
|
|
|
9
|
|
4806
|
use Data::HTML::Element::Utils qw(check_data check_data_type); |
|
|
9
|
|
|
|
|
39
|
|
|
|
9
|
|
|
|
|
247
|
|
|
7
|
9
|
|
|
9
|
|
798
|
use Error::Pure qw(err); |
|
|
9
|
|
|
|
|
18
|
|
|
|
9
|
|
|
|
|
505
|
|
|
8
|
9
|
|
|
9
|
|
56
|
use List::Util 1.33 qw(none); |
|
|
9
|
|
|
|
|
144
|
|
|
|
9
|
|
|
|
|
776
|
|
|
9
|
9
|
|
|
9
|
|
4938
|
use Mo qw(build is); |
|
|
9
|
|
|
|
|
6511
|
|
|
|
9
|
|
|
|
|
98
|
|
|
10
|
9
|
|
|
9
|
|
17491
|
use Mo::utils 0.15 qw(check_array check_strings); |
|
|
9
|
|
|
|
|
186
|
|
|
|
9
|
|
|
|
|
750
|
|
|
11
|
9
|
|
|
9
|
|
5247
|
use Mo::utils::CSS 0.02 qw(check_css_class); |
|
|
9
|
|
|
|
|
110118
|
|
|
|
9
|
|
|
|
|
254
|
|
|
12
|
9
|
|
|
9
|
|
997
|
use Readonly; |
|
|
9
|
|
|
|
|
21
|
|
|
|
9
|
|
|
|
|
2337
|
|
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
Readonly::Array our @TARGETS => qw(_blank _parent _self _top); |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
our $VERSION = 0.17; |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
has css_class => ( |
|
19
|
|
|
|
|
|
|
is => 'ro', |
|
20
|
|
|
|
|
|
|
); |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
has data => ( |
|
23
|
|
|
|
|
|
|
default => [], |
|
24
|
|
|
|
|
|
|
ro => 1, |
|
25
|
|
|
|
|
|
|
); |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
has data_type => ( |
|
28
|
|
|
|
|
|
|
ro => 1, |
|
29
|
|
|
|
|
|
|
); |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
has id => ( |
|
32
|
|
|
|
|
|
|
ro => 1, |
|
33
|
|
|
|
|
|
|
); |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
has target => ( |
|
36
|
|
|
|
|
|
|
ro => 1, |
|
37
|
|
|
|
|
|
|
); |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
has url => ( |
|
40
|
|
|
|
|
|
|
is => 'ro', |
|
41
|
|
|
|
|
|
|
); |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub BUILD { |
|
44
|
21
|
|
|
21
|
0
|
2627500
|
my $self = shift; |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
# Check CSS class. |
|
47
|
21
|
|
|
|
|
119
|
check_css_class($self, 'css_class'); |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
# Check data type. |
|
50
|
21
|
|
|
|
|
443
|
check_data_type($self); |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
# Check data based on type. |
|
53
|
20
|
|
|
|
|
86
|
check_data($self); |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
# Check target. |
|
56
|
17
|
|
|
|
|
84
|
check_strings($self, 'target', \@TARGETS); |
|
57
|
|
|
|
|
|
|
|
|
58
|
16
|
|
|
|
|
261
|
return; |
|
59
|
|
|
|
|
|
|
} |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
1; |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
__END__ |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=pod |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=encoding utf8 |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head1 NAME |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
Data::HTML::Element::A - Data object for HTML a element. |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
use Data::HTML::Element::A; |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
my $obj = Data::HTML::Element::A->new(%params); |
|
78
|
|
|
|
|
|
|
my $css_class = $obj->css_class; |
|
79
|
|
|
|
|
|
|
my $data = $obj->data; |
|
80
|
|
|
|
|
|
|
my $data_type = $obj->data_type; |
|
81
|
|
|
|
|
|
|
my $id = $obj->id; |
|
82
|
|
|
|
|
|
|
my $target = $obj->target; |
|
83
|
|
|
|
|
|
|
my $url = $obj->url; |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head1 METHODS |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head2 C<new> |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
my $obj = Data::HTML::Element::A->new(%params); |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
Constructor. |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=over 8 |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=item * C<css_class> |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
A element CSS class. |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
Default value is undef. |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=item * C<data> |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
Data content. It's reference to array. |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
Data type of data is described in 'data_type' parameter. |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
Default value is []. |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=item * C<data_type> |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
Data type for content. |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
Possible value are: cb plain tags |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
The 'cb' content is code reference. |
|
116
|
|
|
|
|
|
|
The 'plain' content are string(s). |
|
117
|
|
|
|
|
|
|
The 'tags' content is structure described in L<Tags>. |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
Default value is 'plain'. |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=item * C<id> |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
Id. |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
Default value is undef. |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=item * C<target> |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
Target. |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
Possible values are: |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=over |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=item * C<_blank> |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=item * C<_parent> |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=item * C<_self> |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=item * C<_top> |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=back |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
Default value is undef. |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=item * C<url> |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
URL of link. |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
Default value is undef. |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=back |
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
Returns instance of object. |
|
156
|
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=head2 C<css_class> |
|
158
|
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
my $css_class = $obj->css_class; |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
Get CSS class for A element. |
|
162
|
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
Returns string. |
|
164
|
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=head2 C<data> |
|
166
|
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
my $data = $obj->data; |
|
168
|
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
Get data inside button element. |
|
170
|
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
Returns reference to array. |
|
172
|
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
=head2 C<data_type> |
|
174
|
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
my $data_type = $obj->data_type; |
|
176
|
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
Get button data type. |
|
178
|
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
Returns string. |
|
180
|
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
=head2 C<id> |
|
182
|
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
my $id = $obj->id; |
|
184
|
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
Get element id. |
|
186
|
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
Returns string. |
|
188
|
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
=head2 C<url> |
|
190
|
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
my $url = $obj->url; |
|
192
|
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
Get URL of link. |
|
194
|
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
Returns string. |
|
196
|
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
=head1 ERRORS |
|
198
|
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
new(): |
|
200
|
|
|
|
|
|
|
Parameter 'css_class' has bad CSS class name. |
|
201
|
|
|
|
|
|
|
Value: %s |
|
202
|
|
|
|
|
|
|
Parameter 'css_class' has bad CSS class name (number on begin). |
|
203
|
|
|
|
|
|
|
Value: %s |
|
204
|
|
|
|
|
|
|
Parameter 'data' must be a array. |
|
205
|
|
|
|
|
|
|
Value: %s |
|
206
|
|
|
|
|
|
|
Reference: %s |
|
207
|
|
|
|
|
|
|
Parameter 'data' in 'plain' mode must contain reference to array with scalars. |
|
208
|
|
|
|
|
|
|
Parameter 'data' in 'tags' mode must contain reference to array with references to array with Tags structure. |
|
209
|
|
|
|
|
|
|
Parameter 'data_type' has bad value. |
|
210
|
|
|
|
|
|
|
Parameter 'target' must have strings definition. |
|
211
|
|
|
|
|
|
|
Parameter 'target' must have right string definition. |
|
212
|
|
|
|
|
|
|
Parameter 'target' must be one of defined strings. |
|
213
|
|
|
|
|
|
|
String: %s |
|
214
|
|
|
|
|
|
|
Possible strings: %s |
|
215
|
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
=head1 EXAMPLE1 |
|
217
|
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
=for comment filename=a.pl |
|
219
|
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
use strict; |
|
221
|
|
|
|
|
|
|
use warnings; |
|
222
|
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
use Data::HTML::Element::A; |
|
224
|
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
my $obj = Data::HTML::Element::A->new( |
|
226
|
|
|
|
|
|
|
'css_class' => 'link', |
|
227
|
|
|
|
|
|
|
'data' => ['Michal Josef Spacek homepage'], |
|
228
|
|
|
|
|
|
|
'url' => 'https://skim.cz', |
|
229
|
|
|
|
|
|
|
); |
|
230
|
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
# Print out. |
|
232
|
|
|
|
|
|
|
print 'CSS class: '.$obj->css_class."\n"; |
|
233
|
|
|
|
|
|
|
print 'Data: '.(join '', @{$obj->data})."\n"; |
|
234
|
|
|
|
|
|
|
print 'Data type: '.$obj->data_type."\n"; |
|
235
|
|
|
|
|
|
|
print 'URL: '.$obj->url."\n"; |
|
236
|
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
# Output: |
|
238
|
|
|
|
|
|
|
# CSS class: link |
|
239
|
|
|
|
|
|
|
# Data: Michal Josef Spacek homepage |
|
240
|
|
|
|
|
|
|
# Data type: plain |
|
241
|
|
|
|
|
|
|
# URL: https://skim.cz |
|
242
|
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
=head1 EXAMPLE2 |
|
244
|
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
=for comment filename=a_tags.pl |
|
246
|
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
use strict; |
|
248
|
|
|
|
|
|
|
use warnings; |
|
249
|
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
use Data::HTML::Element::A; |
|
251
|
|
|
|
|
|
|
use Tags::Output::Raw; |
|
252
|
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
my $obj = Data::HTML::Element::A->new( |
|
254
|
|
|
|
|
|
|
'css_class' => 'link', |
|
255
|
|
|
|
|
|
|
# Tags(3pm) structure. |
|
256
|
|
|
|
|
|
|
'data' => [ |
|
257
|
|
|
|
|
|
|
['b', 'span'], |
|
258
|
|
|
|
|
|
|
['a', 'class', 'span-link'], |
|
259
|
|
|
|
|
|
|
['d', 'Link'], |
|
260
|
|
|
|
|
|
|
['e', 'span'], |
|
261
|
|
|
|
|
|
|
], |
|
262
|
|
|
|
|
|
|
'data_type' => 'tags', |
|
263
|
|
|
|
|
|
|
'url' => 'https://skim.cz', |
|
264
|
|
|
|
|
|
|
); |
|
265
|
|
|
|
|
|
|
|
|
266
|
|
|
|
|
|
|
my $tags = Tags::Output::Raw->new; |
|
267
|
|
|
|
|
|
|
|
|
268
|
|
|
|
|
|
|
# Serialize data to output. |
|
269
|
|
|
|
|
|
|
$tags->put(@{$obj->data}); |
|
270
|
|
|
|
|
|
|
my $data = $tags->flush(1); |
|
271
|
|
|
|
|
|
|
|
|
272
|
|
|
|
|
|
|
# Print out. |
|
273
|
|
|
|
|
|
|
print 'CSS class: '.$obj->css_class."\n"; |
|
274
|
|
|
|
|
|
|
print 'Data (serialized): '.$data."\n"; |
|
275
|
|
|
|
|
|
|
print 'Data type: '.$obj->data_type."\n"; |
|
276
|
|
|
|
|
|
|
print 'URL: '.$obj->url."\n"; |
|
277
|
|
|
|
|
|
|
|
|
278
|
|
|
|
|
|
|
# Output: |
|
279
|
|
|
|
|
|
|
# CSS class: link |
|
280
|
|
|
|
|
|
|
# Data (serialized): <span class="span-link">Link</span> |
|
281
|
|
|
|
|
|
|
# Data type: tags |
|
282
|
|
|
|
|
|
|
# URL: https://skim.cz |
|
283
|
|
|
|
|
|
|
|
|
284
|
|
|
|
|
|
|
=head1 DEPENDENCIES |
|
285
|
|
|
|
|
|
|
|
|
286
|
|
|
|
|
|
|
L<Data::HTML::Element::Utils>, |
|
287
|
|
|
|
|
|
|
L<Error::Pure>, |
|
288
|
|
|
|
|
|
|
L<List::Util>, |
|
289
|
|
|
|
|
|
|
L<Mo>, |
|
290
|
|
|
|
|
|
|
L<Mo::utils>, |
|
291
|
|
|
|
|
|
|
L<Mo::utils::CSS>. |
|
292
|
|
|
|
|
|
|
|
|
293
|
|
|
|
|
|
|
=head1 REPOSITORY |
|
294
|
|
|
|
|
|
|
|
|
295
|
|
|
|
|
|
|
L<https://github.com/michal-josef-spacek/Data-HTML-Element> |
|
296
|
|
|
|
|
|
|
|
|
297
|
|
|
|
|
|
|
=head1 AUTHOR |
|
298
|
|
|
|
|
|
|
|
|
299
|
|
|
|
|
|
|
Michal Josef Špaček L<mailto:skim@cpan.org> |
|
300
|
|
|
|
|
|
|
|
|
301
|
|
|
|
|
|
|
L<http://skim.cz> |
|
302
|
|
|
|
|
|
|
|
|
303
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
|
304
|
|
|
|
|
|
|
|
|
305
|
|
|
|
|
|
|
© 2022-2024 Michal Josef Špaček |
|
306
|
|
|
|
|
|
|
|
|
307
|
|
|
|
|
|
|
BSD 2-Clause License |
|
308
|
|
|
|
|
|
|
|
|
309
|
|
|
|
|
|
|
=head1 VERSION |
|
310
|
|
|
|
|
|
|
|
|
311
|
|
|
|
|
|
|
0.17 |
|
312
|
|
|
|
|
|
|
|
|
313
|
|
|
|
|
|
|
=cut |