@@ -23,6 +23,11 @@ var inlineTags = []string{
2323 "b" , "big" , "i" , "small" , "abbr" , "acronym" , "cite" , "dfn" , "em" , "kbd" ,
2424 "strong" , "a" , "br" , "img" , "span" , "sub" , "sup" , "code" , "tt" , "del" }
2525
26+ // voidTags never carry content, so they are never "open" as containers.
27+ var voidTags = []string {
28+ "area" , "base" , "br" , "col" , "embed" , "hr" , "img" , "input" , "link" ,
29+ "meta" , "source" , "track" , "wbr" }
30+
2631// inlineToScope names the inline elements that can be scoped on their own.
2732//
2833// These are siblings of `text`, not children of it: a scope of `text` is
@@ -92,6 +97,13 @@ func (l *Linter) lintHTMLTokens(f *core.File, raw []byte, offset int) error { //
9297 class = getAttribute (tok , "class" )
9398 skipClass = checkClasses (class , skipClasses )
9499
100+ if tokt == html .StartTagToken && ! core .StringInSlice (txt , inlineTags ) &&
101+ ! core .StringInSlice (txt , voidTags ) {
102+ walker .enclose (txt , class )
103+ } else if tokt == html .EndTagToken && ! core .StringInSlice (txt , inlineTags ) {
104+ walker .unclose (txt )
105+ }
106+
95107 blockSkip := skipClass && ! core .StringInSlice (txt , inlineTags )
96108 if tokt == html .ErrorToken { //nolint:gocritic
97109 break
0 commit comments