html-proofer-mailto_awesome 1.0.6 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6774a7d7ae064cad6e905dacdac112cc4bb6d57eb6fb5d73fff581641a9b4ded
4
- data.tar.gz: 74b86c00f139f98be460132271e573e6b20a48ff78bf6be260cf2ce8520e70c5
3
+ metadata.gz: 6411236c394f40f47f399843d66e72fd0c23dbeff791b9f424b17b1d3109d00d
4
+ data.tar.gz: aec40d5251f5ae89c1fb928a22d42c94a4838b0ec10c21ad4cb6701f877690fd
5
5
  SHA512:
6
- metadata.gz: 4a2a0bf3339553beff2ce484913a73145f3b9efd8b6176a0412aa730a9830e5979509793c36885902177978d52400afee8629d9271fc7f7e2a5f17ebe03b20bb
7
- data.tar.gz: b487ec54c99e73222191bf38727d93967b8b6bfa15e10cef45815a2bcbc3060e0cc12e9897dccd7aae73b839bcfe4f4f58f02ae26020926fd876a66db5b0d2c1
6
+ metadata.gz: 1656ce1159562e5a4247f852f69290f8442dea492d842dcbc82e79c828edb9a5e18d36b71a8b6474c63c8d3bc4d69609ffd17efa752f204a75a58972cd3bd85d
7
+ data.tar.gz: e7d4983774757825b40c346932b736790a2f1553027f4995c50cc79902043523f7433dab3c2e963ab948e15f85a095223d7a9ee33110b1e8a1f5bc61ec17ec1b
data/.editorconfig ADDED
@@ -0,0 +1,13 @@
1
+ # UTF-8, LF, and spaces. Trailing whitespace is kept so a Markdown hard break (two spaces) stays intact.
2
+ root = true
3
+
4
+ [*]
5
+ charset = utf-8
6
+ end_of_line = lf
7
+ indent_style = space
8
+ insert_final_newline = true
9
+ trim_trailing_whitespace = false
10
+ max_line_length = 120
11
+
12
+ [*.md]
13
+ max_line_length = off
data/.github/FUNDING.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  # These are supported funding model platforms
2
2
 
3
3
  github: [fulldecent]
4
- custom: ["https://www.paypal.me/fulldecent", "https://amazon.com/hz/wishlist/ls/EE78A23EEGQB"]
4
+ custom: ["https://www.paypal.me/fulldecent"]
@@ -0,0 +1,30 @@
1
+ name: Lint
2
+
3
+ on:
4
+ push:
5
+ branches: ["main"]
6
+ pull_request:
7
+ # Runs on all pull requests targeting any branch
8
+ branches: ["**"]
9
+
10
+ jobs:
11
+ lint:
12
+ name: Prettier & Markdownlint
13
+ runs-on: ubuntu-latest
14
+
15
+ steps:
16
+ - name: Checkout code
17
+ uses: actions/checkout@v7
18
+
19
+ - name: Setup Node.js (tool runtime)
20
+ uses: actions/setup-node@v7
21
+ with:
22
+ node-version: "lts/*" # Floating version is appropriate specifically for Prettier and markdownlint
23
+
24
+ - name: Check formatting (Prettier)
25
+ # Command fails if any files do not meet the formatting rules.
26
+ run: npx prettier@latest --check .
27
+
28
+ - name: Check Markdown (markdownlint)
29
+ # Command fails if any markdown files do not meet the linting rules.
30
+ run: npx markdownlint-cli@latest "**/*.md" --ignore "node_modules"
@@ -1,38 +1,37 @@
1
- # This workflow uses actions that are not certified by GitHub.
2
- # They are provided by a third-party and are governed by
3
- # separate terms of service, privacy policy, and support
4
- # documentation.
5
- # This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
6
- # For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
1
+ # Ruby branches still in normal or security maintenance:
2
+ # https://www.ruby-lang.org/en/downloads/branches/
7
3
 
8
- name: Ruby
4
+ name: Test
9
5
 
10
6
  on:
11
7
  push:
12
- branches: [ "main" ]
8
+ branches: ["main"]
13
9
  pull_request:
14
- branches: [ "main" ]
10
+ branches: ["**"]
15
11
 
16
12
  permissions:
17
13
  contents: read
18
14
 
15
+ concurrency:
16
+ group: ${{ github.workflow }}-${{ github.ref }}
17
+ cancel-in-progress: true
18
+
19
19
  jobs:
20
20
  test:
21
-
22
21
  runs-on: ubuntu-latest
23
22
  strategy:
23
+ fail-fast: false
24
24
  matrix:
25
- ruby-version: ['2.6', '2.7', '3.0']
26
-
25
+ ruby-version: ["3.3", "3.4", "4.0"]
27
26
  steps:
28
- - uses: actions/checkout@v3
29
- - name: Set up Ruby
30
- # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
31
- # change this to (see https://github.com/ruby/setup-ruby#versioning):
32
- # uses: ruby/setup-ruby@v1
33
- uses: ruby/setup-ruby@ee2113536afb7f793eed4ce60e8d3b26db912da4 # v1.127.0
34
- with:
35
- ruby-version: ${{ matrix.ruby-version }}
36
- bundler-cache: true # runs 'bundle install' and caches installed gems automatically
37
- - name: Run tests
38
- run: bundle exec rake
27
+ - name: Checkout code
28
+ uses: actions/checkout@v7
29
+
30
+ - name: Set up Ruby ${{ matrix.ruby-version }}
31
+ uses: ruby/setup-ruby@v1
32
+ with:
33
+ ruby-version: ${{ matrix.ruby-version }}
34
+ bundler-cache: true
35
+
36
+ - name: Run tests
37
+ run: bundle exec rake
data/.gitignore CHANGED
@@ -1,3 +1,5 @@
1
+ .DS_Store
2
+
1
3
  /.bundle/
2
4
  /.yardoc
3
5
  /_yardoc/
@@ -9,4 +11,7 @@
9
11
 
10
12
  # rspec failure tracking
11
13
  .rspec_status
12
- /vendor/*
14
+ /vendor/*
15
+
16
+ # The lint workflow runs npx, which can leave a local install tree.
17
+ node_modules/
@@ -0,0 +1,3 @@
1
+ {
2
+ "MD013": false
3
+ }
data/.prettierignore ADDED
@@ -0,0 +1 @@
1
+ *.md
data/Gemfile.lock CHANGED
@@ -1,85 +1,118 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- html-proofer-mailto_awesome (1.0.1)
4
+ html-proofer-mailto_awesome (2.1.0)
5
5
  html-proofer (~> 5.0, >= 5.0.4)
6
+ logger
6
7
 
7
8
  GEM
8
9
  remote: https://rubygems.org/
9
10
  specs:
10
- Ascii85 (1.1.0)
11
- addressable (2.8.1)
12
- public_suffix (>= 2.0.2, < 6.0)
11
+ Ascii85 (2.0.1)
12
+ addressable (2.9.0)
13
+ public_suffix (>= 2.0.2, < 8.0)
13
14
  afm (0.2.2)
14
- async (2.3.1)
15
- console (~> 1.10)
16
- io-event (~> 1.1)
17
- timers (~> 4.1)
18
- console (1.16.2)
19
- fiber-local
20
- diff-lcs (1.5.0)
21
- ethon (0.16.0)
15
+ async (2.21.2)
16
+ console (~> 1.29)
17
+ fiber-annotation
18
+ io-event (~> 1.6, >= 1.6.5)
19
+ benchmark (0.5.0)
20
+ bigdecimal (3.2.3)
21
+ console (1.30.2)
22
+ fiber-annotation
23
+ fiber-local (~> 1.1)
24
+ json
25
+ diff-lcs (1.6.2)
26
+ ethon (0.15.0)
22
27
  ffi (>= 1.15.0)
23
- ffi (1.15.5)
24
- fiber-local (1.0.0)
28
+ ffi (1.17.4-aarch64-linux-gnu)
29
+ ffi (1.17.4-aarch64-linux-musl)
30
+ ffi (1.17.4-arm-linux-gnu)
31
+ ffi (1.17.4-arm-linux-musl)
32
+ ffi (1.17.4-arm64-darwin)
33
+ ffi (1.17.4-x86_64-darwin)
34
+ ffi (1.17.4-x86_64-linux-gnu)
35
+ ffi (1.17.4-x86_64-linux-musl)
36
+ fiber-annotation (0.2.0)
37
+ fiber-local (1.1.0)
38
+ fiber-storage
39
+ fiber-storage (1.0.1)
25
40
  hashery (2.1.2)
26
- html-proofer (5.0.4)
41
+ html-proofer (5.2.2)
27
42
  addressable (~> 2.3)
28
43
  async (~> 2.1)
44
+ benchmark (~> 0.5)
29
45
  nokogiri (~> 1.13)
30
46
  pdf-reader (~> 2.11)
31
47
  rainbow (~> 3.0)
32
48
  typhoeus (~> 1.3)
33
49
  yell (~> 2.0)
34
50
  zeitwerk (~> 2.5)
35
- io-event (1.1.6)
36
- mini_portile2 (2.8.1)
37
- nokogiri (1.14.2)
38
- mini_portile2 (~> 2.8.0)
51
+ io-event (1.11.2)
52
+ json (2.15.2.1)
53
+ logger (1.7.0)
54
+ nokogiri (1.19.4-aarch64-linux-gnu)
39
55
  racc (~> 1.4)
40
- pdf-reader (2.11.0)
41
- Ascii85 (~> 1.0)
42
- afm (~> 0.2.1)
56
+ nokogiri (1.19.4-aarch64-linux-musl)
57
+ racc (~> 1.4)
58
+ nokogiri (1.19.4-arm-linux-gnu)
59
+ racc (~> 1.4)
60
+ nokogiri (1.19.4-arm-linux-musl)
61
+ racc (~> 1.4)
62
+ nokogiri (1.19.4-arm64-darwin)
63
+ racc (~> 1.4)
64
+ nokogiri (1.19.4-x86_64-darwin)
65
+ racc (~> 1.4)
66
+ nokogiri (1.19.4-x86_64-linux-gnu)
67
+ racc (~> 1.4)
68
+ nokogiri (1.19.4-x86_64-linux-musl)
69
+ racc (~> 1.4)
70
+ pdf-reader (2.15.0)
71
+ Ascii85 (>= 1.0, < 3.0, != 2.0.0)
72
+ afm (>= 0.2.1, < 2)
43
73
  hashery (~> 2.0)
44
74
  ruby-rc4
45
75
  ttfunk
46
- public_suffix (5.0.1)
47
- racc (1.6.2)
76
+ public_suffix (6.0.2)
77
+ racc (1.8.1)
48
78
  rainbow (3.1.1)
49
- rake (13.0.6)
50
- rspec (3.12.0)
51
- rspec-core (~> 3.12.0)
52
- rspec-expectations (~> 3.12.0)
53
- rspec-mocks (~> 3.12.0)
54
- rspec-core (3.12.1)
55
- rspec-support (~> 3.12.0)
56
- rspec-expectations (3.12.2)
79
+ rake (13.3.0)
80
+ rspec (3.13.1)
81
+ rspec-core (~> 3.13.0)
82
+ rspec-expectations (~> 3.13.0)
83
+ rspec-mocks (~> 3.13.0)
84
+ rspec-core (3.13.5)
85
+ rspec-support (~> 3.13.0)
86
+ rspec-expectations (3.13.5)
57
87
  diff-lcs (>= 1.2.0, < 2.0)
58
- rspec-support (~> 3.12.0)
59
- rspec-mocks (3.12.3)
88
+ rspec-support (~> 3.13.0)
89
+ rspec-mocks (3.13.5)
60
90
  diff-lcs (>= 1.2.0, < 2.0)
61
- rspec-support (~> 3.12.0)
62
- rspec-support (3.12.0)
91
+ rspec-support (~> 3.13.0)
92
+ rspec-support (3.13.6)
63
93
  ruby-rc4 (0.1.5)
64
- timecop (0.9.6)
65
- timers (4.3.5)
66
- ttfunk (1.7.0)
67
- typhoeus (1.4.0)
68
- ethon (>= 0.9.0)
69
- vcr (6.1.0)
94
+ ttfunk (1.8.0)
95
+ bigdecimal (~> 3.1)
96
+ typhoeus (1.5.0)
97
+ ethon (>= 0.9.0, < 0.16.0)
70
98
  yell (2.2.2)
71
- zeitwerk (2.6.7)
99
+ zeitwerk (2.6.18)
72
100
 
73
101
  PLATFORMS
74
- ruby
102
+ aarch64-linux-gnu
103
+ aarch64-linux-musl
104
+ arm-linux-gnu
105
+ arm-linux-musl
106
+ arm64-darwin
107
+ x86_64-darwin
108
+ x86_64-linux-gnu
109
+ x86_64-linux-musl
75
110
 
76
111
  DEPENDENCIES
77
- bundler (~> 2.0.2)
112
+ bundler (>= 2.0)
78
113
  html-proofer-mailto_awesome!
79
- rake (~> 13.0.6)
80
- rspec (~> 3.12, >= 3.12.0)
81
- timecop (~> 0.9, >= 0.9.6)
82
- vcr (~> 6.1, >= 6.1.0)
114
+ rake (>= 13.0)
115
+ rspec (~> 3.12)
83
116
 
84
117
  BUNDLED WITH
85
- 2.0.2
118
+ 2.6.9
data/README.md CHANGED
@@ -1,80 +1,140 @@
1
- ![Gem](https://img.shields.io/gem/v/html-proofer-mailto_awesome) [![Ruby](https://github.com/fulldecent/html-proofer-mailto_awesome/actions/workflows/ruby.yml/badge.svg)](https://github.com/fulldecent/html-proofer-mailto_awesome/actions/workflows/ruby.yml)
2
-
3
1
  # html-proofer-mailto_awesome
4
- A custom [html-proofer](https://github.com/gjtorikian/html-proofer) test that makes your `mailto:` links awesome.
5
2
 
6
- ## What is an awesome `mailto` link?
3
+ ![Gem](https://img.shields.io/gem/v/html-proofer-mailto_awesome) [![Test](https://github.com/fulldecent/html-proofer-mailto_awesome/actions/workflows/ruby.yml/badge.svg)](https://github.com/fulldecent/html-proofer-mailto_awesome/actions/workflows/ruby.yml) [![Lint](https://github.com/fulldecent/html-proofer-mailto_awesome/actions/workflows/lint.yml/badge.svg)](https://github.com/fulldecent/html-proofer-mailto_awesome/actions/workflows/lint.yml)
4
+
5
+ An [html-proofer](https://github.com/gjtorikian/html-proofer) check that requires `mailto:` links to carry the header fields you want every message to start with.
6
+
7
+ ## What an awesome mailto link is
7
8
 
8
- We should use awesome links as psychological warfare against users. Users will send us emails with stupid or annoying content that we don't want. At big companies (like Amazon) they have abandoned email altogether because of this reason. So instead we prefill the email with the message we want to receive. It takes active cognitive effort for the user to put in their unwanted message.
9
+ People send email we did not ask for. A bare `mailto:` link opens a blank message, and the sender fills that blank with whatever is on their mind. Prefilling the subject and the body makes the useful message the path of least resistance. Replacing it takes effort.
9
10
 
10
- For example, this is a not-awesome `mailto` link:
11
+ This is a not-awesome link:
11
12
 
12
13
  ```html
13
14
  <a href="mailto:support@pacificmedicaltraining.com">Email us</a>
14
15
  ```
15
16
 
16
- This is an awesome link:
17
+ This is an awesome link. The subject and the body are already there:
17
18
 
18
19
  ```html
19
- <a href="mailto:support@pacificmedicaltraining.com?subject=Signing up&amp;body=Hello,\nI'd like to sign up for your course, can you please send me more information.">Email us</a>
20
+ <a
21
+ href="mailto:support@pacificmedicaltraining.com?subject=Signing%20up&amp;body=Hello%2C%0AI%20would%20like%20to%20sign%20up."
22
+ >
23
+ Email us
24
+ </a>
20
25
  ```
21
26
 
22
- For more reference, see http://marcwitteveen.com/mailtogenerator/
27
+ [RFC 6068](https://www.rfc-editor.org/rfc/rfc6068) is the `mailto:` URI scheme. In HTML, write `&amp;` for an ampersand inside the attribute. Header field names are case-insensitive. `Subject` and `subject` are the same field.
23
28
 
24
- ## How do I use it
29
+ The same rule is published for HTML-validate as [`nice-checkers/mailto-awesome`](https://github.com/fulldecent/html-validate-nice-checkers#nice-checkersmailto-awesome).
25
30
 
26
- Follow the same instructions as for any [html-proofer custom class](https://github.com/gjtorikian/html-proofer/wiki/Extensions-(custom-classes)).
31
+ ## Installation
27
32
 
28
- Our ruby gem is [html-proofer-mailto_awesome](https://rubygems.org/gems/html-proofer-mailto_awesome)
33
+ This gem runs on the Ruby branches that are still in normal or security maintenance: 3.3, 3.4, and 4.0. The list is [Ruby maintenance branches](https://www.ruby-lang.org/en/downloads/branches/). Install one of those Rubies from that page.
29
34
 
30
- 1. Add new dependency to your Ruby project
31
-
32
- In Gemfile:
33
-
34
- gem 'html-proofer-mailto_awesome'
35
-
36
- Or in your .gemspec:
35
+ Add the gem to the application that builds or checks the site:
37
36
 
38
- Gem::Specification.new do |s|
39
- ...
40
- s.add_runtime_dependency 'html-proofer-mailto_awesome'
41
- end
42
-
43
- 2. Create a Rakefile like the following and add it to your project
37
+ ```ruby
38
+ gem "html-proofer-mailto_awesome"
39
+ ```
44
40
 
45
- task :default => [:test]
46
-
47
- desc 'run Rspec specs'
48
- task :test do
49
- sh 'rspec spec'
50
- end
51
-
52
- 3. Run `bundle install`
41
+ Then install:
53
42
 
54
- 4. Run `rake`
43
+ ```sh
44
+ bundle install
45
+ ```
55
46
 
56
- Also if you like, you can enable your project for continuous integration testing with Travis:
47
+ ## Usage
57
48
 
58
- 1. Set up Travis CI for your project
49
+ html-proofer runs only the checks named in `checks`. That option replaces the default list, which is `Links`, `Images`, and `Scripts`. Include those names when you still want them, and add `MailtoAwesome`.
59
50
 
60
- 2. Add a `.travis.yml` file like the following to your project and your spec will run automatically
51
+ Require this gem before `run`. html-proofer discovers the check by looking at classes that are already loaded.
61
52
 
62
- language: ruby
63
- rvm:
64
- - 2.5.3
65
- For additional tests you can run on your website, see [Lightning Sites](https://github.com/fulldecent/lightning-sites) and for a sample GitHub project that implements this testing and follows many other HTML development best practices, see [HTML Website Template](https://github.com/fulldecent/html-website-template).
53
+ ```ruby
54
+ require "html-proofer"
55
+ require "html-proofer-mailto_awesome"
66
56
 
67
- For a full example of a website project that includes testing continuous integration testing for awesome mailto links and many other best practices, see our
68
-
69
- ## Contributing
57
+ desc "Check the built site"
58
+ task :test do
59
+ HTMLProofer.check_directory("_site", {
60
+ checks: ["Links", "Images", "Scripts", "MailtoAwesome"],
61
+ }).run
62
+ end
70
63
 
71
- This project is released under the MIT license.
64
+ task default: :test
65
+ ```
72
66
 
73
- Releasing new versions:
67
+ Run it with Bundler so the gem is on the load path:
74
68
 
75
69
  ```sh
76
- gem bump
77
- rm html-proofer-mailto_awesome-*.gem
70
+ bundle exec rake
71
+ ```
72
+
73
+ `MailtoAwesome` looks at `a` elements. A `mailto:` link passes when every required header field is present. The default required fields are `subject` and `body`. An empty value still counts as present (`subject=`). Text in the address, such as `mailto:subject=trick@example.com`, is not a header field.
74
+
75
+ A link that omits a field fails with `mailto: link is missing required parameters: subject, body`. A `mailto:` value that Ruby cannot parse as a URI fails with `mailto: link is malformed and could not be parsed.`
76
+
77
+ `data-proofer-ignore` skips the link, as it does for the other html-proofer checks.
78
+
79
+ ## Configuration
80
+
81
+ `mailto_awesome.required_parameters` replaces the default list. This matches the HTML-validate rule, which uses `requiredParameters` for the same purpose. Pass an empty array when you want the check loaded and no fields required.
82
+
83
+ ```ruby
84
+ HTMLProofer.check_directory("_site", {
85
+ checks: ["Links", "Images", "Scripts", "MailtoAwesome"],
86
+ mailto_awesome: {
87
+ required_parameters: ["subject", "body"],
88
+ },
89
+ }).run
90
+ ```
91
+
92
+ ## Development
93
+
94
+ Clone the repository and install the gems it uses to test itself:
95
+
96
+ ```sh
97
+ git clone https://github.com/fulldecent/html-proofer-mailto_awesome.git
98
+ cd html-proofer-mailto_awesome
99
+ bundle install
100
+ bundle exec rake
101
+ ```
102
+
103
+ Format the files the lint workflow checks. These commands call `@latest` on purpose. A pinned copy would let your machine rewrite files one way and continuous integration reject them another way. [node.js-template](https://github.com/fulldecent/node.js-template) records that constraint on its `format` script.
104
+
105
+ ```sh
106
+ npx prettier@latest --write .
107
+ npx markdownlint-cli@latest --fix "**/*.md" --ignore node_modules
108
+ ```
109
+
110
+ `*.md` is in `.prettierignore`. Prettier does not wrap Markdown. markdownlint does, and [`.markdownlint.json`](.markdownlint.json) turns off the line-length rule.
111
+
112
+ ## Releasing
113
+
114
+ ```sh
115
+ gem install bump
116
+ bump patch # or minor, or major
117
+ rm -f html-proofer-mailto_awesome-*.gem
78
118
  gem build html-proofer-mailto_awesome.gemspec
79
119
  gem push html-proofer-mailto_awesome-*.gem
80
- ```
120
+ ```
121
+
122
+ Rubygems requires MFA for this gem (`rubygems_mfa_required`).
123
+
124
+ ## Maintenance
125
+
126
+ Do this every month or so:
127
+
128
+ 1. Read [Ruby maintenance branches](https://www.ruby-lang.org/en/downloads/branches/). Update `required_ruby_version` and the Ruby matrix in [`.github/workflows/ruby.yml`](.github/workflows/ruby.yml) when a branch leaves security maintenance, or when a new branch enters normal maintenance.
129
+ 1. Review external actions in [`.github/workflows`](.github/workflows). GitHub-supported actions, the ones under the `actions/` organization, need a short review. `ruby/setup-ruby` is not one of those. Read its changelog before moving the tag.
130
+ 1. Review `html-proofer` against the [5.x releases](https://github.com/gjtorikian/html-proofer/releases). This gem depends on `~> 5.0`, `>= 5.0.4`. It also depends on `logger`, because [Ruby 4.0 removed that library from the default gems](https://stdgems.org/libraries/logger/) and html-proofer still loads it.
131
+ 1. Keep `ffi` at 1.17.4 or newer, and `nokogiri` at 1.19.0 or newer, in `Gemfile.lock`. The x86_64-linux builds of ffi 1.17.2 and nokogiri 1.18.10 set `required_ruby_version` to `< 3.5.dev`, so `bundle install` fails on Ruby 4.0. ffi 1.17.4 and nokogiri 1.19.4 allow Ruby before 4.1. ethon pulls in ffi. html-proofer pulls in nokogiri.
132
+
133
+ ## References
134
+
135
+ 1. We use title case for titles and proper nouns; not for headings and things. This includes our README above as well as our workflow rules and other configuration files. If you have a different policy, then please implement it throughout.
136
+ 1. This project is released under the [MIT license](LICENSE).
137
+ 1. This project is built based on [best practices documented in node.js-template](https://github.com/fulldecent/node.js-template). We took its lint workflow (Prettier and markdownlint, both invoked as `npx @latest`), [`.editorconfig`](.editorconfig), [`.markdownlint.json`](.markdownlint.json), [`.prettierignore`](.prettierignore), and this references section. We did not take its Yarn install or its `.node-version` pin. This is a Ruby gem. The lint job uses Node only as the tool runtime for those two checkers.
138
+ 1. The check follows [`nice-checkers/mailto-awesome`](https://github.com/fulldecent/html-validate-nice-checkers#nice-checkersmailto-awesome) in [@fulldecent/nice-checkers-plugin](https://github.com/fulldecent/html-validate-nice-checkers): default required fields are `subject` and `body`, and the caller can replace that list. Delta: this gem compares header field names case-insensitively because [RFC 6068 section 2](https://www.rfc-editor.org/rfc/rfc6068#section-2) says `<hfname>` is case-insensitive. The HTML-validate rule uses `URLSearchParams`, which compares names case-sensitively.
139
+ 1. html-proofer custom checks are loaded by class name and selected with the `checks` option. Passing `checks` replaces the default list. That behavior is documented in the [html-proofer README](https://github.com/gjtorikian/html-proofer#custom-tests).
140
+ 1. Ruby versions in the gemspec and in continuous integration are the branches still in normal or security maintenance, from [Ruby maintenance branches](https://www.ruby-lang.org/en/downloads/branches/). Ruby 4.0 does not ship `logger` as a default gem. This gem depends on the [`logger` gem](https://stdgems.org/libraries/logger/) so html-proofer can load on that Ruby.
data/bin/console CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require "bundler/setup"
4
- require "html/proofer/mailto_awesome"
4
+ require "html-proofer-mailto_awesome"
5
5
 
6
6
  # You can add fixtures and/or initialization code here to make experimenting
7
7
  # with your gem easier. You can also use a different console, if you like.
@@ -21,10 +21,22 @@ Gem::Specification.new do |spec|
21
21
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
22
  spec.require_paths = ["lib"]
23
23
 
24
- spec.add_development_dependency "bundler", "~> 2.0.2"
25
- spec.add_development_dependency "rake", "~> 13.0.6"
26
- spec.add_runtime_dependency 'html-proofer', '~> 5.0', '>= 5.0.4'
27
- spec.add_development_dependency 'rspec', '~> 3.12', '>= 3.12.0'
28
- spec.add_development_dependency 'vcr', '~> 6.1', '>= 6.1.0'
29
- spec.add_development_dependency 'timecop', '~> 0.9', '>= 0.9.6'
24
+ # Ruby branches that are still in normal or security maintenance:
25
+ # https://www.ruby-lang.org/en/downloads/branches/
26
+ spec.required_ruby_version = ">= 3.3.0"
27
+
28
+ spec.metadata = {
29
+ "bug_tracker_uri" => "https://github.com/fulldecent/html-proofer-mailto_awesome/issues",
30
+ "source_code_uri" => "https://github.com/fulldecent/html-proofer-mailto_awesome",
31
+ "homepage_uri" => "https://github.com/fulldecent/html-proofer-mailto_awesome",
32
+ "rubygems_mfa_required" => "true"
33
+ }
34
+
35
+ spec.add_dependency "html-proofer", "~> 5.0", ">= 5.0.4"
36
+ # Ruby 4.0 removed logger from the default gems. html-proofer still loads it.
37
+ # https://stdgems.org/libraries/logger/
38
+ spec.add_dependency "logger"
39
+ spec.add_development_dependency "bundler", ">= 2.0"
40
+ spec.add_development_dependency "rake", ">= 13.0"
41
+ spec.add_development_dependency "rspec", "~> 3.12"
30
42
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module MailtoAwesome
2
- VERSION = "1.0.6"
3
- end
4
+ VERSION = "2.1.0"
5
+ end
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "mailto_awesome"
@@ -1,32 +1,60 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "html/proofer/mailto_awesome/version"
4
+ # Ruby 4.0 removed logger from the default gems. html-proofer still loads it.
5
+ # https://stdgems.org/libraries/logger/
6
+ require "logger"
7
+ require "html-proofer"
8
+ require "uri"
2
9
 
3
- module Html
4
- module Proofer
5
- module MailtoAwesome
6
- class Error < StandardError; end
7
- class MailToAwesome < ::HTMLProofer::Check
8
- def mailto?
9
- return false if @link.ignore? || @link.href.nil?
10
- @link.href.match /^mailto:/i
11
- end
12
-
13
- def awesome?
14
- @link.href.downcase.include? 'subject=' and @link.href.downcase.include? 'body='
15
- end
16
-
17
- def run
18
- return unless @options[:check_mailto_awesome]
19
- @html.css('a').each do |node|
20
- @link = create_element(node)
21
- line = node.line
22
- content = node.to_s
23
-
24
- if mailto? && !awesome?
25
- add_issue("This is a not-awesome mailto link!", line: line, content: content)
26
- end
10
+ module HTMLProofer
11
+ class Check
12
+ # Reports mailto links that omit the header fields a recipient asked for.
13
+ # Header field names follow RFC 6068: hfname is case-insensitive.
14
+ # https://www.rfc-editor.org/rfc/rfc6068#section-2
15
+ class MailtoAwesome < HTMLProofer::Check
16
+ DEFAULT_REQUIRED_PARAMETERS = ["subject", "body"].freeze
17
+
18
+ def run
19
+ @html.css("a").each do |node|
20
+ @link = create_element(node)
21
+ next if @link.ignore?
22
+
23
+ href = node["href"]
24
+ next unless href.is_a?(String) && href.match?(/\Amailto:/i)
25
+
26
+ begin
27
+ names = header_names(href)
28
+ rescue URI::InvalidURIError
29
+ add_failure("mailto: link is malformed and could not be parsed.", element: @link)
30
+ next
27
31
  end
32
+
33
+ missing = required_parameters.reject { |name| names.include?(name) }
34
+ next if missing.empty?
35
+
36
+ add_failure("mailto: link is missing required parameters: #{missing.join(", ")}", element: @link)
28
37
  end
29
- end
38
+ end
39
+
40
+ private
41
+
42
+ def required_parameters
43
+ configured = @runner.options[:mailto_awesome]
44
+ names = configured[:required_parameters] || configured["required_parameters"] if configured.is_a?(Hash)
45
+ names = DEFAULT_REQUIRED_PARAMETERS if names.nil?
46
+ Array(names).map { |name| name.to_s.downcase }
47
+ end
48
+
49
+ def header_names(href)
50
+ # Nokogiri has already decoded &amp;. A caller that passes the source
51
+ # text still has the entity, which RFC 6068 requires in HTML.
52
+ semantic = href.gsub("&amp;", "&").gsub("&lt;", "<").gsub("&gt;", ">")
53
+ uri = URI.parse(semantic)
54
+ raise URI::InvalidURIError, semantic unless uri.is_a?(URI::MailTo)
55
+
56
+ Array(uri.headers).map { |name, _value| name.to_s.downcase }
57
+ end
30
58
  end
31
59
  end
32
60
  end
metadata CHANGED
@@ -1,132 +1,103 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: html-proofer-mailto_awesome
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.6
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - William Entriken
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2023-02-16 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
- name: bundler
13
+ name: html-proofer
15
14
  requirement: !ruby/object:Gem::Requirement
16
15
  requirements:
17
16
  - - "~>"
18
17
  - !ruby/object:Gem::Version
19
- version: 2.0.2
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: 2.0.2
27
- - !ruby/object:Gem::Dependency
28
- name: rake
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
18
+ version: '5.0'
19
+ - - ">="
32
20
  - !ruby/object:Gem::Version
33
- version: 13.0.6
34
- type: :development
21
+ version: 5.0.4
22
+ type: :runtime
35
23
  prerelease: false
36
24
  version_requirements: !ruby/object:Gem::Requirement
37
25
  requirements:
38
26
  - - "~>"
39
27
  - !ruby/object:Gem::Version
40
- version: 13.0.6
28
+ version: '5.0'
29
+ - - ">="
30
+ - !ruby/object:Gem::Version
31
+ version: 5.0.4
41
32
  - !ruby/object:Gem::Dependency
42
- name: html-proofer
33
+ name: logger
43
34
  requirement: !ruby/object:Gem::Requirement
44
35
  requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: '5.0'
48
36
  - - ">="
49
37
  - !ruby/object:Gem::Version
50
- version: 5.0.4
38
+ version: '0'
51
39
  type: :runtime
52
40
  prerelease: false
53
41
  version_requirements: !ruby/object:Gem::Requirement
54
42
  requirements:
55
- - - "~>"
56
- - !ruby/object:Gem::Version
57
- version: '5.0'
58
43
  - - ">="
59
44
  - !ruby/object:Gem::Version
60
- version: 5.0.4
45
+ version: '0'
61
46
  - !ruby/object:Gem::Dependency
62
- name: rspec
47
+ name: bundler
63
48
  requirement: !ruby/object:Gem::Requirement
64
49
  requirements:
65
- - - "~>"
66
- - !ruby/object:Gem::Version
67
- version: '3.12'
68
50
  - - ">="
69
51
  - !ruby/object:Gem::Version
70
- version: 3.12.0
52
+ version: '2.0'
71
53
  type: :development
72
54
  prerelease: false
73
55
  version_requirements: !ruby/object:Gem::Requirement
74
56
  requirements:
75
- - - "~>"
76
- - !ruby/object:Gem::Version
77
- version: '3.12'
78
57
  - - ">="
79
58
  - !ruby/object:Gem::Version
80
- version: 3.12.0
59
+ version: '2.0'
81
60
  - !ruby/object:Gem::Dependency
82
- name: vcr
61
+ name: rake
83
62
  requirement: !ruby/object:Gem::Requirement
84
63
  requirements:
85
- - - "~>"
86
- - !ruby/object:Gem::Version
87
- version: '6.1'
88
64
  - - ">="
89
65
  - !ruby/object:Gem::Version
90
- version: 6.1.0
66
+ version: '13.0'
91
67
  type: :development
92
68
  prerelease: false
93
69
  version_requirements: !ruby/object:Gem::Requirement
94
70
  requirements:
95
- - - "~>"
96
- - !ruby/object:Gem::Version
97
- version: '6.1'
98
71
  - - ">="
99
72
  - !ruby/object:Gem::Version
100
- version: 6.1.0
73
+ version: '13.0'
101
74
  - !ruby/object:Gem::Dependency
102
- name: timecop
75
+ name: rspec
103
76
  requirement: !ruby/object:Gem::Requirement
104
77
  requirements:
105
78
  - - "~>"
106
79
  - !ruby/object:Gem::Version
107
- version: '0.9'
108
- - - ">="
109
- - !ruby/object:Gem::Version
110
- version: 0.9.6
80
+ version: '3.12'
111
81
  type: :development
112
82
  prerelease: false
113
83
  version_requirements: !ruby/object:Gem::Requirement
114
84
  requirements:
115
85
  - - "~>"
116
86
  - !ruby/object:Gem::Version
117
- version: '0.9'
118
- - - ">="
119
- - !ruby/object:Gem::Version
120
- version: 0.9.6
87
+ version: '3.12'
121
88
  description: A custom html-proofer test that makes your mailto links awesome
122
89
  email: github.com@phor.net
123
90
  executables: []
124
91
  extensions: []
125
92
  extra_rdoc_files: []
126
93
  files:
94
+ - ".editorconfig"
127
95
  - ".github/FUNDING.yml"
96
+ - ".github/workflows/lint.yml"
128
97
  - ".github/workflows/ruby.yml"
129
98
  - ".gitignore"
99
+ - ".markdownlint.json"
100
+ - ".prettierignore"
130
101
  - ".rspec"
131
102
  - Gemfile
132
103
  - Gemfile.lock
@@ -136,13 +107,17 @@ files:
136
107
  - bin/console
137
108
  - bin/setup
138
109
  - html-proofer-mailto_awesome.gemspec
110
+ - lib/html-proofer-mailto_awesome.rb
139
111
  - lib/html/proofer/mailto_awesome/version.rb
140
112
  - lib/mailto_awesome.rb
141
113
  homepage: https://github.com/fulldecent/html-proofer-mailto_awesome
142
114
  licenses:
143
115
  - MIT
144
- metadata: {}
145
- post_install_message:
116
+ metadata:
117
+ bug_tracker_uri: https://github.com/fulldecent/html-proofer-mailto_awesome/issues
118
+ source_code_uri: https://github.com/fulldecent/html-proofer-mailto_awesome
119
+ homepage_uri: https://github.com/fulldecent/html-proofer-mailto_awesome
120
+ rubygems_mfa_required: 'true'
146
121
  rdoc_options: []
147
122
  require_paths:
148
123
  - lib
@@ -150,15 +125,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
150
125
  requirements:
151
126
  - - ">="
152
127
  - !ruby/object:Gem::Version
153
- version: '0'
128
+ version: 3.3.0
154
129
  required_rubygems_version: !ruby/object:Gem::Requirement
155
130
  requirements:
156
131
  - - ">="
157
132
  - !ruby/object:Gem::Version
158
133
  version: '0'
159
134
  requirements: []
160
- rubygems_version: 3.3.7
161
- signing_key:
135
+ rubygems_version: 4.0.20
162
136
  specification_version: 4
163
137
  summary: Checker for mailto links
164
138
  test_files: []