File Coverage

blib/lib/HTML/Lint/Pluggable/HTML5.pm
Criterion Covered Total %
statement 26 28 92.8
branch 8 10 80.0
condition n/a
subroutine 9 9 100.0
pod 0 1 0.0
total 43 48 89.5


line stmt bran cond sub pod time code
1             package HTML::Lint::Pluggable::HTML5;
2 1     1   615 use 5.008_001;
  1         3  
3 1     1   4 use strict;
  1         1  
  1         18  
4 1     1   3 use warnings;
  1         1  
  1         43  
5              
6             our $VERSION = '0.08';
7              
8 1     1   4 use parent qw/ HTML::Lint::Pluggable::WhiteList /;
  1         1  
  1         6  
9 1     1   483 use List::MoreUtils qw/any/;
  1         6682  
  1         6  
10              
11             my %html5_tag = map { $_ => 1 } qw/article aside audio bdi canvas command datalist details dialog embed figcaption figure footer header hgroup keygen main mark menu menuitem meter nav output progress section source summary template time track video rb rp rt rtc ruby wbr/;
12              
13             my %html5_global_attr = map { $_ => 1 } qw/contenteditable contextmenu draggable dropzone hidden role spellcheck tabindex translate/;
14             my @html5_global_user_attr = (qr/^aria-/, qr/^data-/);
15             my %html5_attr = (
16             a => +{ map { $_ => 1 } qw/media/ },
17             area => +{ map { $_ => 1 } qw/media hreflang rel/ },
18             base => +{ map { $_ => 1 } qw/target/ },
19             meta => +{ map { $_ => 1 } qw/charset/ },
20             input => +{ map { $_ => 1 } qw/autofocus placeholder form required autocomplete min max multiple pattern step dirname formaction formenctype formmethod formnovalidate formtarget/ },
21             select => +{ map { $_ => 1 } qw/autofocus form required/ },
22             textarea => +{ map { $_ => 1 } qw/autofocus placeholder form required dirname maxlength wrap/ },
23             button => +{ map { $_ => 1 } qw/form autofocus formaction formenctype formmethod formnovalidate formtarget/ },
24             output => +{ map { $_ => 1 } qw/form/ },
25             label => +{ map { $_ => 1 } qw/form/ },
26             object => +{ map { $_ => 1 } qw/form/ },
27             fieldset => +{ map { $_ => 1 } qw/form disabled/ },
28             form => +{ map { $_ => 1 } qw/novalidate/ },
29             menu => +{ map { $_ => 1 } qw/type label/ },
30             style => +{ map { $_ => 1 } qw/scoped/ },
31             script => +{ map { $_ => 1 } qw/async/ },
32             html => +{ map { $_ => 1 } qw/manifest/ },
33             link => +{ map { $_ => 1 } qw/sizes/ },
34             ol => +{ map { $_ => 1 } qw/reversed/ },
35             iframe => +{ map { $_ => 1 } qw/sandbox seamless srcdoc allowfullscreen/ },
36             );
37              
38             # Generated by html5_entities.pl
39             my %html5_entity = map { "&" . $_ . ";" => 1 } qw/ frac13 supE gtcc filig boxdr
40             DownLeftTeeVector Rscr ggg larrfs simg SHcy Verbar dfisht qopf boxvl lat
41             VDash dfr rdquor boxDl vsubne isindot Rsh Ofr suphsub Ncy bcy timesb prnE
42             starf TildeEqual zfr cire supset ShortUpArrow EqualTilde acy NotTildeEqual
43             Breve gnE wreath supdot nbump lrarr NotNestedGreaterGreater Zopf CirclePlus
44             lotimes circledast eqslantgtr nprcue Hfr gtreqless LeftRightArrow
45             upharpoonleft escr ThickSpace Updownarrow khcy nearr DiacriticalAcute equest
46             nsupset npolint curarrm lrhar suplarr gesdot gtrdot dopf triplus ngt Hopf
47             bsime ominus SquareUnion boxHU Uscr xrArr nvlArr CircleTimes pluse homtht
48             triminus complement LeftTee midcir boxvR IEcy Wscr Qopf nsupe gnap iiiint
49             circeq olcir LeftDownVectorBar supsup mscr ncap triangleq nleftarrow Mcy
50             nsucc varr Equal urcorner RightVector NestedGreaterGreater LeftDownTeeVector
51             Downarrow LowerLeftArrow nrArr TildeFullEqual setminus Integral pre vsubnE
52             forkv nle Conint boxh odash LessTilde twoheadleftarrow HARDcy Escr tridot
53             srarr ohm NotGreaterFullEqual oscr ell Ccaron emptyset Lscr rscr rBarr
54             DiacriticalTilde twixt gneqq lhblk Emacr LessLess block Sfr Tcaron
55             PrecedesTilde IOcy backepsilon precneqq Uogon gel boxdR nvge cirE divonx rcy
56             Abreve Assign UnionPlus frac45 Ncedil zopf complexes
57             CounterClockwiseContourIntegral quatint larrlp zhcy ngeqq sdote jopf cupdot
58             Lt boxur boxuL naturals DD vrtri gtcir blacktriangleright circledR swArr
59             lesdot nbumpe searrow updownarrow ltquest Fouriertrf check nsube Lcy
60             DoubleContourIntegral gopf dashv Wopf rtriltri boxvH lobrk boxdl yscr
61             PlusMinus curvearrowleft Square shortmid subseteqq nsup planckh circledS
62             tritime NotLessTilde nltri natural gcirc el boxhd iopf Leftrightarrow mcy
63             thetav capbrcup SucceedsTilde DownRightVectorBar lharu Colon Rcaron dollar
64             uogon LeftArrowBar bcong olarr triangle smashp blacktriangle
65             LeftUpDownVector les nfr SquareSubsetEqual prec xoplus preccurlyeq solbar
66             rnmid odsold Pscr Equilibrium rx larrtl Star eqvparsl egsdot Lopf pcy lharul
67             dharl lesg lAtail UnderBar ufr bigtriangleup RightUpDownVector profalar
68             cirscir nvDash gla QUOT eqsim simrarr gdot capdot upsi NotLess wscr epar
69             sqcups succcurlyeq Succeeds supseteq nrarrc NegativeThickSpace ratail ncup
70             nlE notinvc leqq leg comp andslope oint DoubleLongLeftArrow rharul mfr
71             SquareSubset Omacr leftleftarrows curlyvee duarr LeftFloor llhard zdot
72             longleftarrow LeftArrowRightArrow mho ntgl xuplus LT ncy sc centerdot
73             Congruent larrsim smid NotLessGreater gvertneqq cupbrcap leftrightsquigarrow
74             trpezium colon LeftTeeArrow varnothing vprop gtreqqless plusdo nsce xutri
75             Upsi sqsube between Gt ncongdot CloseCurlyDoubleQuote sqcup nsubseteq Ncaron
76             RightTeeArrow csup ngeqslant ultri ord LeftDownVector Rfr DoubleLeftArrow
77             nwarr imath nVDash larrpl Gdot infintie nlarr sscr DScy Kfr curlyeqsucc
78             DiacriticalGrave GJcy gtrarr DownArrow UpArrow plussim Implies ntriangleleft
79             NotSucceeds dzigrarr urcrop DoubleLongRightArrow RightTriangleBar backsimeq
80             nap rightarrow xlarr SuchThat Hacek nsime DownTee larrb PrecedesSlantEqual
81             gjcy bigoplus ac pluscir rarrb eogon NotSquareSubsetEqual prnsim andd hairsp
82             ffilig RightDownVectorBar And doteqdot rcub sopf nlArr ltri bigcirc Bcy sext
83             angle frac16 boxvh scpolint Aogon DownBreve zeetrf kopf Re nearhk rmoustache
84             Nfr lvnE NotSquareSupersetEqual racute Lang nwnear NotEqualTilde subsetneq
85             imacr curlywedge DoubleUpArrow dot imof leftarrowtail eDot sqsub hybull tosa
86             odiv Mellintrf ddagger frac56 VeryThinSpace ltrif lsquor clubsuit nges
87             expectation Bfr realine dharr xodot NotNestedLessLess ffr Ascr ldsh Map
88             nltrie simgE period NotSuperset DoubleLongLeftRightArrow pfr supne Nscr
89             marker Topf blacktriangledown dsol subset bsol Gopf bsim DoubleVerticalBar
90             Cacute andand aopf NewLine veebar CHcy angsph bopf ShortDownArrow eng
91             dotsquare inodot boxvr half frac35 NotRightTriangleEqual notnivb puncsp
92             dlcrop subplus flat straightphi rbrace VerticalTilde gesles bkarow Ll scnsim
93             Wfr Ucy ogt div Barwed ntrianglelefteq ssmile tcy RightArrowBar Rarr lessgtr
94             timesbar swarrow UpArrowBar Cconint curvearrowright olcross iprod cacute
95             Otimes tstrok nsccue strns CenterDot ohbar lrcorner plus gesl fopf npreceq
96             hscr LeftVector Rrightarrow multimap sccue Idot Jscr ovbar vopf xopf Acy lcy
97             nvgt Hstrok Vee Ufr NotRightTriangleBar boxUr nLtv Ycy kjcy jcirc geqslant
98             backsim rtri RightArrow csube glE Gscr sigmav TSHcy Rang UnderBrace
99             varsupsetneqq tshcy cwint late Wedge mid dotminus angmsdaf phiv mldr ecir
100             FilledSmallSquare cups boxDL TRADE DoubleRightArrow vartheta topf
101             GreaterEqual aogon Gg ijlig erDot rfr NegativeVeryThinSpace lE
102             NotLeftTriangleEqual YUcy doteq RoundImplies Mscr digamma Vcy shchcy
103             ContourIntegral Qscr angmsdac hopf subsup smallsetminus Wcirc triangleright
104             yucy gE boxDr blacklozenge succeq notniva nleftrightarrow RightDownTeeVector
105             ofcir lsh rhard lozf uscr subE copf Coproduct square bNot DownRightVector
106             amacr KJcy equals supsub yfr hardcy Ffr Zcy succnapprox simeq rationals
107             mnplus fork GreaterSlantEqual xdtri odot jmath vsupne awconint nleqq Lcaron
108             Dopf epsi acd xvee eparsl csub lnsim ncedil quaternions nldr rarrlp excl
109             Bernoullis lbarr ring rightarrowtail boxUl rightrightarrows lcaron notinva
110             LeftTriangle emsp14 Cup Lleftarrow Esim boxuR phone Lsh emptyv ccaps
111             mapstoup barwed larrbfs vsupnE vzigzag vcy ycirc Kcedil pertenk Xfr bigwedge
112             cirmid boxul Zdot veeeq bbrk NotGreaterTilde boxplus ddotseq RightTee hbar
113             profsurf lbrkslu angmsd esdot lfr scirc LeftTriangleEqual lhard leftarrow
114             lEg NotPrecedes Yscr leftrightarrow xcup ltrPar rlhar risingdotseq comma
115             roang dblac submult cross rhov NotEqual fpartint rangd gnsim sqcap zcaron
116             frac25 lgE larrhk star succsim Nopf Vbar NotLessLess Copf subseteq bumpE
117             diamondsuit wedgeq nsubseteqq lmidot commat DoubleLeftTee LeftTriangleBar
118             Cdot cir DifferentialD suphsol subdot iukcy gnapprox lrtri uharl vBarv harrw
119             Tab CloseCurlyQuote topcir elsdot ropar Rcedil gammad xwedge bigstar orv
120             Edot Fopf UpDownArrow thksim bowtie YAcy NotGreaterLess cdot iogon zacute
121             RightCeiling amalg xharr gtrapprox Cscr target Rcy caron mapstodown lurdshar
122             notinE npr lneqq kfr CircleMinus gescc ltcir Because Tilde succneqq
123             RightTriangleEqual Kscr lacute DotDot olt nLt lesdoto bot wedge precsim
124             luruhar Longleftarrow NegativeThinSpace semi ClockwiseContourIntegral range
125             lrhard angmsdag Iogon fltns boxdL abreve OverParenthesis iecy
126             DoubleUpDownArrow bscr conint boxhD ZHcy cupor bprime iiint NotGreaterEqual
127             Vscr sdotb rrarr Ubrcy mapstoleft Sup LJcy ZeroWidthSpace lthree
128             longleftrightarrow Rarrtl UpEquilibrium Diamond hstrok uparrow Vfr angzarr
129             gtlPar approxeq smtes downharpoonleft hcirc ssetmn bigcap npre
130             NotTildeFullEqual die UpTee nsupseteq simlE sacute Jsercy uwangle cuwed
131             napprox NotDoubleVerticalBar angrtvbd Dfr operp cularr scE roarr jsercy
132             rightharpoondown varepsilon rpargt wcirc nsim boxVL loplus Darr ll Iscr
133             angrtvb geq xlArr smeparsl fllig nrtrie gimel lopar dcaron ldrdhar Sub
134             InvisibleComma chcy angmsdaa backcong intlarhk GreaterEqualLess bnequiv
135             NotSucceedsEqual gtquest solb boxUR nscr lagran LeftArrow Subset urtri
136             nrightarrow parsim Cfr roplus boxvL ApplyFunction varpi DownTeeArrow
137             InvisibleTimes circlearrowleft gfr circledcirc ocir parallel verbar mapsto
138             Imacr iff approx frac18 leftrightharpoons wr lessdot wopf iocy uhblk numero
139             male trisb rsh NotVerticalBar Tcy ocy cuepr nsmid EmptySmallSquare
140             NotSupersetEqual DJcy lessapprox rarrap reals simne cudarrr subsetneqq GT
141             bemptyv sqsupset egs nparsl rAtail opar MinusPlus nleqslant ngE ddarr ffllig
142             NotSubset incare uuarr Dstrok Rightarrow downarrow LessFullEqual Sopf slarr
143             oS NotPrecedesSlantEqual boxH lsimg barwedge longmapsto Itilde
144             SucceedsSlantEqual nharr SucceedsEqual Oopf UnderBracket spar lates because
145             NotLessEqual plankv iinfin NotLeftTriangle coprod rtrie mp yacy caps
146             trianglelefteq supdsub natur nexists apid bsemi rarrw Jcy squ dstrok rbrkslu
147             becaus beth nLeftarrow efDot prap nleq ofr bump ulcorn top supnE ubreve
148             NotHumpDownHump Del wfr vfr ifr Gbreve swarhk nesim quest Tfr neArr
149             LeftVectorBar Icy Ifr dtrif nopf ii eDDot boxVR Element swnwar Jfr
150             ntrianglerighteq Intersection COPY nesear Lfr gcy kcy Zacute Ecaron rbarr
151             ImaginaryI cupcap LT NotCongruent Dcaron vltri nvltrie cscr Uarr Exists
152             HorizontalLine mcomma bernou Ropf leqslant xmap lnE nvdash boxminus rbrack
153             caret upharpoonright dscy ldrushar lne utilde nsc gsiml notindot scap
154             backprime nvrtrie minusdu topfork ForAll LeftCeiling langle ecy models
155             rarrtl vee djcy NotTilde icy dotplus SquareSupersetEqual ShortLeftArrow
156             llarr prurel isins Vert lcedil nsubset geqq ThinSpace robrk nrarrw pointint
157             Umacr ee boxVh nLeftrightarrow rarrbfs Fcy Xscr OverBracket gsime REG
158             circleddash ic varsupsetneq GreaterFullEqual Longrightarrow npar vArr mopf
159             oopf Scirc hslash napos hercon barvee LeftDoubleBracket blank lHar Dashv
160             eplus nvrArr Laplacetrf longrightarrow uopf origof capand boxV LeftUpVector
161             ltdot rarrsim rthree downdownarrows disin varpropto gap sqsupe pscr Lcedil
162             lmoust esim acE SmallCircle rsquor Proportion Eogon vDash tdot capcap rsqb
163             dscr VerticalLine Supset lbrack kgreen Scy zscr NJcy scy NotExists csupe
164             hkswarow boxHD Ecy gsim dzcy vellip Mopf LeftUpTeeVector lfisht andv Gammad
165             OpenCurlyQuote blk12 rdsh lopf tfr emsp13 cemptyv erarr boxVl boxhu Efr nvle
166             thicksim imped SOFTcy bepsi Barv drbkarow ruluhar ogon imagpart drcorn
167             laemptyv zigrarr ascr nearrow cylcty Ocy prE cuesc UnderParenthesis it ast
168             Gcirc profline OverBrace RightUpVector blacktriangleleft vartriangleleft Hat
169             bigodot rbbrk Jcirc Sqrt Jukcy nrtri looparrowleft nge eqcolon AMP Product
170             sqsubseteq compfn HumpEqual RightUpTeeVector bumpe NotPrecedesEqual
171             curlyeqprec demptyv odblac Dot rdca Afr xsqcup rightleftharpoons
172             OpenCurlyDoubleQuote sfrown varsubsetneqq rharu circlearrowright breve
173             wedbar kscr TildeTilde GreaterLess niv scedil Jopf oast RightFloor Vdash
174             ljcy SubsetEqual Bumpeq qint therefore simdot bigsqcup utri MediumSpace
175             looparrowright vBar timesd fflig par vnsub ntlg squarf Iopf LeftUpVectorBar
176             LessGreater Tcedil umacr Hscr dtri LongRightArrow midast ycy ENG Dscr ltcc
177             nrarr SupersetEqual RightArrowLeftArrow scnE ntriangleright nwarhk kcedil
178             dtdot daleth udblac GreaterGreater NotElement Or leftrightarrows boxUL
179             vangrt lcub tbrk ucy otimesas wp sung sqcaps succapprox ropf nlsim Yopf
180             boxHd udarr frac78 blacksquare rightsquigarrow Scedil xnis smt squf Popf GT
181             rmoust NotGreater xfr hyphen LeftTeeVector ltimes Lacute nsubE lvertneqq
182             rlarr lsime gtrless rfisht ape iscr nspar Superset subnE UpperRightArrow
183             questeq hamilt LowerRightArrow sqsupseteq rcaron VerticalBar nGtv tscy
184             Odblac DownLeftVectorBar pm llcorner notnivc emacr VerticalSeparator Udblac
185             DownRightTeeVector isinE notni omid vartriangleright NotTildeTilde topbot
186             rightharpoonup subne itilde tprime EmptyVerySmallSquare Vopf
187             ReverseEquilibrium edot latail xrarr iiota afr af rppolint qfr Poincareplane
188             gacute Colone Kopf dwangle gneq nvap vdash Cross subsim epsiv nis ncaron
189             Uring Sc qscr rotimes nhArr Leftarrow Aopf SHCHcy LeftAngleBracket rarrfs
190             Zcaron xhArr horbar DownLeftRightVector supplus gEl Ubreve hookrightarrow
191             sqsup copysr intcal LongLeftRightArrow prsim DiacriticalDoubleAcute rpar
192             fscr lAarr nVdash bsolhsub tcaron spadesuit utrif sharp bullet Bscr AMP
193             maltese num xotime pitchfork bigotimes ReverseElement bne cwconint
194             leftharpoondown ccupssm plustwo FilledVerySmallSquare lesseqgtr IJlig
195             nwarrow Kcy orslope bbrktbrk setmn leq frac38 Ccirc NotLeftTriangleBar
196             ulcorner succnsim glj Sscr cuvee fallingdotseq TripleDot Tstrok CircleDot
197             Dcy boxHu nGt vert Uarrocir uplus ReverseUpEquilibrium parsl cirfnint
198             plusacir bigcup Pr boxVr curarr rHar ngtr langd preceq RightUpVectorBar jscr
199             nsucceq lesges gbreve SquareSuperset sstarf bsolb ldquor NotSucceedsTilde
200             angmsdae RightDownVector rangle lap isinsv eqslantless lltri
201             NotGreaterGreater boxtimes utdot varkappa upuparrows bigvee capcup
202             NotReverseElement Union telrec angmsdah lesdotor ratio nless lneq
203             precnapprox NonBreakingSpace easter lozenge ltrie gne urcorn nlt harrcir
204             rcedil NotCupCap nacute vscr Backslash grave supsetneq LeftRightVector
205             NotSquareSubset ccirc frac15 Int nRightarrow ufisht frac58 loang Ycirc
206             nsimeq RightTriangle DoubleDownArrow orderof numsp supsim duhar ctdot lparlt
207             lnap order boxDR tint minusd female Cedilla DoubleDot bnot Fscr DotEqual
208             ubrcy nshortparallel PartialD nsqsupe gtdot Amacr xscr UpperLeftArrow Gfr
209             apE race NotHumpEqual Hcirc popf elinters lBarr planck gl eopf toea
210             straightepsilon dbkarow ecolon shortparallel scsim LongLeftArrow uring sfr
211             bumpeq eqcirc Precedes precapprox nles simplus RBarr yicy Cap HumpDownHump
212             nparallel softcy sqsubset Lstrok rightthreetimes xcap Utilde seswar
213             NegativeMediumSpace dHar supmult Oscr nang tscr doublebarwedge lbrace ccaron
214             NotSquareSuperset scnap hoarr lesseqqgtr ulcrop map kappav prcue TScy Racute
215             intprod dd awint lscr Mfr aleph CapitalDifferentialD searr Gcy lowbar in
216             LessSlantEqual colone nvlt Larr twoheadrightarrow supseteqq subsub
217             trianglerighteq drcrop els ltlarr rarrc nvsim napE cularrp thkap
218             varsubsetneq percnt DownLeftVector njcy mumap malt intercal plusb
219             HilbertSpace Zfr phmmat sce lsqb lesssim integers NestedLessLess ange udhar
220             PrecedesEqual gscr gesdoto angmsdab propto angst nequiv RightVectorBar KHcy
221             Pfr OverBar DoubleLeftRightArrow CupCap Uopf Im REG frown subrarr YIcy
222             varrho nsqsube lsim COPY nsupE Pcy ccups Therefore measuredangle UpTeeArrow
223             nprec lescc raemptyv NotSucceedsSlantEqual bottom lstrok cupcup
224             UpArrowDownArrow RightAngleBracket diam tcedil blk34 loarr lg DDotrahd
225             rarrhk Qfr ges nvinfin fcy efr GreaterTilde hfr DownArrowUpArrow rbrke
226             Vvdash downharpoonright SquareIntersection divideontimes Tscr DownArrowBar
227             Longleftrightarrow boxv boxhU zcy apacir lnapprox DZcy RightTeeVector isinv
228             heartsuit QUOT leftthreetimes nhpar jcy sol Not siml dash jukcy lpar ap
229             supedot oror yopf bigtriangledown jfr triangleleft shcy thickapprox succ
230             rdldhar blk14 xcirc minusb subedot ngeq Xopf NotSubsetEqual Cayleys cudarrl
231             congdot Gcedil rightleftarrows trie realpart nvHarr nwArr Uparrow npart nGg
232             dlcorn asympeq Vdashl Lmidot qprime Eopf Yfr equivDD hksearow primes mlcp
233             uharr rAarr sime rect LessEqualGreater Bopf seArr ngsim ncong DoubleRightTee
234             swarr omacr Sum coloneq nsupseteqq Zscr smile vnsup diamond angrt lbrke
235             rtrif angmsdad notinvb biguplus varsigma fjlig hookleftarrow searhk pr eg
236             ShortRightArrow exponentiale imagline bfr frac23 RuleDelayed triangledown
237             dcy prnap osol orarr nmid cfr mDDot precnsim leftharpoonup nexist gesdotol
238             lbrksld RightDoubleBracket Proportional varphi uHar smte NoBreak
239             NotLessSlantEqual mstpos supsetneqq Nacute plusdu boxbox ldca nisd rarrpl
240             boxVH nedot rbrksld gtrsim lbbrk NotGreaterSlantEqual NotRightTriangle
241             ecaron lmoustache Iukcy napid gvnE ExponentialE Sacute rtimes DiacriticalDot
242             checkmark gg nshortmid nLl/;
243              
244             sub init {
245 3     3 0 5 my($class, $lint) = @_;
246             $class->SUPER::init($lint => +{
247             rule => +{
248             'elem-unknown' => sub {
249 2     2   3 my $param = shift;
250 2 50       11 return 1 if $html5_tag{$param->{tag}};
251 0         0 return 0;
252             },
253             'attr-unknown' => sub {
254 10     10   8 my $param = shift;
255 10 100       23 return 1 if $html5_global_attr{$param->{attr}};
256 8 100       26 return 1 if $html5_attr{$param->{tag}}{$param->{attr}};
257 4 100       31 return 1 if any { $param->{attr} =~ $_ } @html5_global_user_attr;
  8         33  
258 2         6 return 0;
259             },
260             'text-unknown-entity' => sub {
261 1     1   1 my $param = shift;
262 1 50       6 return 1 if $html5_entity{$param->{entity}};
263 0           return 0;
264             },
265             }
266 3         33 });
267             }
268              
269             1;
270             __END__