html-proofer 0.9.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -0
- data/bin/htmlproof +4 -2
- data/html-proofer.gemspec +1 -1
- data/lib/html/proofer.rb +1 -0
- data/lib/html/proofer/check.rb +2 -1
- data/lib/html/proofer/checkable.rb +9 -8
- data/spec/html/proofer/fixtures/images/ignorableAltViaOptions.html +13 -0
- data/spec/html/proofer/images_spec.rb +6 -0
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0e7b88c5fd839aa05b97b85399326a9db187a340
|
4
|
+
data.tar.gz: e0a0c34a2602aca002797185b7ee488b1a94314d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 904bc7984ee9ddba79e06833a9e235e26c5d388c7581493f79f210053248d4d7916dfe849c8eac7e5fc75815f5be2dbf9d88b3f043eb1181e95f11241cae698b
|
7
|
+
data.tar.gz: 509fe2ee57606ea93e1c175bafc8bf8ff39891a93c0bfa8c7ea3242f731f184e4a884bb1deea9d2433074f3b816d25542873deed24e7df4a3f421e64d2f106ba
|
data/README.md
CHANGED
@@ -124,6 +124,7 @@ The `HTML::Proofer` constructor takes an optional hash of additional options:
|
|
124
124
|
| `ext` | The extension of your HTML files including the dot. | `.html` |
|
125
125
|
| `favicon` | Enables the favicon checker. | `false` |
|
126
126
|
| `href_ignore` | An array of Strings or RegExps containing `href`s that are safe to ignore. Certain URIs, like `mailto` and `tel`, are always ignored. | `[]` |
|
127
|
+
| `alt_ignore` | An array of Strings or RegExps containing `img`s whose missing `alt` tags are safe to ignore. | `[]` |
|
127
128
|
| `href_swap` | A hash containing key-value pairs of `RegExp => String`. It transforms links that match `RegExp` into `String` via `gsub`. | `{}` |
|
128
129
|
| `verbose` | If `true`, outputs extra information as the checking happens. Useful for debugging. | `false` |
|
129
130
|
|
data/bin/htmlproof
CHANGED
@@ -17,7 +17,8 @@ Mercenary.program(:htmlproof) do |p|
|
|
17
17
|
p.option 'ext', '--ext EXT', 'The extension of your HTML files (default: `.html`)'
|
18
18
|
p.option 'favicon', '--favicon', 'Enables the favicon checker (default: `false`).'
|
19
19
|
p.option 'swap', '--swap regex:string,[regex:string,...]', Array, 'Array containing key-value pairs of `RegExp:String`. It transforms links that match `RegExp` into `String`'
|
20
|
-
p.option '
|
20
|
+
p.option 'href_ignore', '--href_ignore link1,[link2,...]', Array, 'Array of Strings containing `href`s that are safe to ignore. Certain URIs, like `mailto` and `tel`, are always ignored.'
|
21
|
+
p.option 'alt_ignore', '--alt_ignore image1,[image2,...]', Array, 'Array of Strings containing `img`s whose missing `alt` tags are safe to ignore'
|
21
22
|
p.option 'disable_external', '--disable_external', 'Disables the external link checker (default: `false`)'
|
22
23
|
p.option 'verbose', '--verbose', 'Enables more verbose logging.'
|
23
24
|
|
@@ -34,7 +35,8 @@ Mercenary.program(:htmlproof) do |p|
|
|
34
35
|
options[:href_swap][%r{#{pair[0]}}] = pair[1]
|
35
36
|
end
|
36
37
|
end
|
37
|
-
options[:href_ignore] = opts["ignore"] unless opts["
|
38
|
+
options[:href_ignore] = opts["ignore"] unless opts["href_ignore"].nil?
|
39
|
+
options[:alt_ignore] = opts["ignore"] unless opts["alt_ignore"].nil?
|
38
40
|
options[:disable_external] = opts["disable_external"] unless opts["disable_external"].nil?
|
39
41
|
options[:favicon] = opts["favicon"] unless opts["favicon"].nil?
|
40
42
|
options[:verbose] = opts["verbose"] unless opts["verbose"].nil?
|
data/html-proofer.gemspec
CHANGED
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |gem|
|
5
5
|
gem.name = "html-proofer"
|
6
|
-
gem.version = "0.
|
6
|
+
gem.version = "1.0.0"
|
7
7
|
gem.authors = ["Garen Torikian"]
|
8
8
|
gem.email = ["gjtorikian@gmail.com"]
|
9
9
|
gem.description = %q{Test your rendered HTML files to make sure they're accurate.}
|
data/lib/html/proofer.rb
CHANGED
data/lib/html/proofer/check.rb
CHANGED
@@ -10,7 +10,7 @@ class HTML::Proofer::Checks
|
|
10
10
|
|
11
11
|
class Check
|
12
12
|
|
13
|
-
attr_reader :issues, :src, :path, :options, :external_urls, :additional_href_ignores
|
13
|
+
attr_reader :issues, :src, :path, :options, :external_urls, :additional_href_ignores, :additional_alt_ignores
|
14
14
|
|
15
15
|
def initialize(src, path, html, opts={})
|
16
16
|
@src = src
|
@@ -19,6 +19,7 @@ class HTML::Proofer::Checks
|
|
19
19
|
@options = opts
|
20
20
|
@issues = []
|
21
21
|
@additional_href_ignores = @options[:href_ignore]
|
22
|
+
@additional_alt_ignores = @options[:alt_ignore]
|
22
23
|
@external_urls = {}
|
23
24
|
end
|
24
25
|
|
@@ -62,14 +62,15 @@ module HTML
|
|
62
62
|
end
|
63
63
|
|
64
64
|
def ignore?
|
65
|
-
return true if @data_ignore_proofer || @check.additional_href_ignores.include?(url)
|
66
|
-
return true if @type == "image"
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
65
|
+
return true if @data_ignore_proofer || @check.additional_href_ignores.include?(url) || @check.additional_alt_ignores.include?(url)
|
66
|
+
return true if (@type == "image" || @type == "favicon") && url.match(/^data:image/)
|
67
|
+
|
68
|
+
[@check.additional_href_ignores, @check.additional_alt_ignores].each do |additional_ignore|
|
69
|
+
additional_ignore.each do |ignore|
|
70
|
+
if ignore.is_a? String
|
71
|
+
return true if ignore == url
|
72
|
+
elsif ignore.is_a? Regexp
|
73
|
+
return true if ignore =~ url
|
73
74
|
end
|
74
75
|
end
|
75
76
|
end
|
@@ -82,4 +82,10 @@ describe "Images test" do
|
|
82
82
|
output = capture_stderr { HTML::Proofer.new(relativeLinks).run }
|
83
83
|
output.should == ""
|
84
84
|
end
|
85
|
+
|
86
|
+
it 'properly ignores missing alt tags when asked' do
|
87
|
+
ignorableLinks = "#{FIXTURES_DIR}/images/ignorableAltViaOptions.html"
|
88
|
+
output = capture_stderr { HTML::Proofer.new(ignorableLinks, {:alt_ignore => [/wikimedia/, "gpl.png"]}).run }
|
89
|
+
output.should == ""
|
90
|
+
end
|
85
91
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: html-proofer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Garen Torikian
|
@@ -169,6 +169,7 @@ files:
|
|
169
169
|
- spec/html/proofer/fixtures/favicon/favicon_present_shortcut.html
|
170
170
|
- spec/html/proofer/fixtures/images/existingImageExternal.html
|
171
171
|
- spec/html/proofer/fixtures/images/gpl.png
|
172
|
+
- spec/html/proofer/fixtures/images/ignorableAltViaOptions.html
|
172
173
|
- spec/html/proofer/fixtures/images/ignorableImages.html
|
173
174
|
- spec/html/proofer/fixtures/images/image_missing_protocol_invalid.html
|
174
175
|
- spec/html/proofer/fixtures/images/image_missing_protocol_valid.html
|
@@ -268,6 +269,7 @@ test_files:
|
|
268
269
|
- spec/html/proofer/fixtures/favicon/favicon_present_shortcut.html
|
269
270
|
- spec/html/proofer/fixtures/images/existingImageExternal.html
|
270
271
|
- spec/html/proofer/fixtures/images/gpl.png
|
272
|
+
- spec/html/proofer/fixtures/images/ignorableAltViaOptions.html
|
271
273
|
- spec/html/proofer/fixtures/images/ignorableImages.html
|
272
274
|
- spec/html/proofer/fixtures/images/image_missing_protocol_invalid.html
|
273
275
|
- spec/html/proofer/fixtures/images/image_missing_protocol_valid.html
|