jekyll_href 1.2.4 → 1.2.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 13925ae2b44abe077101e5302d6aee8a640cdf3c50dcb4a29c76e2c355dae039
4
- data.tar.gz: cf41c3a1c8424fc3e3ba67ccf6f27238e71766c72ed7006442291d855a933c4f
3
+ metadata.gz: 7ce2ffe035bd807e82e6ec9f639677e82f4413bed796bc513962f384cea6b5e8
4
+ data.tar.gz: 90ae63c7030fe498a6e4eadb61a20927a110847fb70809058e7da41f8b4d2d72
5
5
  SHA512:
6
- metadata.gz: afa3c62bf2806362a3e52d6978a8ea9ad3b5eb21e5f685b5328c04c0e19728e680a58961bd0daac805fcfbef1f031e98c6de769b085c9c8e4f058a209793c325
7
- data.tar.gz: ce210b8cecefb1282991e9f4cca6ca5f80e7d94b9738f875f4848e9c445e24744e57c5a93f099e83362ed6e10448a38499f1907b96a04ef402db63710589f2aa
6
+ metadata.gz: 6fd44f9bcb7aa12f2503333663be4fd7619c83e37563387997dd9043996127545a980a627b33677b8f1ee428af579dd3ff9ea84d0cf39f8095bc81199e8ea165
7
+ data.tar.gz: 1e5808fde63549696c8464c5d6e5127b32aa36a3f3919fbaf4a37d04cdf373f7b9861cfd459f2b61bc6d327e995c1303ae8642157ecce1f2f02e4537a5932d35
data/CHANGELOG.md CHANGED
@@ -1,6 +1,12 @@
1
+ ## 1.2.6 / 2023-06-18
2
+ * No longer blows up on error.
3
+
4
+ ## 1.2.5 / 2023-05-26
5
+ * Added `style` and `class` options.
6
+
1
7
  ## 1.2.4 / 2023-05-18
2
- * When only a URI is provided, the plugin now generates the `http` scheme for IP4 & IP6 loopback addresses like
3
- `localhost`, and `127.0.0.0`, as well as private IP4 addresses like 192.168.0.0 and 172.16.0.0;
8
+ * When only a URI is provided, the plugin now generates the `http` scheme for IP4 & IP6 loopback addresses like
9
+ `localhost`, and `127.0.0.0`, as well as private IP4 addresses like 192.168.0.0 and 172.16.0.0;
4
10
  otherwise it generates the `https` scheme.
5
11
 
6
12
  ## 1.2.3 / 2023-05-16
data/README.md CHANGED
@@ -82,6 +82,20 @@ To enforce the generation of this attribute, preface the link with the word `bla
82
82
  The `blank` and `notarget` parameters are mutually exclusive.
83
83
  If both are specified, `blank` prevails.
84
84
 
85
+ ### `class`
86
+ This option allows CSS classes to be added to the HTML generated by the `href` tag.
87
+ It has no effect on the `href_summary` tag output.
88
+
89
+ For example:
90
+
91
+ ```
92
+ {% href class='bg_yellow' https://mslinn.com click here %}
93
+ ```
94
+ Expands to:
95
+ ```
96
+ <a href="https://mslinn.com" class="bg_yellow" rel="nofollow" target="_blank">click here</a>
97
+ ```
98
+
85
99
  ### `follow`
86
100
  To suppress the `nofollow` attribute, preface the link with the word `follow`.
87
101
 
@@ -109,8 +123,8 @@ The `match` option looks through the pages collection for a URL with containing
109
123
 
110
124
 
111
125
  ### `shy`
112
- `shy` is only applicable for syntax 3 (implicit URL).
113
- This option causes displayed urls to have an &amp;shy; inserted after each slash (/).
126
+ The `shy` keyword option is only applicable for syntax 3 (implicit URL).
127
+ This option causes displayed urls to have an [`&amp;shy;`](https://developer.mozilla.org/en-US/docs/Web/CSS/hyphens) inserted after each slash (/).
114
128
  If both `shy` and `wbr` are specified, `wbr` prevails.
115
129
 
116
130
  For example:
@@ -119,21 +133,21 @@ For example:
119
133
  ```
120
134
  Expands to:
121
135
  ```
122
- <a href="https://mslinn.com/path/to/page.html">mslinn.com/&shy;path/&shy;to/&shy;page.html</a>
136
+ <a href="https://mslinn.com/path/to/page.html" rel="nofollow" target="_blank">mslinn.com/&shy;path/&shy;to/&shy;page.html</a>
123
137
  ```
124
138
 
125
- ### `shy`
126
- The `shy` keyword option is only applicable for syntax 3 (implicit URL).
127
- This option causes displayed urls to have an [`&amp;shy;`](https://developer.mozilla.org/en-US/docs/Web/CSS/hyphens) inserted after each slash (/).
128
- If both `shy` and `wbr` are specified, `wbr` prevails.
139
+ ### `style`
140
+ This option allows CSS styling to be added to the HTML generated by the `href` tag.
141
+ It has no effect on the `href_summary` tag output.
129
142
 
130
143
  For example:
144
+
131
145
  ```
132
- {% href shy mslinn.com/path/to/page.html %}
146
+ {% href style='color: red; font-weight: bold;' https://mslinn.com click here %}
133
147
  ```
134
148
  Expands to:
135
149
  ```
136
- <a href="https://mslinn.com/path/to/page.html" rel="nofollow" target="_blank">mslinn.com/&shy;path/&shy;to/&shy;page.html</a>
150
+ <a href="https://mslinn.com" rel="nofollow" style="color: ref; font-weight: bold" target="_blank">click here</a>
137
151
  ```
138
152
 
139
153
  ### `summary`
data/jekyll_href.gemspec CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
  END_OF_DESC
11
11
  spec.email = ['mslinn@mslinn.com']
12
12
  spec.files = Dir['.rubocop.yml', 'LICENSE.*', 'Rakefile', '{lib,spec}/**/*', '*.gemspec', '*.md']
13
- spec.homepage = 'https://www.mslinn.com/jekyll/3000-jekyll-plugins.html#href'
13
+ spec.homepage = 'https://www.mslinn.com/jekyll_plugins/jekyll_href.html'
14
14
  spec.license = 'MIT'
15
15
  spec.metadata = {
16
16
  'allowed_push_host' => 'https://rubygems.org',
@@ -32,6 +32,7 @@ Gem::Specification.new do |spec|
32
32
 
33
33
  spec.add_dependency 'ipaddress'
34
34
  spec.add_dependency 'jekyll', '>= 3.5.0'
35
- spec.add_dependency 'jekyll_all_collections', '~> 0.3.0', '>= 0.3.1'
36
- spec.add_dependency 'jekyll_plugin_support', '~> 0.6.0', '>= 0.6.1'
35
+ spec.add_dependency 'jekyll_all_collections', '>= 0.3.3'
36
+ spec.add_dependency 'jekyll_plugin_support', '>= 0.7.0'
37
+ spec.add_dependency 'sanitize'
37
38
  end
data/lib/href_tag.rb CHANGED
@@ -3,6 +3,7 @@ require 'jekyll_all_collections'
3
3
  require 'jekyll_plugin_logger'
4
4
  require 'jekyll_plugin_support'
5
5
  require 'liquid'
6
+ require 'sanitize'
6
7
  require_relative 'jekyll_href/version'
7
8
  require_relative 'hash_array'
8
9
 
@@ -38,7 +39,9 @@ module HrefTag
38
39
  # @return [String]
39
40
  def render_impl
40
41
  globals_initial
41
- linkk = compute_linkk
42
+ linkk, error_msg = compute_linkk
43
+ return error_msg unless linkk
44
+
42
45
  linkk = replace_vars(linkk)
43
46
  linkk.delete_prefix('./') # normalize relative links
44
47
  @url = linkk if @url
@@ -47,7 +50,9 @@ module HrefTag
47
50
  globals_update(@helper.argv, linkk) # Sets @link and @text, might clear @follow and @target
48
51
  handle_match if @match
49
52
  save_summary
50
- "<a href='#{@link}'#{@target}#{@follow}>#{@text}</a>"
53
+ klass = " class='#{@klass}'" if @klass
54
+ style = " style='#{@style}'" if @style
55
+ "<a href='#{@link}'#{klass}#{style}#{@target}#{@follow}>#{@text}</a>"
51
56
  end
52
57
 
53
58
  private
@@ -88,32 +93,27 @@ module HrefTag
88
93
 
89
94
  # Does not look at or compute @link
90
95
  def compute_linkk
91
- return @link if @link
96
+ return @link, nil if @link
92
97
 
93
98
  linkk = @url
94
99
  if linkk.nil? || !linkk
95
100
  linkk = @helper.argv&.shift
96
101
  @helper.params&.shift
97
102
  @helper.keys_values&.delete(linkk)
98
- dump_linkk_relations(linkk) if linkk.nil?
103
+ return nil, error_no_uri if linkk.nil?
99
104
  elsif @url.to_s.empty?
100
- dump_linkk_relations(linkk)
105
+ return nil, error_no_uri
101
106
  end
102
- linkk
107
+ [linkk, nil]
103
108
  end
104
109
 
105
- def dump_linkk_relations(linkk)
110
+ def error_no_uri
106
111
  msg = <<~END_MESSAGE
107
- jekyll_href error: no url was provided on #{@path}:#{@line_number}.
108
- @helper.markup=#{@helper.markup}
109
- @helper.argv='#{@helper.argv}'
110
- linkk='#{linkk}'
111
- @match='#{@match}'
112
- @url='#{@url}'
113
- @follow='#{@follow}
114
- @target='#{@target}'
112
+ Error: no url was provided on #{@path}:#{@line_number} (after front matter).
113
+ <pre>{% href #{@argument_string}%}</pre>
115
114
  END_MESSAGE
116
- abort msg.red
115
+ @logger.error { Sanitize.fragment msg }
116
+ "<span class='error'>Error: #{msg}</span>"
117
117
  end
118
118
 
119
119
  # Sets @follow, @helper, @match, @path, @shy, @target, @url, @wbr
@@ -122,11 +122,13 @@ module HrefTag
122
122
  AllCollectionsHooks.compute(@site)
123
123
 
124
124
  @blank = @helper.parameter_specified? 'blank'
125
+ @klass = @helper.parameter_specified? 'class'
125
126
  @follow = @helper.parameter_specified?('follow') ? '' : " rel='nofollow'"
126
127
  @match = @helper.parameter_specified? 'match'
127
128
  @label = @helper.parameter_specified? 'label'
128
129
  @summary_exclude = @helper.parameter_specified? 'summary_exclude'
129
130
  @shy = @helper.parameter_specified? 'shy'
131
+ @style = @helper.parameter_specified? 'style'
130
132
  @summary = @helper.parameter_specified? 'summary'
131
133
  @target = @blank ? " target='_blank'" : nil
132
134
  @target ||= @helper.parameter_specified?('notarget') ? '' : " target='_blank'"
@@ -1,3 +1,3 @@
1
1
  module JekyllHrefVersion
2
- VERSION = '1.2.4'.freeze
2
+ VERSION = '1.2.6'.freeze
3
3
  end
@@ -1,29 +1,15 @@
1
1
  example_id | status | run_time |
2
2
  ----------------------------------------------------------------- | ------ | --------------- |
3
- ./spec/hash_array_spec.rb[1:1] | passed | 0.17104 seconds |
4
- ./spec/href_spec.rb[1:1] | passed | 0.03236 seconds |
5
- ./spec/href_spec.rb[1:2] | passed | 0.02884 seconds |
6
- ./spec/href_spec.rb[1:3] | passed | 0.02956 seconds |
7
- ./spec/href_spec.rb[1:4] | passed | 0.02841 seconds |
8
- ./spec/href_spec.rb[1:5] | passed | 0.02897 seconds |
9
- ./spec/href_spec.rb[1:6] | passed | 0.02866 seconds |
10
- ./spec/href_spec.rb[1:7] | passed | 0.02966 seconds |
11
- ./spec/href_spec.rb[1:8] | passed | 0.02983 seconds |
12
- ./spec/href_spec.rb[1:9] | passed | 0.02735 seconds |
13
- ./spec/href_spec.rb[1:10] | passed | 0.02928 seconds |
14
- ./spec/href_spec.rb[1:11] | passed | 0.02861 seconds |
15
- ./spec/href_spec.rb[1:12] | passed | 0.02958 seconds |
16
- ./spec/href_spec.rb[1:13] | passed | 0.02714 seconds |
17
- /mnt/_/work/jekyll/my_plugins/jekyll_href/spec/href_spec.rb[1:1] | passed | 0.02582 seconds |
18
- /mnt/_/work/jekyll/my_plugins/jekyll_href/spec/href_spec.rb[1:2] | passed | 0.01031 seconds |
19
- /mnt/_/work/jekyll/my_plugins/jekyll_href/spec/href_spec.rb[1:3] | passed | 0.01045 seconds |
20
- /mnt/_/work/jekyll/my_plugins/jekyll_href/spec/href_spec.rb[1:4] | passed | 0.01038 seconds |
21
- /mnt/_/work/jekyll/my_plugins/jekyll_href/spec/href_spec.rb[1:5] | passed | 0.01081 seconds |
22
- /mnt/_/work/jekyll/my_plugins/jekyll_href/spec/href_spec.rb[1:6] | passed | 0.01053 seconds |
23
- /mnt/_/work/jekyll/my_plugins/jekyll_href/spec/href_spec.rb[1:7] | passed | 0.01125 seconds |
24
- /mnt/_/work/jekyll/my_plugins/jekyll_href/spec/href_spec.rb[1:8] | passed | 0.01113 seconds |
25
- /mnt/_/work/jekyll/my_plugins/jekyll_href/spec/href_spec.rb[1:9] | passed | 0.01088 seconds |
26
- /mnt/_/work/jekyll/my_plugins/jekyll_href/spec/href_spec.rb[1:10] | passed | 0.01066 seconds |
27
- /mnt/_/work/jekyll/my_plugins/jekyll_href/spec/href_spec.rb[1:11] | failed | 0.06099 seconds |
28
- /mnt/_/work/jekyll/my_plugins/jekyll_href/spec/href_spec.rb[1:12] | passed | 0.01096 seconds |
29
- /mnt/_/work/jekyll/my_plugins/jekyll_href/spec/href_spec.rb[1:13] | passed | 0.01028 seconds |
3
+ /mnt/f/work/jekyll/my_plugins/jekyll_href/spec/href_spec.rb[1:1] | passed | 0.00817 seconds |
4
+ /mnt/f/work/jekyll/my_plugins/jekyll_href/spec/href_spec.rb[1:2] | passed | 0.00349 seconds |
5
+ /mnt/f/work/jekyll/my_plugins/jekyll_href/spec/href_spec.rb[1:3] | passed | 0.0033 seconds |
6
+ /mnt/f/work/jekyll/my_plugins/jekyll_href/spec/href_spec.rb[1:4] | passed | 0.00307 seconds |
7
+ /mnt/f/work/jekyll/my_plugins/jekyll_href/spec/href_spec.rb[1:5] | passed | 0.00315 seconds |
8
+ /mnt/f/work/jekyll/my_plugins/jekyll_href/spec/href_spec.rb[1:6] | passed | 0.0032 seconds |
9
+ /mnt/f/work/jekyll/my_plugins/jekyll_href/spec/href_spec.rb[1:7] | passed | 0.0035 seconds |
10
+ /mnt/f/work/jekyll/my_plugins/jekyll_href/spec/href_spec.rb[1:8] | passed | 0.00323 seconds |
11
+ /mnt/f/work/jekyll/my_plugins/jekyll_href/spec/href_spec.rb[1:9] | passed | 0.0032 seconds |
12
+ /mnt/f/work/jekyll/my_plugins/jekyll_href/spec/href_spec.rb[1:10] | passed | 0.00307 seconds |
13
+ /mnt/f/work/jekyll/my_plugins/jekyll_href/spec/href_spec.rb[1:11] | passed | 0.00317 seconds |
14
+ /mnt/f/work/jekyll/my_plugins/jekyll_href/spec/href_spec.rb[1:12] | passed | 0.00357 seconds |
15
+ /mnt/f/work/jekyll/my_plugins/jekyll_href/spec/href_spec.rb[1:13] | passed | 0.0035 seconds |
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll_href
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.4
4
+ version: 1.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Slinn
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-05-18 00:00:00.000000000 Z
11
+ date: 2023-06-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ipaddress
@@ -42,42 +42,44 @@ dependencies:
42
42
  name: jekyll_all_collections
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: 0.3.0
48
45
  - - ">="
49
46
  - !ruby/object:Gem::Version
50
- version: 0.3.1
47
+ version: 0.3.3
51
48
  type: :runtime
52
49
  prerelease: false
53
50
  version_requirements: !ruby/object:Gem::Requirement
54
51
  requirements:
55
- - - "~>"
56
- - !ruby/object:Gem::Version
57
- version: 0.3.0
58
52
  - - ">="
59
53
  - !ruby/object:Gem::Version
60
- version: 0.3.1
54
+ version: 0.3.3
61
55
  - !ruby/object:Gem::Dependency
62
56
  name: jekyll_plugin_support
63
57
  requirement: !ruby/object:Gem::Requirement
64
58
  requirements:
65
- - - "~>"
66
- - !ruby/object:Gem::Version
67
- version: 0.6.0
68
59
  - - ">="
69
60
  - !ruby/object:Gem::Version
70
- version: 0.6.1
61
+ version: 0.7.0
71
62
  type: :runtime
72
63
  prerelease: false
73
64
  version_requirements: !ruby/object:Gem::Requirement
74
65
  requirements:
75
- - - "~>"
66
+ - - ">="
76
67
  - !ruby/object:Gem::Version
77
- version: 0.6.0
68
+ version: 0.7.0
69
+ - !ruby/object:Gem::Dependency
70
+ name: sanitize
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
78
73
  - - ">="
79
74
  - !ruby/object:Gem::Version
80
- version: 0.6.1
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
81
83
  description: 'Generates an ''a href'' tag, possibly with target=''_blank'' and rel=''nofollow''.
82
84
 
83
85
  '
@@ -102,14 +104,14 @@ files:
102
104
  - spec/href_spec.rb
103
105
  - spec/spec_helper.rb
104
106
  - spec/status_persistence.txt
105
- homepage: https://www.mslinn.com/jekyll/3000-jekyll-plugins.html#href
107
+ homepage: https://www.mslinn.com/jekyll_plugins/jekyll_href.html
106
108
  licenses:
107
109
  - MIT
108
110
  metadata:
109
111
  allowed_push_host: https://rubygems.org
110
112
  bug_tracker_uri: https://github.com/mslinn/jekyll_href/issues
111
113
  changelog_uri: https://github.com/mslinn/jekyll_href/CHANGELOG.md
112
- homepage_uri: https://www.mslinn.com/jekyll/3000-jekyll-plugins.html#href
114
+ homepage_uri: https://www.mslinn.com/jekyll_plugins/jekyll_href.html
113
115
  source_code_uri: https://github.com/mslinn/jekyll_href
114
116
  post_install_message: |2+
115
117