line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTML::Lint::HTML4; |
2
|
|
|
|
|
|
|
|
3
|
39
|
|
|
39
|
|
230
|
use warnings; |
|
39
|
|
|
|
|
66
|
|
|
39
|
|
|
|
|
1027
|
|
4
|
39
|
|
|
39
|
|
154
|
use strict; |
|
39
|
|
|
|
|
53
|
|
|
39
|
|
|
|
|
751
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=head1 NAME |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
HTML::Lint::HTML4 -- Rules for HTML 4 as used by HTML::Lint. |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 SYNOPSIS |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
Collection of tags and attributes for use by HTML::Lint. You can add |
13
|
|
|
|
|
|
|
your own tags and attributes if you like. |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
# Add an attribute that your company uses. |
16
|
|
|
|
|
|
|
HTML::Lint::HTML4::add_attribute( 'body', 'proprietary-attribute' ); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
# Add the HTML 5 |
19
|
|
|
|
|
|
|
HTML::Lint::HTML4::add_tag( 'canvas' ); |
20
|
|
|
|
|
|
|
HTML::Lint::HTML4::add_attribute( 'canvas', $_ ) for qw( height width ); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
This must be done before HTML::Lint does any validation. Note also that |
23
|
|
|
|
|
|
|
this modifies a global table, and is not on a per-object basis. |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=cut |
26
|
|
|
|
|
|
|
|
27
|
39
|
|
|
39
|
|
135
|
use parent 'Exporter'; |
|
39
|
|
|
|
|
57
|
|
|
39
|
|
|
|
|
166
|
|
28
|
|
|
|
|
|
|
our @EXPORT_OK = qw( %isKnownAttribute %isRequired %isNonrepeatable %isObsolete ); |
29
|
|
|
|
|
|
|
|
30
|
3939
|
|
|
3939
|
|
4991
|
sub _hash { return { map { ($_ => 1) } @_ } } |
|
64584
|
|
|
|
|
86518
|
|
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
our @physical = qw( b big code i kbd s small strike sub sup tt u xmp ); |
33
|
|
|
|
|
|
|
our @content = qw( abbr acronym cite code dfn em kbd samp strong var ); |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
our @core = qw( class id style title ); |
36
|
|
|
|
|
|
|
our @i18n = qw( dir lang ); |
37
|
|
|
|
|
|
|
our @events = qw( onclick ondblclick onkeydown onkeypress onkeyup |
38
|
|
|
|
|
|
|
onmousedown onmousemove onmouseout onmouseover onmouseup ); |
39
|
|
|
|
|
|
|
our @std = (@core,@i18n,@events); |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
our %isRequired = %{_hash( qw( html body head title ) )}; |
42
|
|
|
|
|
|
|
our %isNonrepeatable = %{_hash( qw( html head base title body isindex ))}; |
43
|
|
|
|
|
|
|
our %isObsolete = %{_hash( qw( listing plaintext xmp ) )}; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
# Some day I might do something with these. For now, they're just comments. |
46
|
195
|
|
|
195
|
|
463
|
sub _ie_only { return @_ } |
47
|
117
|
|
|
117
|
|
249
|
sub _ns_only { return @_ } |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
our %isKnownAttribute = ( |
50
|
|
|
|
|
|
|
# All the physical markup has the same |
51
|
|
|
|
|
|
|
(map { $_=>_hash(@std) } (@physical, @content) ), |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
a => _hash( @std, qw( accesskey charset coords href hreflang name onblur onfocus rel rev shape tabindex target type ) ), |
54
|
|
|
|
|
|
|
address => _hash( @std ), |
55
|
|
|
|
|
|
|
applet => _hash( @std ), |
56
|
|
|
|
|
|
|
area => _hash( @std, qw( accesskey alt coords href nohref onblur onfocus shape tabindex target ) ), |
57
|
|
|
|
|
|
|
base => _hash( qw( href target ) ), |
58
|
|
|
|
|
|
|
basefont => _hash( qw( color face id size ) ), |
59
|
|
|
|
|
|
|
bdo => _hash( @core, @i18n ), |
60
|
|
|
|
|
|
|
blockquote => _hash( @std, qw( cite ) ), |
61
|
|
|
|
|
|
|
body => _hash( @std, |
62
|
|
|
|
|
|
|
qw( alink background bgcolor link marginheight marginwidth onload onunload text vlink ), |
63
|
|
|
|
|
|
|
_ie_only( qw( bgproperties leftmargin topmargin ) ), |
64
|
|
|
|
|
|
|
), |
65
|
|
|
|
|
|
|
br => _hash( @core, qw( clear ) ), |
66
|
|
|
|
|
|
|
button => _hash( @std, qw( accesskey disabled name onblur onfocus tabindex type value ) ), |
67
|
|
|
|
|
|
|
caption => _hash( @std, qw( align ) ), |
68
|
|
|
|
|
|
|
center => _hash( @std ), |
69
|
|
|
|
|
|
|
cite => _hash(), |
70
|
|
|
|
|
|
|
col => _hash( @std, qw( align char charoff span valign width ) ), |
71
|
|
|
|
|
|
|
colgroup => _hash( @std, qw( align char charoff span valign width ) ), |
72
|
|
|
|
|
|
|
del => _hash( @std, qw( cite datetime ) ), |
73
|
|
|
|
|
|
|
div => _hash( @std, qw( align ) ), |
74
|
|
|
|
|
|
|
dir => _hash( @std, qw( compact ) ), |
75
|
|
|
|
|
|
|
dd => _hash( @std ), |
76
|
|
|
|
|
|
|
dl => _hash( @std, qw( compact ) ), |
77
|
|
|
|
|
|
|
dt => _hash( @std ), |
78
|
|
|
|
|
|
|
embed => _hash( |
79
|
|
|
|
|
|
|
qw( align height hidden name palette quality play src units width ), |
80
|
|
|
|
|
|
|
_ns_only( qw( border hspace pluginspage type vspace ) ), |
81
|
|
|
|
|
|
|
), |
82
|
|
|
|
|
|
|
fieldset => _hash( @std ), |
83
|
|
|
|
|
|
|
font => _hash( @core, @i18n, qw( color face size ) ), |
84
|
|
|
|
|
|
|
form => _hash( @std, qw( accept-charset action enctype method name onreset onsubmit target ) ), |
85
|
|
|
|
|
|
|
frame => _hash( @core, qw( frameborder longdesc marginheight marginwidth name noresize scrolling src ) ), |
86
|
|
|
|
|
|
|
frameset => _hash( @core, qw( cols onload onunload rows border bordercolor frameborder framespacing ) ), |
87
|
|
|
|
|
|
|
h1 => _hash( @std, qw( align ) ), |
88
|
|
|
|
|
|
|
h2 => _hash( @std, qw( align ) ), |
89
|
|
|
|
|
|
|
h3 => _hash( @std, qw( align ) ), |
90
|
|
|
|
|
|
|
h4 => _hash( @std, qw( align ) ), |
91
|
|
|
|
|
|
|
h5 => _hash( @std, qw( align ) ), |
92
|
|
|
|
|
|
|
h6 => _hash( @std, qw( align ) ), |
93
|
|
|
|
|
|
|
head => _hash( @i18n, qw( profile ) ), |
94
|
|
|
|
|
|
|
hr => _hash( @core, @events, qw( align noshade size width ) ), |
95
|
|
|
|
|
|
|
html => _hash( @i18n, qw( version xmlns xml:lang ) ), |
96
|
|
|
|
|
|
|
iframe => _hash( @core, qw( align frameborder height longdesc marginheight marginwidth name scrolling src width ) ), |
97
|
|
|
|
|
|
|
img => _hash( @std, qw( align alt border height hspace ismap longdesc name src usemap vspace width ) ), |
98
|
|
|
|
|
|
|
input => _hash( @std, qw( accept accesskey align alt border checked disabled maxlength name onblur onchange onfocus onselect readonly size src tabindex type usemap value ) ), |
99
|
|
|
|
|
|
|
ins => _hash( @std, qw( cite datetime ) ), |
100
|
|
|
|
|
|
|
isindex => _hash( @core, @i18n, qw( prompt ) ), |
101
|
|
|
|
|
|
|
label => _hash( @std, qw( accesskey for onblur onfocus ) ), |
102
|
|
|
|
|
|
|
legend => _hash( @std, qw( accesskey align ) ), |
103
|
|
|
|
|
|
|
li => _hash( @std, qw( type value ) ), |
104
|
|
|
|
|
|
|
'link' => _hash( @std, qw( charset href hreflang media rel rev target type ) ), |
105
|
|
|
|
|
|
|
'map' => _hash( @std, qw( name ) ), |
106
|
|
|
|
|
|
|
menu => _hash( @std, qw( compact ) ), |
107
|
|
|
|
|
|
|
meta => _hash( @i18n, qw( content http-equiv name scheme ) ), |
108
|
|
|
|
|
|
|
nobr => _hash( @std ), |
109
|
|
|
|
|
|
|
noframes => _hash( @std ), |
110
|
|
|
|
|
|
|
noscript => _hash( @std ), |
111
|
|
|
|
|
|
|
object => _hash( @std, qw( align archive border classid codebase codetype data declare height hspace name standby tabindex type usemap vspace width )), |
112
|
|
|
|
|
|
|
ol => _hash( @std, qw( compact start type ) ), |
113
|
|
|
|
|
|
|
optgroup => _hash( @std, qw( disabled label ) ), |
114
|
|
|
|
|
|
|
option => _hash( @std, qw( disabled label selected value ) ), |
115
|
|
|
|
|
|
|
p => _hash( @std, qw( align ) ), |
116
|
|
|
|
|
|
|
param => _hash( qw( id name type value valuetype ) ), |
117
|
|
|
|
|
|
|
plaintext => _hash(), |
118
|
|
|
|
|
|
|
pre => _hash( @std, qw( width ) ), |
119
|
|
|
|
|
|
|
q => _hash( @std, qw( cite ) ), |
120
|
|
|
|
|
|
|
script => _hash( qw( charset defer event for language src type ) ), |
121
|
|
|
|
|
|
|
'select' => _hash( @std, qw( disabled multiple name onblur onchange onfocus size tabindex ) ), |
122
|
|
|
|
|
|
|
span => _hash( @std ), |
123
|
|
|
|
|
|
|
style => _hash( @i18n, qw( media title type ) ), |
124
|
|
|
|
|
|
|
table => _hash( @std, |
125
|
|
|
|
|
|
|
qw( align bgcolor border cellpadding cellspacing datapagesize frame rules summary width ), |
126
|
|
|
|
|
|
|
_ie_only( qw( background bordercolor bordercolordark bordercolorlight ) ), |
127
|
|
|
|
|
|
|
_ns_only( qw( bordercolor cols height hspace vspace ) ), |
128
|
|
|
|
|
|
|
), |
129
|
|
|
|
|
|
|
tbody => _hash( @std, qw( align char charoff valign ) ), |
130
|
|
|
|
|
|
|
td => _hash( @std, |
131
|
|
|
|
|
|
|
qw( abbr align axis bgcolor char charoff colspan headers height nowrap rowspan scope valign width ), |
132
|
|
|
|
|
|
|
_ie_only( qw( background bordercolor bordercolordark bordercolorlight ) ), |
133
|
|
|
|
|
|
|
), |
134
|
|
|
|
|
|
|
textarea => _hash( @std, qw( accesskey cols disabled name onblur onchange onfocus onselect readonly rows tabindex wrap ) ), |
135
|
|
|
|
|
|
|
th => _hash( @std, |
136
|
|
|
|
|
|
|
qw( abbr align axis bgcolor char charoff colspan headers height nowrap rowspan scope valign width ), |
137
|
|
|
|
|
|
|
_ie_only( qw( background bordercolor bordercolordark bordercolorlight ) ), |
138
|
|
|
|
|
|
|
), |
139
|
|
|
|
|
|
|
thead => _hash( @std, qw( align char charoff valign ) ), |
140
|
|
|
|
|
|
|
tfoot => _hash( @std, qw( align char charoff valign ) ), |
141
|
|
|
|
|
|
|
title => _hash( @i18n ), |
142
|
|
|
|
|
|
|
tr => _hash( @std, |
143
|
|
|
|
|
|
|
qw( align bgcolor char charoff valign ), |
144
|
|
|
|
|
|
|
_ie_only( qw( bordercolor bordercolordark bordercolorlight nowrap ) ), |
145
|
|
|
|
|
|
|
_ns_only( qw( nowrap ) ), |
146
|
|
|
|
|
|
|
), |
147
|
|
|
|
|
|
|
ul => _hash( @std, qw( compact type ) ), |
148
|
|
|
|
|
|
|
); |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=head1 FUNCTIONS |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
The functions below are very specifically not exported, and need to be |
154
|
|
|
|
|
|
|
called with a complete package reference, so as to remind the programmer |
155
|
|
|
|
|
|
|
that she is monkeying with the entire package. |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=head2 add_tag( $tag ); |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
Adds a tag to the list of tags that HTML::Lint knows about. If you |
160
|
|
|
|
|
|
|
specify a tag that HTML::Lint already knows about, then nothing is |
161
|
|
|
|
|
|
|
changed. |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
HTML::Lint::HTML4::add_tag( 'canvas' ); |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=cut |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
sub add_tag { |
168
|
1
|
|
|
1
|
1
|
3
|
my $tag = shift; |
169
|
|
|
|
|
|
|
|
170
|
1
|
50
|
|
|
|
3
|
if ( !$isKnownAttribute{ $tag } ) { |
171
|
1
|
|
|
|
|
2
|
$isKnownAttribute{ $tag } = {}; |
172
|
|
|
|
|
|
|
} |
173
|
|
|
|
|
|
|
|
174
|
1
|
|
|
|
|
2
|
return; |
175
|
|
|
|
|
|
|
} |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
=head2 add_attribute( $tag, $attribute ); |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
Adds an attribute to a tag that HTML::Lint knows about. The tag must |
181
|
|
|
|
|
|
|
already be known to HTML::Lint or else this function will die. |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
HTML::Lint::HTML4::add_attribute( 'canvas', $_ ) for qw( height width ); |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
=cut |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
sub add_attribute { |
188
|
3
|
|
|
3
|
1
|
63
|
my $tag = shift; |
189
|
3
|
|
|
|
|
4
|
my $attr = shift; |
190
|
|
|
|
|
|
|
|
191
|
3
|
|
50
|
|
|
9
|
my $attrs = $isKnownAttribute{ $tag } || die "Tag $tag is unknown"; |
192
|
|
|
|
|
|
|
|
193
|
3
|
|
|
|
|
5
|
$isKnownAttribute{ $tag }->{ $attr } = 1; |
194
|
|
|
|
|
|
|
|
195
|
3
|
|
|
|
|
6
|
return; |
196
|
|
|
|
|
|
|
} |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
1; |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
__END__ |