Class: HtmlCheck

Inherits:
HTMLProofer::Check show all
Defined in:
lib/html-proofer/check/html.rb

Constant Summary collapse

SCRIPT_EMBEDS_MSG =
/Element script embeds close tag/
INVALID_TAG_MSG =
/Tag ([\w\-:]+) invalid/
INVALID_PREFIX =
/Namespace prefix/
PARSE_ENTITY_REF =
/htmlParseEntityRef: no name/

Instance Attribute Summary

Attributes inherited from HTMLProofer::Check

#element, #external_urls, #html, #issues, #node, #options, #path, #src

Instance Method Summary collapse

Methods inherited from HTMLProofer::Check

#add_issue, #add_path_for_url, #add_to_external_urls, #blank?, #create_element, #initialize, subchecks

Constructor Details

This class inherits a constructor from HTMLProofer::Check

Instance Method Details

#runObject


7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/html-proofer/check/html.rb', line 7

def run
  @html.errors.each do |error|
    message = error.message
    line    = error.line

    if message =~ INVALID_TAG_MSG || message =~ INVALID_PREFIX
      next unless options[:validation][:report_invalid_tags]
    end

    if message =~ PARSE_ENTITY_REF
      next unless options[:validation][:report_missing_names]
    end

    # tags embedded in scripts are used in templating languages: http://git.io/vOovv
    next if !options[:validation][:report_script_embeds] && message =~ SCRIPT_EMBEDS_MSG

    add_issue(message, line: line)
  end
end