Class: HtmlCheck

Inherits:
HTML::Proofer::CheckRunner show all
Defined in:
lib/html/proofer/checks/html.rb

Constant Summary collapse

HTML5_TAGS =
%w(article aside bdi details dialog figcaption
figure footer header main mark menuitem meter
nav progress rp rt ruby section summary
time wbr datalist keygen output color date
datetime datetime-local email month number
range search tel time url week canvas
svg audio embed source track video
altGlyph altGlyphDef altGlyphItem animate
animateColor animateMotion animateTransform
circle clipPath color-profile cursor defs
desc ellipse feBlend feColorMatrix
feComponentTransfer feComposite feConvolveMatrix
feDiffuseLighting feDisplacementMap feDistantLight
feFlood feFuncA feFuncB feFuncG feFuncR feGaussianBlur
feImage feMerge feMergeNode feMorphology feOffset
fePointLight feSpecularLighting feSpotLight feTile
feTurbulence filter font font-face font-face-format
font-face-name font-face-src font-face-uri
foreignObject g glyph glyphRef hkern image line
linearGradient marker mask metadata missing-glyph
mpath path pattern polygon polyline radialGradient
rect set stop switch symbol text textPath tref tspan use
view vkern)
SCRIPT_EMBEDS_MSG =
/Element script embeds close tag/

Instance Attribute Summary

Attributes inherited from HTML::Proofer::CheckRunner

#alt_ignores, #empty_alt_ignore, #external_urls, #href_ignores, #hydra_opts, #issues, #options, #parallel_opts, #path, #src, #typhoeus_opts, #url_ignores, #validation_opts

Instance Method Summary collapse

Methods inherited from HTML::Proofer::CheckRunner

#add_issue, #add_path_for_url, #add_to_external_urls, checks, #extract_domain_path, #initialize, #new_url_query_values?

Constructor Details

This class inherits a constructor from HTML::Proofer::CheckRunner

Instance Method Details

#runObject


32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/html/proofer/checks/html.rb', line 32

def run
  @html.errors.each do |error|
    message = error.message
    line    = error.line
    # Nokogiri (or rather libxml2 underhood) only recognizes html4 tags,
    # so we need to skip errors caused by the new tags in html5
    next if HTML5_TAGS.include? message[/Tag ([\w-]+) invalid/o, 1]

    # tags embedded in scripts are used in templating languages: http://git.io/vOovv
    next if @validation_opts[:ignore_script_embeds] && message =~ SCRIPT_EMBEDS_MSG

    add_issue(message, line)
  end
end