html-proofer 3.9.2 → 3.9.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/bin/htmlproofer +4 -4
- data/lib/html-proofer.rb +5 -0
- data/lib/html-proofer/check/links.rb +5 -4
- data/lib/html-proofer/url_validator.rb +2 -1
- data/lib/html-proofer/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 246e851f166c3330542ef13670c9b86ea6acef06b142de26692ae16ec421dd15
|
4
|
+
data.tar.gz: 6e63ce9f51b36817a9420ef07dd7a40c5668227f94ffc01df4cf3d8ac21fdb1e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 19a3a97c74d2c9fddbbb4b12cbc38e9ab08309232c876ccaab922643de9535f0ebf9d56a90a3ce0c4821cd070d5b629ef4368629e2e5b2c6a02c36acb5019e3a
|
7
|
+
data.tar.gz: e2201edf4fee55ed6b80b00e7bbdb5eb272a8fc5748d1bcd41148e3afa7757e24487c5698e12083288aeefc2a5e7db317d8fd29b5340d5678d9c14fe2b327381
|
data/bin/htmlproofer
CHANGED
@@ -15,7 +15,7 @@ Mercenary.program(:htmlproofer) do |p|
|
|
15
15
|
|
16
16
|
p.option 'allow_missing_href', '--allow-missing-href', 'If `true`, does not flag `a` tags missing `href` (this is the default for HTML5).'
|
17
17
|
p.option 'allow_hash_href', '--allow-hash-href', 'If `true`, ignores the `href="#"`'
|
18
|
-
p.option 'as_links', '--as-links', 'Assumes that `PATH` is a comma-separated array of links to check.'
|
18
|
+
p.option 'as_links', '--as-links link1,[link2,...]', Array, 'Assumes that `PATH` is a comma-separated array of links to check.'
|
19
19
|
p.option 'alt_ignore', '--alt-ignore image1,[image2,...]', Array, 'A comma-separated list of Strings or RegExps containing `img`s whose missing `alt` tags are safe to ignore'
|
20
20
|
p.option 'assume_extension', '--assume-extension', 'Automatically add extension (e.g. `.html`) to file paths, to allow extensionless URLs (as supported by Jekyll 3 and GitHub Pages) (default: `false`).'
|
21
21
|
p.option 'checks_to_ignore', '--checks-to-ignore check1,[check2,...]', Array, ' An array of Strings indicating which checks you\'d like to not perform.'
|
@@ -25,12 +25,12 @@ Mercenary.program(:htmlproofer) do |p|
|
|
25
25
|
p.option 'check_img_http', '--check-img-http', 'Fails an image if it\'s marked as `http` (default: `false`).'
|
26
26
|
p.option 'check_opengraph', '--check-opengraph', 'Enables the Open Graph checker (default: `false`).'
|
27
27
|
p.option 'check_sri', '--check-sri', 'Check that `<link>` and `<script>` external resources do use SRI (default: `false`).'
|
28
|
-
p.option 'directory_index_file', '--directory-index-file', String, 'Sets the file to look for when a link refers to a directory. (default: `index.html`)'
|
28
|
+
p.option 'directory_index_file', '--directory-index-file <filename>', String, 'Sets the file to look for when a link refers to a directory. (default: `index.html`)'
|
29
29
|
p.option 'disable_external', '--disable-external', 'If `true`, does not run the external link checker, which can take a lot of time (default: `false`)'
|
30
30
|
p.option 'empty_alt_ignore', '--empty-alt-ignore', 'If `true`, ignores images with empty alt tags'
|
31
|
-
p.option 'error_sort', '--error-sort
|
31
|
+
p.option 'error_sort', '--error-sort <sort>', String, 'Defines the sort order for error output. Can be `:path`, `:desc`, or `:status` (default: `:path`).'
|
32
32
|
p.option 'enforce_https', '--enforce-https', 'Fails a link if it\'s not marked as `https` (default: `false`).'
|
33
|
-
p.option 'extension', '--extension
|
33
|
+
p.option 'extension', '--extension <ext>', String, 'The extension of your HTML files including the dot. (default: `.html`)'
|
34
34
|
p.option 'external_only', '--external_only', 'Only checks problems with external references'
|
35
35
|
p.option 'file_ignore', '--file-ignore file1,[file2,...]', Array, 'A comma-separated list of Strings or RegExps containing file paths that are safe to ignore'
|
36
36
|
p.option 'http_status_ignore', '--http-status-ignore 123,[xxx, ...]', Array, 'A comma-separated list of numbers representing status codes to ignore.'
|
data/lib/html-proofer.rb
CHANGED
@@ -19,6 +19,7 @@ rescue LoadError; end
|
|
19
19
|
module HTMLProofer
|
20
20
|
def check_file(file, options = {})
|
21
21
|
raise ArgumentError unless file.is_a?(String)
|
22
|
+
raise ArgumentError, "#{file} does not exist" unless File.exist?(file)
|
22
23
|
options[:type] = :file
|
23
24
|
HTMLProofer::Runner.new(file, options)
|
24
25
|
end
|
@@ -26,6 +27,7 @@ module HTMLProofer
|
|
26
27
|
|
27
28
|
def check_directory(directory, options = {})
|
28
29
|
raise ArgumentError unless directory.is_a?(String)
|
30
|
+
raise ArgumentError, "#{directory} does not exist" unless Dir.exist?(directory)
|
29
31
|
options[:type] = :directory
|
30
32
|
HTMLProofer::Runner.new([directory], options)
|
31
33
|
end
|
@@ -34,6 +36,9 @@ module HTMLProofer
|
|
34
36
|
def check_directories(directories, options = {})
|
35
37
|
raise ArgumentError unless directories.is_a?(Array)
|
36
38
|
options[:type] = :directory
|
39
|
+
directories.each do |directory|
|
40
|
+
raise ArgumentError, "#{directory} does not exist" unless Dir.exist?(directory)
|
41
|
+
end
|
37
42
|
HTMLProofer::Runner.new(directories, options)
|
38
43
|
end
|
39
44
|
module_function :check_directories
|
@@ -110,6 +110,7 @@ class LinkCheck < ::HTMLProofer::Check
|
|
110
110
|
def hash_check(html, href_hash)
|
111
111
|
decoded_href_hash = Addressable::URI.unescape(href_hash)
|
112
112
|
fragment_ids = [href_hash, decoded_href_hash]
|
113
|
+
# https://www.w3.org/TR/html5/single-page.html#scroll-to-fragid
|
113
114
|
fragment_ids.include?('top') || !find_fragments(html, fragment_ids).empty?
|
114
115
|
end
|
115
116
|
|
@@ -117,8 +118,8 @@ class LinkCheck < ::HTMLProofer::Check
|
|
117
118
|
xpaths = fragment_ids.flat_map do |frag_id|
|
118
119
|
escaped_frag_id = "'#{frag_id.split("'").join("', \"'\", '")}', ''"
|
119
120
|
[
|
120
|
-
"//*[
|
121
|
-
"//*[
|
121
|
+
"//*[case_sensitive_equals(@id, concat(#{escaped_frag_id}))]",
|
122
|
+
"//*[case_sensitive_equals(@name, concat(#{escaped_frag_id}))]"
|
122
123
|
]
|
123
124
|
end
|
124
125
|
xpaths << XpathFunctions.new
|
@@ -140,8 +141,8 @@ class LinkCheck < ::HTMLProofer::Check
|
|
140
141
|
end
|
141
142
|
|
142
143
|
class XpathFunctions
|
143
|
-
def
|
144
|
-
node_set.find_all { |node| node.to_s.
|
144
|
+
def case_sensitive_equals(node_set, str_to_match)
|
145
|
+
node_set.find_all { |node| node.to_s. == str_to_match.to_s }
|
145
146
|
end
|
146
147
|
end
|
147
148
|
end
|
@@ -178,8 +178,9 @@ module HTMLProofer
|
|
178
178
|
|
179
179
|
body_doc = create_nokogiri(response.body)
|
180
180
|
|
181
|
+
unencoded_hash = Addressable::URI.unescape(hash)
|
182
|
+
xpath = %(//*[@name="#{hash}"]|/*[@name="#{unencoded_hash}"]|//*[@id="#{hash}"]|//*[@id="#{unencoded_hash}"])
|
181
183
|
# user-content is a special addition by GitHub.
|
182
|
-
xpath = %(//*[@name="#{hash}"]|//*[@id="#{hash}"])
|
183
184
|
if URI.parse(href).host =~ /github\.com/i
|
184
185
|
xpath << %(|//*[@name="user-content-#{hash}"]|//*[@id="user-content-#{hash}"])
|
185
186
|
end
|
data/lib/html-proofer/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: html-proofer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.9.
|
4
|
+
version: 3.9.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Garen Torikian
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-11-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mercenary
|
@@ -314,7 +314,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
314
314
|
version: '0'
|
315
315
|
requirements: []
|
316
316
|
rubyforge_project:
|
317
|
-
rubygems_version: 2.6
|
317
|
+
rubygems_version: 2.7.6
|
318
318
|
signing_key:
|
319
319
|
specification_version: 4
|
320
320
|
summary: A set of tests to validate your HTML output. These tests check if your image
|