line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
##---------------------------------------------------------------------------- |
2
|
|
|
|
|
|
|
## HTML Object - ~/lib/HTML/Object/Comment.pm |
3
|
|
|
|
|
|
|
## Version v0.2.0 |
4
|
|
|
|
|
|
|
## Copyright(c) 2021 DEGUEST Pte. Ltd. |
5
|
|
|
|
|
|
|
## Author: Jacques Deguest <jack@deguest.jp> |
6
|
|
|
|
|
|
|
## Created 2021/04/19 |
7
|
|
|
|
|
|
|
## Modified 2022/09/18 |
8
|
|
|
|
|
|
|
## All rights reserved |
9
|
|
|
|
|
|
|
## |
10
|
|
|
|
|
|
|
## |
11
|
|
|
|
|
|
|
## This program is free software; you can redistribute it and/or modify it |
12
|
|
|
|
|
|
|
## under the same terms as Perl itself. |
13
|
|
|
|
|
|
|
##---------------------------------------------------------------------------- |
14
|
|
|
|
|
|
|
package HTML::Object::Comment; |
15
|
|
|
|
|
|
|
BEGIN |
16
|
|
|
|
|
|
|
{ |
17
|
29
|
|
|
29
|
|
202
|
use strict; |
|
29
|
|
|
|
|
62
|
|
|
29
|
|
|
|
|
904
|
|
18
|
29
|
|
|
29
|
|
140
|
use warnings; |
|
29
|
|
|
|
|
65
|
|
|
29
|
|
|
|
|
738
|
|
19
|
29
|
|
|
29
|
|
150
|
use warnings::register; |
|
29
|
|
|
|
|
46
|
|
|
29
|
|
|
|
|
3806
|
|
20
|
29
|
|
|
29
|
|
200
|
use parent qw( HTML::Object::Element ); |
|
29
|
|
|
|
|
63
|
|
|
29
|
|
|
|
|
190
|
|
21
|
29
|
|
|
29
|
|
1861
|
use vars qw( $VERSION ); |
|
29
|
|
|
|
|
122
|
|
|
29
|
|
|
|
|
1197
|
|
22
|
29
|
|
|
29
|
|
557
|
our $VERSION = 'v0.2.0'; |
23
|
|
|
|
|
|
|
}; |
24
|
|
|
|
|
|
|
|
25
|
29
|
|
|
29
|
|
141
|
use strict; |
|
29
|
|
|
|
|
49
|
|
|
29
|
|
|
|
|
494
|
|
26
|
29
|
|
|
29
|
|
122
|
use warnings; |
|
29
|
|
|
|
|
54
|
|
|
29
|
|
|
|
|
8745
|
|
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub init |
29
|
|
|
|
|
|
|
{ |
30
|
7
|
|
|
7
|
1
|
105
|
my $self = shift( @_ ); |
31
|
7
|
|
|
|
|
145
|
$self->{open_seq} = '<!--'; |
32
|
7
|
|
|
|
|
46
|
$self->{close_seq} = '-->'; |
33
|
7
|
|
|
|
|
35
|
$self->{tag} = '_comment'; |
34
|
7
|
|
|
|
|
21
|
$self->{value} = ''; |
35
|
7
|
|
|
|
|
29
|
$self->{is_empty} = 1; |
36
|
7
|
|
|
|
|
20
|
$self->{_init_strict_use_sub} = 1; |
37
|
7
|
|
|
|
|
21
|
$self->{_exception_class} = 'HTML::Object::Exception'; |
38
|
7
|
50
|
|
|
|
67
|
$self->SUPER::init( @_ ) || return( $self->pass_error ); |
39
|
7
|
|
|
|
|
47
|
return( $self ); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub as_string |
43
|
|
|
|
|
|
|
{ |
44
|
1
|
|
|
1
|
1
|
123
|
my $self = shift( @_ ); |
45
|
|
|
|
|
|
|
# We need to remove the reset flag, otherwise if there are any subsequent change that need to be propagated to this comment parent, HTML::Object::Element::reset will not propagate it |
46
|
1
|
|
|
|
|
10
|
$self->_remove_reset; |
47
|
|
|
|
|
|
|
return( |
48
|
1
|
50
|
|
|
|
5
|
$self->value->length |
49
|
|
|
|
|
|
|
? $self->new_scalar( join( '', '<!--', $self->value->scalar, '-->' ) ) |
50
|
|
|
|
|
|
|
: $self->original |
51
|
|
|
|
|
|
|
); |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub as_xml |
55
|
|
|
|
|
|
|
{ |
56
|
0
|
|
|
0
|
1
|
0
|
my $self = shift( @_ ); |
57
|
0
|
0
|
|
|
|
0
|
my $txt = $self->value->length |
58
|
|
|
|
|
|
|
? $self->new_scalar( join( '', '<!--', $self->value->scalar, '-->' ) ) |
59
|
|
|
|
|
|
|
: $self->original; |
60
|
|
|
|
|
|
|
# HTML::Element says there cannot be double --'s in XML comments |
61
|
0
|
|
|
|
|
0
|
$txt->replace( qr/--/, '--' ); |
62
|
0
|
|
|
|
|
0
|
return( $txt ); |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
0
|
|
|
0
|
1
|
0
|
sub close_seq { return( shift->_set_get_scalar_as_object( 'close_seq', @_ ) ); } |
66
|
|
|
|
|
|
|
|
67
|
0
|
|
|
0
|
1
|
0
|
sub open_seq { return( shift->_set_get_scalar_as_object( 'open_seq', @_ ) ); } |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub set_checksum |
70
|
|
|
|
|
|
|
{ |
71
|
7
|
|
|
7
|
1
|
28
|
my $self = shift( @_ ); |
72
|
7
|
|
|
|
|
38
|
return( $self->_get_md5_hash( $self->value->scalar ) ); |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
17
|
|
|
17
|
1
|
165750
|
sub value : lvalue { return( shift->_set_get_scalar_as_object( 'value', @_ ) ); } |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
1; |
78
|
|
|
|
|
|
|
# NOTE: POD |
79
|
|
|
|
|
|
|
__END__ |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=encoding utf-8 |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head1 NAME |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
HTML::Object::Comment - HTML Object Comment Element Class |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head1 SYNOPSIS |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
use HTML::Object::Comment; |
90
|
|
|
|
|
|
|
my $this = HTML::Object::Comment->new || |
91
|
|
|
|
|
|
|
die( HTML::Object::Comment->error, "\n" ); |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head1 VERSION |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
v0.2.0 |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head1 DESCRIPTION |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
This module represents an HTML comment |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head1 INHERITANCE |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
+-----------------------+ +-----------------------+ |
104
|
|
|
|
|
|
|
| HTML::Object::Element | --> | HTML::Object::Comment | |
105
|
|
|
|
|
|
|
+-----------------------+ +-----------------------+ |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head1 PROPERTIES |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head2 nodeValue |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
This returns or sets the value of the current node. |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
For document, element or collection, this returns C<undef> and for attribute, text or comment, this returns the objct value. |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
See L<for more information|https://developer.mozilla.org/en-US/docs/Web/API/Node/nodeValue> |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head1 METHODS |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head2 as_string |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
Returns the HTML comment as a string. |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=head2 as_xml |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
Returns the comment as an XML string., which is almost the same format as with L</as_string> |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=head2 close_seq |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
Set or get the string used as a close sequence. |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=head2 isEqualNode |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
Returns a boolean value which indicates whether or not two elements are of the same type and all their defining data points match. |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
Two elements are equal when they have the same type, defining characteristics (this would be their ID, number of children, and so forth), its attributes match, and so on. The specific set of data points that must match varies depending on the types of the elements. |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
See L<for more information|https://developer.mozilla.org/en-US/docs/Web/API/Node/isEqualNode> |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=head2 nodeValue |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
This returns or sets the value of the current element. |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
See L<for more information|https://developer.mozilla.org/en-US/docs/Web/API/Node/nodeValue> |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=head2 open_seq |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
Set or get the string used as an open sequence. |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=head2 set_checksum |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
Read-only. |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
Get the element md5 checksum for the current value. |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=head2 value |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
Set or get the comment inner value, i.e. the text within, as a L<scalar object|Module::Generic::Scalar> |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=head1 AUTHOR |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
Jacques Deguest E<lt>F<jack@deguest.jp>E<gt> |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=head1 SEE ALSO |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
L<https://html.spec.whatwg.org/multipage/syntax.html#the-doctype> |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
L<https://developer.mozilla.org/en-US/docs/Web/HTML/Quirks_Mode_and_Standards_Mode> |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
L<HTML::Object>, L<HTML::Object::Attribute>, L<HTML::Object::Boolean>, L<HTML::Object::Closing>, L<HTML::Object::Collection>, L<HTML::Object::Comment>, L<HTML::Object::Declaration>, L<HTML::Object::Document>, L<HTML::Object::Element>, L<HTML::Object::Exception>, L<HTML::Object::Literal>, L<HTML::Object::Number>, L<HTML::Object::Root>, L<HTML::Object::Space>, L<HTML::Object::Text>, L<HTML::Object::XQuery> |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
Copyright (c) 2021 DEGUEST Pte. Ltd. |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
All rights reserved |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. |