html-proofer 3.0.6 → 3.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/htmlproofer +11 -6
- data/lib/html-proofer/check/images.rb +4 -0
- data/lib/html-proofer/configuration.rb +3 -1
- data/lib/html-proofer/element.rb +5 -1
- data/lib/html-proofer/runner.rb +9 -0
- data/lib/html-proofer/version.rb +1 -1
- metadata +10 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2d69ea6f2eb74095372c3f46f5b0b40beb25d4c2
|
4
|
+
data.tar.gz: b788331194e898263a88a47f41c60f77a4f3051a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a98a1fd90173d4481caae3c2fa7b702e1d5ab04cd262f4c555d250b7ce4518e29bcb0f3cfba7cd33d88526389bd05f3665b3ebb6ca0a46404057fa01f7663c62
|
7
|
+
data.tar.gz: 603de7c0256dde6120f0cce01e4803768c09468c620a04d81d6b053bd3d66e72573bc8fbe33efa9597a090fcd3c9f8744826021829e1619fc35fdc584c8c7513
|
data/bin/htmlproofer
CHANGED
@@ -18,9 +18,10 @@ Mercenary.program(:htmlproofer) do |p|
|
|
18
18
|
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'
|
19
19
|
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`).'
|
20
20
|
p.option 'checks_to_ignore', '--checks-to-ignore check1,[check2,...]', Array, ' An array of Strings indicating which checks you\'d like to not perform.'
|
21
|
-
p.option 'check_external_hash', '--check-external-hash', 'Checks whether external hashes exist (even if the
|
21
|
+
p.option 'check_external_hash', '--check-external-hash', 'Checks whether external hashes exist (even if the webpage exists). This slows the checker down (default: `false`).'
|
22
22
|
p.option 'check_favicon', '--check-favicon', 'Enables the favicon checker (default: `false`).'
|
23
23
|
p.option 'check_html', '--check-html', 'Enables HTML validation errors from Nokogiri (default: `false`).'
|
24
|
+
p.option 'check_img_http', '--check-img-http', 'Fails an image if it\'s marked as `http` (default: `false`).'
|
24
25
|
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`)'
|
25
26
|
p.option 'disable_external', '--disable-external', 'If `true`, does not run the external link checker, which can take a lot of time (default: `false`)'
|
26
27
|
p.option 'empty_alt_ignore', '--empty-alt-ignore', 'If `true`, ignores images with empty alt tags'
|
@@ -37,7 +38,8 @@ Mercenary.program(:htmlproofer) do |p|
|
|
37
38
|
p.option 'only_4xx', '--only-4xx', 'Only reports errors for links that fall within the 4xx status code range'
|
38
39
|
p.option 'timeframe', '--timeframe <time>', String, 'A string representing the caching timeframe.'
|
39
40
|
p.option 'url_ignore', '--url-ignore link1,[link2,...]', Array, 'A comma-separated list of Strings or RegExps containing URLs that are safe to ignore. It affects all HTML attributes. Note that non-HTTP(S) URIs are always ignored'
|
40
|
-
p.option 'url_swap', '--url-swap re:string,[re:string,...]', Array, 'A comma-separated list containing key-value pairs of `RegExp => String`. It transforms URLs that match `RegExp` into `String` via `gsub`.'
|
41
|
+
p.option 'url_swap', '--url-swap re:string,[re:string,...]', Array, 'A comma-separated list containing key-value pairs of `RegExp => String`. It transforms URLs that match `RegExp` into `String` via `gsub`. The escape sequences `\\:` should be used to produce literal `:`s.'
|
42
|
+
p.option 'internal_domains', '--internal-domains domain1,[domain2,...]', Array, 'A comma-separated list of Strings containing domains that will be treated as internal urls.'
|
41
43
|
|
42
44
|
p.action do |args, opts|
|
43
45
|
args = ['.'] if args.empty?
|
@@ -47,7 +49,7 @@ Mercenary.program(:htmlproofer) do |p|
|
|
47
49
|
|
48
50
|
# prepare everything to go to proofer
|
49
51
|
p.options.select { |o| !opts[o.config_key].nil? }.each do |option|
|
50
|
-
if option.
|
52
|
+
if opts[option.config_key].is_a?(Array)
|
51
53
|
opts[option.config_key] = opts[option.config_key].map { |i| HTMLProofer::Configuration.to_regex?(i) }
|
52
54
|
end
|
53
55
|
options[option.config_key.to_sym] = opts[option.config_key]
|
@@ -57,8 +59,11 @@ Mercenary.program(:htmlproofer) do |p|
|
|
57
59
|
unless opts['url_swap'].nil?
|
58
60
|
options[:url_swap] = {}
|
59
61
|
opts['url_swap'].each do |s|
|
60
|
-
|
61
|
-
|
62
|
+
splt = s.split(/(?<!\\):/,2)
|
63
|
+
|
64
|
+
re = splt[0].gsub(/\\:/, ':')
|
65
|
+
string = splt[1].gsub(/\\:/, ':')
|
66
|
+
options[:url_swap][Regexp.new(re)] = string
|
62
67
|
end
|
63
68
|
end
|
64
69
|
|
@@ -73,7 +78,7 @@ Mercenary.program(:htmlproofer) do |p|
|
|
73
78
|
|
74
79
|
options[:cache] = {}
|
75
80
|
options[:cache][:timeframe] = opts['timeframe'] unless opts['timeframe'].nil?
|
76
|
-
|
81
|
+
|
77
82
|
options[:http_status_ignore] = Array(options[:http_status_ignore]).map(&:to_i)
|
78
83
|
|
79
84
|
paths = path.split(',')
|
@@ -40,6 +40,10 @@ class ImageCheck < ::HTMLProofer::Check
|
|
40
40
|
if !@img.ignore_alt? && (@img.alt.nil? || (empty_alt_tag? && !@img.ignore_empty_alt?))
|
41
41
|
add_issue("image #{@img.url} does not have an alt attribute", line: line)
|
42
42
|
end
|
43
|
+
|
44
|
+
if @img.check_img_http? && @img.scheme == 'http'
|
45
|
+
add_issue("image #{@img.url} uses the http scheme", line: line)
|
46
|
+
end
|
43
47
|
end
|
44
48
|
|
45
49
|
external_urls
|
@@ -9,6 +9,7 @@ module HTMLProofer
|
|
9
9
|
:check_external_hash => false,
|
10
10
|
:check_favicon => false,
|
11
11
|
:check_html => false,
|
12
|
+
:check_img_http => false,
|
12
13
|
:checks_to_ignore => [],
|
13
14
|
:directory_index_file => 'index.html',
|
14
15
|
:disable_external => false,
|
@@ -19,10 +20,11 @@ module HTMLProofer
|
|
19
20
|
:external_only => false,
|
20
21
|
:file_ignore => [],
|
21
22
|
:http_status_ignore => [],
|
23
|
+
:internal_domains => [],
|
22
24
|
:log_level => :info,
|
23
25
|
:only_4xx => false,
|
24
26
|
:url_ignore => [],
|
25
|
-
:url_swap =>
|
27
|
+
:url_swap => {}
|
26
28
|
}
|
27
29
|
|
28
30
|
TYPHOEUS_DEFAULTS = {
|
data/lib/html-proofer/element.rb
CHANGED
@@ -9,7 +9,7 @@ module HTMLProofer
|
|
9
9
|
attr_reader :id, :name, :alt, :href, :link, :src, :line, :data_proofer_ignore
|
10
10
|
|
11
11
|
def initialize(obj, check)
|
12
|
-
#
|
12
|
+
# Construct readable ivars for every element
|
13
13
|
obj.attributes.each_pair do |attribute, value|
|
14
14
|
name = "#{attribute.tr('-:.', '_')}".to_sym
|
15
15
|
(class << self; self; end).send(:attr_reader, name)
|
@@ -91,6 +91,10 @@ module HTMLProofer
|
|
91
91
|
@check.options[:allow_hash_href]
|
92
92
|
end
|
93
93
|
|
94
|
+
def check_img_http?
|
95
|
+
@check.options[:check_img_http]
|
96
|
+
end
|
97
|
+
|
94
98
|
# path is external to the file
|
95
99
|
def external?
|
96
100
|
!internal?
|
data/lib/html-proofer/runner.rb
CHANGED
@@ -23,6 +23,15 @@ module HTMLProofer
|
|
23
23
|
FileUtils.mkdir_p(STORAGE_DIR)
|
24
24
|
end
|
25
25
|
|
26
|
+
# Add swap patterns for internal domains
|
27
|
+
unless @options[:internal_domains].empty?
|
28
|
+
@options[:internal_domains].each do |dom|
|
29
|
+
@options[:url_swap][Regexp.new("^http://#{dom}")] = ''
|
30
|
+
@options[:url_swap][Regexp.new("^https://#{dom}")] = ''
|
31
|
+
@options[:url_swap][Regexp.new("^//#{dom}")] = ''
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
26
35
|
@failures = []
|
27
36
|
end
|
28
37
|
|
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.0
|
4
|
+
version: 3.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Garen Torikian
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-09-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mercenary
|
@@ -112,16 +112,22 @@ dependencies:
|
|
112
112
|
name: activesupport
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
|
-
- - "
|
115
|
+
- - ">="
|
116
116
|
- !ruby/object:Gem::Version
|
117
117
|
version: '4.2'
|
118
|
+
- - "<"
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: '6.0'
|
118
121
|
type: :runtime
|
119
122
|
prerelease: false
|
120
123
|
version_requirements: !ruby/object:Gem::Requirement
|
121
124
|
requirements:
|
122
|
-
- - "
|
125
|
+
- - ">="
|
123
126
|
- !ruby/object:Gem::Version
|
124
127
|
version: '4.2'
|
128
|
+
- - "<"
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
version: '6.0'
|
125
131
|
- !ruby/object:Gem::Dependency
|
126
132
|
name: redcarpet
|
127
133
|
requirement: !ruby/object:Gem::Requirement
|