html-proofer 2.5.1 → 2.5.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (183) hide show
  1. checksums.yaml +4 -4
  2. data/bin/htmlproof +11 -1
  3. data/lib/html/proofer.rb +1 -0
  4. data/lib/html/proofer/check_runner.rb +1 -1
  5. data/lib/html/proofer/checkable.rb +2 -2
  6. data/lib/html/proofer/checks/links.rb +2 -0
  7. data/lib/html/proofer/url_validator.rb +14 -3
  8. data/lib/html/proofer/version.rb +1 -1
  9. metadata +4 -344
  10. data/.gitignore +0 -26
  11. data/.travis.yml +0 -14
  12. data/Gemfile +0 -3
  13. data/LICENSE.txt +0 -22
  14. data/README.md +0 -276
  15. data/Rakefile +0 -21
  16. data/html-proofer.gemspec +0 -32
  17. data/script/bootstrap +0 -5
  18. data/spec/html/proofer/checkable_spec.rb +0 -47
  19. data/spec/html/proofer/command_spec.rb +0 -88
  20. data/spec/html/proofer/favicon_spec.rb +0 -47
  21. data/spec/html/proofer/fixtures/favicon/favicon_absent.html +0 -4
  22. data/spec/html/proofer/fixtures/favicon/favicon_absent_apple.html +0 -7
  23. data/spec/html/proofer/fixtures/favicon/favicon_broken.html +0 -7
  24. data/spec/html/proofer/fixtures/favicon/favicon_broken_but_ignored.html +0 -7
  25. data/spec/html/proofer/fixtures/favicon/favicon_present.html +0 -7
  26. data/spec/html/proofer/fixtures/favicon/favicon_present_shortcut.html +0 -7
  27. data/spec/html/proofer/fixtures/html/div_inside_head.html +0 -6
  28. data/spec/html/proofer/fixtures/html/html5_tags.html +0 -9
  29. data/spec/html/proofer/fixtures/html/ignore_script_embeds.html +0 -3
  30. data/spec/html/proofer/fixtures/html/invalid_tag.html +0 -3
  31. data/spec/html/proofer/fixtures/html/missing_closing_quotes.html +0 -5
  32. data/spec/html/proofer/fixtures/html/opening_and_ending_tag_mismatch.html +0 -7
  33. data/spec/html/proofer/fixtures/html/svg_elements.html +0 -729
  34. data/spec/html/proofer/fixtures/html/unescaped_ampersand_in_attribute.html +0 -4
  35. data/spec/html/proofer/fixtures/html/unmatched_end_tag.html +0 -5
  36. data/spec/html/proofer/fixtures/images/emptyImageAltText.html +0 -10
  37. data/spec/html/proofer/fixtures/images/existingImageExternal.html +0 -9
  38. data/spec/html/proofer/fixtures/images/gpl.png +0 -0
  39. data/spec/html/proofer/fixtures/images/ignorableAltViaOptions.html +0 -13
  40. data/spec/html/proofer/fixtures/images/ignorableImages.html +0 -10
  41. data/spec/html/proofer/fixtures/images/ignoreAltButNotLink.html +0 -13
  42. data/spec/html/proofer/fixtures/images/image_missing_protocol_invalid.html +0 -9
  43. data/spec/html/proofer/fixtures/images/image_missing_protocol_valid.html +0 -9
  44. data/spec/html/proofer/fixtures/images/missingImageAlt.html +0 -9
  45. data/spec/html/proofer/fixtures/images/missingImageAltText.html +0 -9
  46. data/spec/html/proofer/fixtures/images/missingImageExternal.html +0 -9
  47. data/spec/html/proofer/fixtures/images/missingImageInternal.html +0 -9
  48. data/spec/html/proofer/fixtures/images/missingImageSrc.html +0 -9
  49. data/spec/html/proofer/fixtures/images/relativeToSelf.html +0 -2
  50. data/spec/html/proofer/fixtures/images/rootRelativeImages.html +0 -2
  51. data/spec/html/proofer/fixtures/images/srcSetCheck.html +0 -7
  52. data/spec/html/proofer/fixtures/images/srcSetIgnorable.html +0 -13
  53. data/spec/html/proofer/fixtures/images/srcSetMissingAlt.html +0 -7
  54. data/spec/html/proofer/fixtures/images/srcSetMissingImage.html +0 -7
  55. data/spec/html/proofer/fixtures/images/terribleImageName.html +0 -9
  56. data/spec/html/proofer/fixtures/images/workingDataURIImage.html +0 -3
  57. data/spec/html/proofer/fixtures/links/_site/folder.html/index.html +0 -1
  58. data/spec/html/proofer/fixtures/links/anchors_in_pre.html +0 -12
  59. data/spec/html/proofer/fixtures/links/attributeWithDash.html +0 -8
  60. data/spec/html/proofer/fixtures/links/blank_mailto_link.html +0 -9
  61. data/spec/html/proofer/fixtures/links/blank_tel_link.html +0 -9
  62. data/spec/html/proofer/fixtures/links/brokenHashExternal.html +0 -11
  63. data/spec/html/proofer/fixtures/links/brokenHashInternal.html +0 -14
  64. data/spec/html/proofer/fixtures/links/brokenHashOnTheWeb.html +0 -2
  65. data/spec/html/proofer/fixtures/links/brokenInternalLink.html +0 -0
  66. data/spec/html/proofer/fixtures/links/brokenLinkExternal.html +0 -11
  67. data/spec/html/proofer/fixtures/links/brokenLinkInternal.html +0 -10
  68. data/spec/html/proofer/fixtures/links/brokenLinkWithNumber.html +0 -8
  69. data/spec/html/proofer/fixtures/links/brokenUnixLinks.html +0 -5
  70. data/spec/html/proofer/fixtures/links/broken_hash_with_query.html +0 -9
  71. data/spec/html/proofer/fixtures/links/checkSSLLinks.html +0 -1
  72. data/spec/html/proofer/fixtures/links/check_just_once.html +0 -8
  73. data/spec/html/proofer/fixtures/links/ensure_typhoeus_options.html +0 -1
  74. data/spec/html/proofer/fixtures/links/erstiebegr%C3%BC%C3%9Fung.html +0 -0
  75. data/spec/html/proofer/fixtures/links/erstiebegr/303/274/303/237ung.html +0 -0
  76. data/spec/html/proofer/fixtures/links/escape_pipes.html +0 -9
  77. data/spec/html/proofer/fixtures/links/file.foo +0 -11
  78. data/spec/html/proofer/fixtures/links/folder-php/index.php +0 -2
  79. data/spec/html/proofer/fixtures/links/folder/anchorLink.html +0 -0
  80. data/spec/html/proofer/fixtures/links/folder/assets/barrel.png +0 -0
  81. data/spec/html/proofer/fixtures/links/folder/index.html +0 -0
  82. data/spec/html/proofer/fixtures/links/folder/multiples/catalog/file.html +0 -8
  83. data/spec/html/proofer/fixtures/links/folder/multiples/javadoc/file.html +0 -8
  84. data/spec/html/proofer/fixtures/links/folder/relativeImage.html +0 -2
  85. data/spec/html/proofer/fixtures/links/githubHash.html +0 -1
  86. data/spec/html/proofer/fixtures/links/gpl.png +0 -0
  87. data/spec/html/proofer/fixtures/links/hashReferringToSelf.html +0 -44
  88. data/spec/html/proofer/fixtures/links/head_link_href.html +0 -7
  89. data/spec/html/proofer/fixtures/links/head_link_href_absent.html +0 -7
  90. data/spec/html/proofer/fixtures/links/head_link_href_empty.html +0 -7
  91. data/spec/html/proofer/fixtures/links/ignorableLinks.html +0 -13
  92. data/spec/html/proofer/fixtures/links/ignorableLinksViaOptions.html +0 -13
  93. data/spec/html/proofer/fixtures/links/ignores_cases.html +0 -3
  94. data/spec/html/proofer/fixtures/links/invalid_mailto_link.html +0 -9
  95. data/spec/html/proofer/fixtures/links/javascript_link.html +0 -9
  96. data/spec/html/proofer/fixtures/links/linkToFolder.html +0 -9
  97. data/spec/html/proofer/fixtures/links/linkTranslatedViaHrefSwap.html +0 -9
  98. data/spec/html/proofer/fixtures/links/linkWithHttps.html +0 -9
  99. data/spec/html/proofer/fixtures/links/linkWithRedirect.html +0 -14
  100. data/spec/html/proofer/fixtures/links/link_directory_without_slash.html +0 -1
  101. data/spec/html/proofer/fixtures/links/link_missing_protocol_invalid.html +0 -9
  102. data/spec/html/proofer/fixtures/links/link_missing_protocol_valid.html +0 -9
  103. data/spec/html/proofer/fixtures/links/link_pointing_to_directory.html +0 -1
  104. data/spec/html/proofer/fixtures/links/links_in_pre.html +0 -13
  105. data/spec/html/proofer/fixtures/links/mailto_link.html +0 -9
  106. data/spec/html/proofer/fixtures/links/missingLinkHref.html +0 -9
  107. data/spec/html/proofer/fixtures/links/multipleProblems.html +0 -11
  108. data/spec/html/proofer/fixtures/links/nodupe.html +0 -1
  109. data/spec/html/proofer/fixtures/links/non_standard_characters.html +0 -10
  110. data/spec/html/proofer/fixtures/links/notarealhash.html +0 -0
  111. data/spec/html/proofer/fixtures/links/other_protocols.html +0 -4
  112. data/spec/html/proofer/fixtures/links/placeholder_with_empty_id.html +0 -1
  113. data/spec/html/proofer/fixtures/links/placeholder_with_id.html +0 -1
  114. data/spec/html/proofer/fixtures/links/placeholder_with_name.html +0 -1
  115. data/spec/html/proofer/fixtures/links/redirected_error.html +0 -1
  116. data/spec/html/proofer/fixtures/links/relativeLinks.html +0 -4
  117. data/spec/html/proofer/fixtures/links/rootLink/folder/index.html +0 -1
  118. data/spec/html/proofer/fixtures/links/rootLink/index.html +0 -1
  119. data/spec/html/proofer/fixtures/links/rootLink/rootLink.html +0 -9
  120. data/spec/html/proofer/fixtures/links/tel_link.html +0 -9
  121. data/spec/html/proofer/fixtures/links/urlencoded-href.html +0 -2
  122. data/spec/html/proofer/fixtures/links/utf8Link.html +0 -2
  123. data/spec/html/proofer/fixtures/resources/Screen Shot 2012-08-09 at 7.51.18 AM.png +0 -0
  124. data/spec/html/proofer/fixtures/resources/books/assets/getting-good-with-git.jpg +0 -0
  125. data/spec/html/proofer/fixtures/resources/books/assets/pro-git.jpg +0 -0
  126. data/spec/html/proofer/fixtures/resources/books/assets/version-control-with-git.jpg +0 -0
  127. data/spec/html/proofer/fixtures/resources/books/nestedRelativeImages.html +0 -5
  128. data/spec/html/proofer/fixtures/resources/gpl.png +0 -0
  129. data/spec/html/proofer/fixtures/scripts/ignorableLinksViaOptions.html +0 -4
  130. data/spec/html/proofer/fixtures/scripts/script.js +0 -1
  131. data/spec/html/proofer/fixtures/scripts/script_broken_external.html +0 -9
  132. data/spec/html/proofer/fixtures/scripts/script_content.html +0 -9
  133. data/spec/html/proofer/fixtures/scripts/script_content_absent.html +0 -9
  134. data/spec/html/proofer/fixtures/scripts/script_in_pre.html +0 -5
  135. data/spec/html/proofer/fixtures/scripts/script_missing_internal.html +0 -9
  136. data/spec/html/proofer/fixtures/scripts/script_valid_internal.html +0 -9
  137. data/spec/html/proofer/fixtures/sorting/issue/broken_image_one.html +0 -1
  138. data/spec/html/proofer/fixtures/sorting/issue/broken_image_two.html +0 -4
  139. data/spec/html/proofer/fixtures/sorting/path/multiple_issues.html +0 -11
  140. data/spec/html/proofer/fixtures/sorting/path/single_issue.html +0 -1
  141. data/spec/html/proofer/fixtures/sorting/status/a_404.html +0 -1
  142. data/spec/html/proofer/fixtures/sorting/status/broken_link.html +0 -3
  143. data/spec/html/proofer/fixtures/sorting/status/missing_redirect.html +0 -1
  144. data/spec/html/proofer/fixtures/utils/lang-jp.html +0 -1
  145. data/spec/html/proofer/fixtures/vcr_cassettes/images/existingImageExternal_html.yml +0 -62
  146. data/spec/html/proofer/fixtures/vcr_cassettes/images/ignoreAltButNotLink_html_alt_ignore_/_/_.yml +0 -45
  147. data/spec/html/proofer/fixtures/vcr_cassettes/images/image_missing_protocol_invalid_html.yml +0 -117
  148. data/spec/html/proofer/fixtures/vcr_cassettes/images/image_missing_protocol_valid_html.yml +0 -62
  149. data/spec/html/proofer/fixtures/vcr_cassettes/images/missingImageExternal_html.yml +0 -45
  150. data/spec/html/proofer/fixtures/vcr_cassettes/links/attributeWithDash_html.yml +0 -73
  151. data/spec/html/proofer/fixtures/vcr_cassettes/links/brokenHashOnTheWeb_html.yml +0 -56
  152. data/spec/html/proofer/fixtures/vcr_cassettes/links/brokenHashOnTheWeb_html_check_external_hash_true_.yml +0 -719
  153. data/spec/html/proofer/fixtures/vcr_cassettes/links/brokenHashOnTheWeb_html_only_4xx_true_.yml +0 -56
  154. data/spec/html/proofer/fixtures/vcr_cassettes/links/brokenLinkExternal_html.yml +0 -96
  155. data/spec/html/proofer/fixtures/vcr_cassettes/links/brokenUnixLinks_html.yml +0 -156
  156. data/spec/html/proofer/fixtures/vcr_cassettes/links/checkSSLLinks_html.yml +0 -50
  157. data/spec/html/proofer/fixtures/vcr_cassettes/links/check_just_once_html.yml +0 -87
  158. data/spec/html/proofer/fixtures/vcr_cassettes/links/ensure_typhoeus_options_html_typhoeus_ssl_verifypeer_false_.yml +0 -40
  159. data/spec/html/proofer/fixtures/vcr_cassettes/links/escape_pipes_html.yml +0 -52
  160. data/spec/html/proofer/fixtures/vcr_cassettes/links/file_foo_ext_foo_.yml +0 -96
  161. data/spec/html/proofer/fixtures/vcr_cassettes/links/githubHash_html.yml +0 -73
  162. data/spec/html/proofer/fixtures/vcr_cassettes/links/linkWithHttps_html.yml +0 -73
  163. data/spec/html/proofer/fixtures/vcr_cassettes/links/linkWithRedirect_html.yml +0 -236
  164. data/spec/html/proofer/fixtures/vcr_cassettes/links/linkWithRedirect_html_only_4xx_true_typhoeus_followlocation_false_.yml +0 -318
  165. data/spec/html/proofer/fixtures/vcr_cassettes/links/linkWithRedirect_html_typhoeus_followlocation_false_.yml +0 -318
  166. data/spec/html/proofer/fixtures/vcr_cassettes/links/link_missing_protocol_invalid_html.yml +0 -45
  167. data/spec/html/proofer/fixtures/vcr_cassettes/links/link_missing_protocol_valid_html.yml +0 -73
  168. data/spec/html/proofer/fixtures/vcr_cassettes/links/nodupe_html.yml +0 -182
  169. data/spec/html/proofer/fixtures/vcr_cassettes/links/non_standard_characters_html.yml +0 -113
  170. data/spec/html/proofer/fixtures/vcr_cassettes/links/redirected_error_html.yml +0 -1044
  171. data/spec/html/proofer/fixtures/vcr_cassettes/links/utf8Link_html.yml +0 -113
  172. data/spec/html/proofer/fixtures/vcr_cassettes/scripts/script_broken_external_html.yml +0 -45
  173. data/spec/html/proofer/fixtures/vcr_cassettes/sorting/status_typhoeus_followlocation_false_error_sort_status_.yml +0 -244
  174. data/spec/html/proofer/fixtures/vcr_cassettes/sorting/status_verbosity_info_typhoeus_followlocation_false_error_sort_status_.yml +0 -244
  175. data/spec/html/proofer/fixtures/vcr_cassettes/www_garbalarba_com_href_swap_/garbalarba/_github_.yml +0 -73
  176. data/spec/html/proofer/fixtures/vcr_cassettes/www_github_com_foofoofoo_biz.yml +0 -115
  177. data/spec/html/proofer/html_spec.rb +0 -64
  178. data/spec/html/proofer/images_spec.rb +0 -147
  179. data/spec/html/proofer/links_spec.rb +0 -376
  180. data/spec/html/proofer/scripts_spec.rb +0 -46
  181. data/spec/html/proofer/utils_spec.rb +0 -14
  182. data/spec/html/proofer_spec.rb +0 -122
  183. data/spec/spec_helper.rb +0 -75
data/.gitignore DELETED
@@ -1,26 +0,0 @@
1
- *.gem
2
- *.rbc
3
- .bundle
4
- .config
5
- coverage
6
- InstalledFiles
7
- lib/bundler/man
8
- pkg
9
- rdoc
10
- spec/reports
11
- test/tmp
12
- test/version_tmp
13
- tmp
14
-
15
- Gemfile.lock
16
- out/
17
- sample.rb
18
- run_sample.rb
19
- src/
20
- docs/
21
-
22
- # YARD artifacts
23
- .yardoc
24
- _yardoc
25
- doc/
26
- .DS_Store
data/.travis.yml DELETED
@@ -1,14 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 2.0
4
- - 2.1
5
- - 2.2
6
- env:
7
- global:
8
- - NOKOGIRI_USE_SYSTEM_LIBRARIES=true
9
-
10
- sudo: false
11
- cache: bundler
12
-
13
- git:
14
- depth: 10
data/Gemfile DELETED
@@ -1,3 +0,0 @@
1
- source 'http://rubygems.org'
2
-
3
- gemspec
data/LICENSE.txt DELETED
@@ -1,22 +0,0 @@
1
- Copyright (c) 2013 Garen Torikian
2
-
3
- MIT License
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining
6
- a copy of this software and associated documentation files (the
7
- "Software"), to deal in the Software without restriction, including
8
- without limitation the rights to use, copy, modify, merge, publish,
9
- distribute, sublicense, and/or sell copies of the Software, and to
10
- permit persons to whom the Software is furnished to do so, subject to
11
- the following conditions:
12
-
13
- The above copyright notice and this permission notice shall be
14
- included in all copies or substantial portions of the Software.
15
-
16
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md DELETED
@@ -1,276 +0,0 @@
1
- # HTML::Proofer
2
-
3
- If you generate HTML files, _then this tool might be for you_.
4
-
5
- `HTML::Proofer` is a set of tests to validate your HTML output. These tests check if your image references are legitimate, if they have alt tags, if your internal links are working, and so on. It's intended to be an all-in-one checker for your output.
6
-
7
- [![Build Status](https://travis-ci.org/gjtorikian/html-proofer.svg?branch=master)](https://travis-ci.org/gjtorikian/html-proofer) [![Gem Version](https://badge.fury.io/rb/html-proofer.svg)](http://badge.fury.io/rb/html-proofer)
8
-
9
- ## Installation
10
-
11
- Add this line to your application's Gemfile:
12
-
13
- gem 'html-proofer'
14
-
15
- And then execute:
16
-
17
- $ bundle
18
-
19
- Or install it yourself as:
20
-
21
- $ gem install html-proofer
22
-
23
- **NOTE:** When installation speed matters, set `NOKOGIRI_USE_SYSTEM_LIBRARIES` to `true` in your environment. This is useful for increasing the speed of your Continuous Integration builds.
24
-
25
- ## What's Tested?
26
-
27
- You can enable or disable most of the following checks.
28
-
29
- ### Images
30
-
31
- `img` elements:
32
-
33
- * Whether all your images have alt tags
34
- * Whether your internal image references are not broken
35
- * Whether external images are showing
36
-
37
- ### Links
38
-
39
- `a`, `link` elements:
40
-
41
- * Whether your internal links are working
42
- * Whether your internal hash references (`#linkToMe`) are working
43
- * Whether external links are working
44
-
45
- ### Scripts
46
-
47
- `script` elements:
48
-
49
- * Whether your internal script references are working
50
- * Whether external scripts are loading
51
-
52
- ### Favicon
53
-
54
- * Whether your favicons are valid.
55
-
56
- ### HTML
57
-
58
- * Whether your HTML markup is valid. This is done via [Nokogiri, to ensure well-formed markup](http://www.nokogiri.org/tutorials/ensuring_well_formed_markup.html).
59
-
60
- ## Usage
61
-
62
- ### Using in a script
63
-
64
- Require the gem; generate some HTML; create a new instance of the `HTML::Proofer` on
65
- your output folder; then `run` it. Here's a simple example:
66
-
67
- ```ruby
68
- require 'html/proofer'
69
- require 'html/pipeline'
70
- require 'find'
71
-
72
- # make an out dir
73
- Dir.mkdir("out") unless File.exist?("out")
74
-
75
- pipeline = HTML::Pipeline.new [
76
- HTML::Pipeline::MarkdownFilter,
77
- HTML::Pipeline::TableOfContentsFilter
78
- ], :gfm => true
79
-
80
- # iterate over files, and generate HTML from Markdown
81
- Find.find("./docs") do |path|
82
- if File.extname(path) == ".md"
83
- contents = File.read(path)
84
- result = pipeline.call(contents)
85
-
86
- File.open("out/#{path.split("/").pop.sub('.md', '.html')}", 'w') { |file| file.write(result[:output].to_s) }
87
- end
88
- end
89
-
90
- # test your out dir!
91
- HTML::Proofer.new("./out").run
92
- ```
93
-
94
- ### Using on the command-line
95
-
96
- You'll get a new program called `htmlproof` with this gem. Terrific!
97
-
98
- Use it like you'd expect to:
99
-
100
- ``` bash
101
- htmlproof ./out --href-swap wow:cow,mow:doh --ext .html.erb --href-ignore www.github.com
102
- ```
103
-
104
- Note: since `href_swap` is a bit special, you'll pass in a pair of `RegEx:String` values.
105
- `htmlproof` will figure out what you mean.
106
-
107
- ### Using with Jekyll
108
-
109
- Want to use HTML Proofer with your Jekyll site? Awesome. Simply add `gem 'html-proofer'`
110
- to your `Gemfile` as described above, and add the following to your `Rakefile`,
111
- using `rake test` to execute:
112
-
113
- ```ruby
114
- require 'html/proofer'
115
-
116
- task :test do
117
- sh "bundle exec jekyll build"
118
- HTML::Proofer.new("./_site").run
119
- end
120
- ```
121
-
122
- Don't have or want a `Rakefile`? You can also do something like the following:
123
-
124
- ```bash
125
- htmlproof ./_site
126
- ```
127
-
128
- ### Array of links
129
-
130
- Instead of a directory as the first argument, you can also pass in an array of links:
131
-
132
- ``` ruby
133
- HTML::Proofer.new(["http://github.com", "http://jekyllrb.com"])
134
- ```
135
-
136
- This configures Proofer to just test those links to ensure they are valid. Note that for the command-line, you'll need to pass a special `--as-links` argument:
137
-
138
- ``` bash
139
- htmlproof www.google.com,www.github.com --as-links
140
- ```
141
-
142
- ## Ignoring content
143
-
144
- Add the `data-proofer-ignore` attribute to any tag to ignore it from every check.
145
-
146
- ``` html
147
- <a href="http://notareallink" data-proofer-ignore>Not checked.</a>
148
- ```
149
-
150
- ## Configuration
151
-
152
- The `HTML::Proofer` constructor takes an optional hash of additional options:
153
-
154
- | Option | Description | Default |
155
- | :----- | :---------- | :------ |
156
- | `alt_ignore` | An array of Strings or RegExps containing `img`s whose missing `alt` tags are safe to ignore. | `[]` |
157
- | `empty_alt_ignore` | If `true`, ignores images with empty alt tags. | `false` |
158
- | `check_external_hash` | Checks whether external hashes exist (even if the website exists). This slows the checker down. | `false` |
159
- | `check_favicon` | Enables the favicon checker. | `false` |
160
- | `check_html` | Enables HTML validation errors from Nokogiri | `false` |
161
- |`checks_to_ignore`| An array of Strings indicating which checks you'd like to not perform. | `[]`
162
- | `directory_index_file` | Sets the file to look for when a link refers to a directory. | `index.html` |
163
- | `disable_external` | If `true`, does not run the external link checker, which can take a lot of time. | `false` |
164
- | `error_sort` | Defines the sort order for error output. Can be `:path`, `:desc`, or `:status`. | `:path`
165
- | `ext` | The extension of your HTML files including the dot. | `.html`
166
- | `file_ignore` | An array of Strings or RegExps containing file paths that are safe to ignore. | `[]` |
167
- | `href_ignore` | An array of Strings or RegExps containing `href`s that are safe to ignore. Note that non-HTTP(S) URIs are always ignored. **Will be renamed in a future release.** | `[]` |
168
- | `href_swap` | A hash containing key-value pairs of `RegExp => String`. It transforms links that match `RegExp` into `String` via `gsub`. **Will be renamed in a future release.** | `{}` |
169
- | `ignore_script_embeds` | When `check_html` is enabled, `script` tags containing markup [are reported as errors](http://git.io/vOovv). Enabling this option ignores those errors. | `false`
170
- | `only_4xx` | Only reports errors for links that fall within the 4xx status code range. | `false` |
171
- | `url_ignore` | An array 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. | `[]` |
172
- | `verbose` | If `true`, outputs extra information as the checking happens. Useful for debugging. **Will be deprecated in a future release.**| `false` |
173
- | `verbosity` | Sets the logging level, as determined by [Yell](https://github.com/rudionrails/yell). | `:info`
174
-
175
- ### Configuring Typhoeus and Hydra
176
-
177
- [Typhoeus](https://github.com/typhoeus/typhoeus) is used to make fast, parallel requests to external URLs. You can pass in any of Typhoeus' options for the external link checks with the options namespace of `:typhoeus`. For example:
178
-
179
- ``` ruby
180
- HTML::Proofer.new("out/", {:ext => ".htm", :typhoeus => { :verbose => true, :ssl_verifyhost => 2 } })
181
- ```
182
-
183
- This sets `HTML::Proofer`'s extensions to use _.htm_, gives Typhoeus a configuration for it to be verbose, and use specific SSL settings. Check [the Typhoeus documentation](https://github.com/typhoeus/typhoeus#other-curl-options) for more information on what options it can receive.
184
-
185
- You can similarly pass in a `:hydra` option with a hash configuration for Hydra.
186
-
187
- The default value is `typhoeus => { :followlocation => true }`.
188
-
189
- ### Configuring Parallel
190
-
191
- [Parallel](https://github.com/grosser/parallel) is used to speed internal file checks. You can pass in any of its options with the options namespace `:parallel`. For example:
192
-
193
- ``` ruby
194
- HTML::Proofer.new("out/", {:ext => ".htm", :parallel => { :in_processes => 3} })
195
- ```
196
-
197
- In this example, `:in_processes => 3` is passed into Parallel as a configuration option.
198
-
199
- ## Logging
200
-
201
- HTML-Proofer can be as noisy or as quiet as you'd like. There are two ways to log information:
202
-
203
- * If you set the `:verbose` option to `true`, HTML-Proofer will provide some debug information.
204
- * If you set the `:verbosity` option, you can better define the level of logging. See the configuration table above for more information.
205
-
206
- `:verbosity` is newer and offers better configuration. `:verbose` will be deprecated in a future 3.x.x release.
207
-
208
- ## Custom tests
209
-
210
- Want to write your own test? Sure! Just create two classes--one that inherits from `HTML::Proofer::Checkable`, and another that inherits from `HTML::Proofer::CheckRunner`.
211
-
212
- The `CheckRunner` subclass must define one method called `run`. This is called on your content, and is responsible for performing the validation on whatever elements you like. When you catch a broken issue, call `add_issue(message)` to explain the error.
213
-
214
- The `Checkable` subclass defines various helper methods you can use as part of your test. Usually, you'll want to instantiate it within `run`. You have access to all of your element's attributes.
215
-
216
- Here's an example custom test that protects against `mailto` links that point to `octocat@github.com`:
217
-
218
- ``` ruby
219
- class OctocatLinkCheck < ::HTML::Proofer::Checkable
220
- def mailto?
221
- return false if @data_ignore_proofer || @href.nil? || @href.empty?
222
- return @href.match /^mailto\:/
223
- end
224
-
225
- def octocat?
226
- return @href.match /\:octocat@github.com\Z/
227
- end
228
-
229
- end
230
-
231
- class MailToOctocat < ::HTML::Proofer::CheckRunner
232
- def run
233
- @html.css('a').each do |node|
234
- link = OctocatLinkCheck.new(node, self)
235
- line = node.line
236
-
237
- if link.mailto? && link.octocat?
238
- return add_issue("Don't email the Octocat directly!", line)
239
- end
240
- end
241
- end
242
- end
243
- ```
244
-
245
- ## Troubleshooting
246
-
247
- ### Certificates
248
-
249
- To ignore certificates, turn off Typhoeus' SSL verification:
250
-
251
- ``` ruby
252
- HTML::Proofer.new("out/", {
253
- :typhoeus => {
254
- :ssl_verifypeer => false,
255
- :ssl_verifyhost => 0}
256
- }).run
257
- ```
258
-
259
- ### User-Agent
260
-
261
- To change the User-Agent used by Typhoeus:
262
-
263
- ``` ruby
264
- HTML::Proofer.new("out/", {
265
- :typhoeus => {
266
- :headers => { "User-Agent" => "Mozilla/5.0 (compatible; My New User-Agent)" }
267
- }}).run
268
- ```
269
-
270
- ## Real-life examples
271
-
272
- Project | Repository
273
- :--- | :---
274
- [Raspberry Pi documentation](http://www.raspberrypi.org/documentation/) | [raspberrypi/documentation]( https://github.com/raspberrypi/documentation)
275
- [Open Whisper Systems website](https://whispersystems.org/) | [WhisperSystems/whispersystems.org](https://github.com/WhisperSystems/whispersystems.org)
276
- [Jekyll website](http://jekyllrb.com/) | [jekyll/jekyll](https://github.com/jekyll/jekyll)
data/Rakefile DELETED
@@ -1,21 +0,0 @@
1
- require 'bundler'
2
- Bundler::GemHelper.install_tasks
3
-
4
- require 'rspec/core/rake_task'
5
-
6
- RSpec::Core::RakeTask.new(:spec)
7
-
8
- task :default => [:spec, :proof_readme]
9
-
10
- task :proof_readme do
11
- require 'html/proofer'
12
- require 'redcarpet'
13
-
14
- redcarpet = Redcarpet::Markdown.new Redcarpet::Render::HTML.new({}), {}
15
- html = redcarpet.render File.read('README.md')
16
-
17
- mkdir_p 'out'
18
- File.write('out/README.html', html)
19
-
20
- HTML::Proofer.new('./out').run
21
- end
data/html-proofer.gemspec DELETED
@@ -1,32 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
- $LOAD_PATH.push File.expand_path('../lib', __FILE__)
3
- require 'html/proofer/version'
4
-
5
- Gem::Specification.new do |gem|
6
- gem.name = 'html-proofer'
7
- gem.version = HTML::Proofer::VERSION
8
- gem.authors = ['Garen Torikian']
9
- gem.email = ['gjtorikian@gmail.com']
10
- gem.description = %(Test your rendered HTML files to make sure they're accurate.)
11
- gem.summary = %(A set of tests to validate your HTML output. These tests check if your image references are legitimate, if they have alt tags, if your internal links are working, and so on. It's intended to be an all-in-one checker for your documentation output.)
12
- gem.homepage = 'https://github.com/gjtorikian/html-proofer'
13
- gem.license = 'MIT'
14
- gem.executables = ['htmlproof']
15
- gem.files = `git ls-files -z`.split("\x0")
16
- gem.test_files = gem.files.grep(%r{^(spec)/})
17
- gem.require_paths = ['lib']
18
-
19
- gem.add_dependency 'mercenary', '~> 0.3.2'
20
- gem.add_dependency 'nokogiri', '~> 1.5'
21
- gem.add_dependency 'colored', '~> 1.2'
22
- gem.add_dependency 'typhoeus', '~> 0.7'
23
- gem.add_dependency 'yell', '~> 2.0'
24
- gem.add_dependency 'parallel', '~> 1.3'
25
- gem.add_dependency 'addressable', '~> 2.3'
26
-
27
- gem.add_development_dependency 'redcarpet'
28
- gem.add_development_dependency 'rspec', '~> 3.1'
29
- gem.add_development_dependency 'rake'
30
- gem.add_development_dependency 'awesome_print'
31
- gem.add_development_dependency 'vcr', '~> 2.9'
32
- end
data/script/bootstrap DELETED
@@ -1,5 +0,0 @@
1
- #!/bin/sh
2
-
3
- set -e
4
-
5
- bundle install "$@"
@@ -1,47 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe HTML::Proofer::Checkable do
4
- describe '#initialize' do
5
- it 'accepts the xmlns attribute' do
6
- nokogiri = Nokogiri::HTML '<a xmlns:cc="http://creativecommons.org/ns#">Creative Commons</a>'
7
- checkable = HTML::Proofer::Checkable.new nokogiri.css('a').first, nil
8
- expect(checkable.instance_variable_get(:@xmlns_cc)).to eq 'http://creativecommons.org/ns#'
9
- end
10
- it 'assignes the text node' do
11
- nokogiri = Nokogiri::HTML '<p>One'
12
- checkable = HTML::Proofer::Checkable.new nokogiri.css('p').first, nil
13
- expect(checkable.instance_variable_get(:@text)).to eq 'One'
14
- end
15
- it 'accepts the content attribute' do
16
- nokogiri = Nokogiri::HTML '<meta name="twitter:card" content="summary">'
17
- checkable = HTML::Proofer::Checkable.new nokogiri.css('meta').first, nil
18
- expect(checkable.instance_variable_get(:@content)).to eq 'summary'
19
- end
20
- end
21
- describe '#ignores_pattern_check' do
22
- it 'works for regex patterns' do
23
- nokogiri = Nokogiri::HTML '<script src=/assets/main.js></script>'
24
- checkable = HTML::Proofer::Checkable.new nokogiri.css('script').first, nil
25
- expect(checkable.ignores_pattern_check([/\/assets\/.*(js|css|png|svg)/])).to eq true
26
- end
27
- it 'works for string patterns' do
28
- nokogiri = Nokogiri::HTML '<script src=/assets/main.js></script>'
29
- checkable = HTML::Proofer::Checkable.new nokogiri.css('script').first, nil
30
- expect(checkable.ignores_pattern_check(['/assets/main.js'])).to eq true
31
- end
32
- end
33
- describe '#url' do
34
- it 'works for src attributes' do
35
- nokogiri = Nokogiri::HTML '<img src=image.png />'
36
- checkable = HTML::Proofer::Checkable.new nokogiri.css('img').first, nil
37
- expect(checkable.url).to eq 'image.png'
38
- end
39
- end
40
- describe '#ignore' do
41
- it 'works for twitter cards' do
42
- nokogiri = Nokogiri::HTML '<meta name="twitter:url" data-proofer-ignore content="http://example.com/soon-to-be-published-url">'
43
- checkable = HTML::Proofer::Checkable.new nokogiri.css('meta').first, nil
44
- expect(checkable.ignore?).to eq true
45
- end
46
- end
47
- end