diff --git a/README.md b/README.md index 28fcd463..e7927684 100644 --- a/README.md +++ b/README.md @@ -36,45 +36,45 @@ Below is a mostly comprehensive list of checks that HTMLProofer can perform. `img` elements: -* Whether all your images have alt tags -* Whether your internal image references are not broken -* Whether external images are showing -* Whether your images are HTTP +- Whether all your images have alt tags +- Whether your internal image references are not broken +- Whether external images are showing +- Whether your images are HTTP ### Links `a`, `link` elements: -* Whether your internal links are working -* Whether your internal hash references (`#linkToMe`) are working -* Whether external links are working -* Whether your links are HTTPS -* Whether CORS/SRI is enabled +- Whether your internal links are working +- Whether your internal hash references (`#linkToMe`) are working +- Whether external links are working +- Whether your links are HTTPS +- Whether CORS/SRI is enabled ### Scripts `script` elements: -* Whether your internal script references are working -* Whether external scripts are loading -* Whether CORS/SRI is enabled +- Whether your internal script references are working +- Whether external scripts are loading +- Whether CORS/SRI is enabled ### Favicon -* Whether your favicons are valid. +- Whether your favicons are valid. ### OpenGraph -* Whether the images and URLs in the OpenGraph metadata are valid. +- Whether the images and URLs in the OpenGraph metadata are valid. ## Usage You can configure HTMLProofer to run on: -* a file -* a directory -* an array of directories -* an array of links +- a file +- a directory +- an array of directories +- an array of links It can also run through the command-line. @@ -118,7 +118,7 @@ HTMLProofer.check_directory("./out").run If you simply want to check a single file, use the `check_file` method: -``` ruby +```ruby HTMLProofer.check_file("/path/to/a/file.html").run ``` @@ -126,13 +126,13 @@ HTMLProofer.check_file("/path/to/a/file.html").run If you want to check a directory, use `check_directory`: -``` ruby +```ruby HTMLProofer.check_directory("./out").run ``` If you want to check multiple directories, use `check_directories`: -``` ruby +```ruby HTMLProofer.check_directories(["./one", "./two"]).run ``` @@ -140,7 +140,7 @@ HTMLProofer.check_directories(["./one", "./two"]).run With `check_links`, you can also pass in an array of links: -``` ruby +```ruby HTMLProofer.check_links(["https://github.com", "https://jekyllrb.com"]).run ``` @@ -157,7 +157,7 @@ In this case, any link that matches the `^https://placeholder.com` will be conve A similar swapping process can be done for attributes: ```ruby -run_proofer(file, :file, swap_attributes: { "img": [["data-src", "src"]] }) +run_proofer(file, :file, swap_attributes: { "img" => [["data-src", "src"]] }) ``` In this case, we are telling HTMLProofer that, for any `img` tag detected, for any `src` attribute, pretend it's actually the `src` attribute instead. Since the value is an array of arrays, you can pass in as many attribute swaps as you need for each element. @@ -168,7 +168,7 @@ You'll also get a new program called `htmlproofer` with this gem. Terrific! Pass in options through the command-line as flags, like this: -``` bash +```bash htmlproofer --extensions .html.erb ./out ``` @@ -179,14 +179,14 @@ Use `htmlproofer --help` to see all command line options. For options which require an array of input, surround the value with quotes, and don't use any spaces. For example, to exclude an array of HTTP status code, you might do: -``` bash +```bash htmlproofer --ignore-status-codes "999,401,404" ./out ``` For something like `url-ignore`, and other options that require an array of regular expressions, you can pass in a syntax like this: -``` bash +```bash htmlproofer --ignore-urls "/www.github.com/,/foo.com/" ./out ``` @@ -194,7 +194,7 @@ Since `swap_urls` is a bit special, you'll pass in a pair of `RegEx:String` values. The escape sequences `\:` should be used to produce literal `:`s `htmlproofer` will figure out what you mean. -``` bash +```bash htmlproofer --swap-urls "wow:cow,mow:doh" --extensions .html.erb --ignore-urls www.github.com ./out ``` @@ -229,18 +229,17 @@ end If you have trouble with (or don't want to) install Ruby/Nokogumbo, the command-line tool can be run through Docker. See [klakegg/html-proofer](https://hub.docker.com/r/klakegg/html-proofer) for more information. - ## Ignoring content Add the `data-proofer-ignore` attribute to any tag to ignore it from every check. -``` html +```html Not checked. ``` This can also apply to parent elements, all the way up to the `` tag: -``` html +```html
Not checked because of parent.
@@ -267,41 +266,41 @@ HTMLProofer.check_directory("./output", { ignore_urls: diffable_files }).run The `HTMLProofer` constructor takes an optional hash of additional options: -| Option | Description | Default | -| :----- | :---------- | :------ | -| `allow_hash_href` | If `true`, assumes `href="#"` anchors are valid | `true` | -| `allow_missing_href` | If `true`, does not flag `a` tags missing `href`. In HTML5, this is technically allowed, but could also be human error. | `false` | -| `assume_extension` | Automatically add specified extension to files for internal links, to allow extensionless URLs (as supported by most servers) | `.html` | -| `checks`| An array of Strings indicating which checks you want to run | `['Links', 'Images', 'Scripts']` -| `check_external_hash` | Checks whether external hashes exist (even if the webpage exists) | `true` | -| `check_internal_hash` | Checks whether internal hashes exist (even if the webpage exists) | `true` | -| `check_sri` | Check that `` and `