jekyll_href 1.0.13 → 1.0.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/README.md +24 -4
- data/lib/jekyll_href/version.rb +1 -1
- data/lib/jekyll_href.rb +7 -5
- data/spec/href_spec.rb +65 -1
- data/spec/status_persistence.txt +15 -11
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e77bc04770e6fae8eeb1a595be3e3faf81fe6c77c023a9a711a3a97d51b3a828
|
4
|
+
data.tar.gz: c9ff34ea2c4611fefb8f36e99471ad55a490b60d68c255fbcc06ce3791acc90e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9727eed971f210d18ab6826a297b5563bf899ab1c14bbd9a988fa31405d1521357ca6fa48894ab3dfacfda11371f025c83908ed5ef1519ce7fb04ba9f25605d9
|
7
|
+
data.tar.gz: e82fbe117198467601a940fbc24fd9a2a40ec802b263e43324cfaaca7467f8b704f16ad1dc6214a02154ba88f04006de7f9830c08a2857c49a8614515f016f4e
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -10,7 +10,8 @@ If the url starts with `http`, or the `match` keyword is specified:
|
|
10
10
|
- The url will open in a new tab or window.
|
11
11
|
- The url will include `rel=nofollow` for SEO purposes.
|
12
12
|
|
13
|
-
CAUTION: if linked text contains a single or double quote you will see the error message: `Liquid Exception: Unmatched quote`.
|
13
|
+
CAUTION: if linked text contains a single or double quote you will see the error message: `Liquid Exception: Unmatched quote`.
|
14
|
+
Instead, use ' (`'`), " (`"`), ‘ (`‘`), ’ (`’`), “ (`“`), and ” (`”`)
|
14
15
|
|
15
16
|
In `_config.yml`, if a section called `plugin-vars` exists,
|
16
17
|
then its name/value pairs are available for substitution.
|
@@ -23,7 +24,7 @@ then its name/value pairs are available for substitution.
|
|
23
24
|
|
24
25
|
## Syntax 1 (requires `url` does not have embedded spaces):
|
25
26
|
```
|
26
|
-
{% href [match | [follow] [notarget]] url text to display %}
|
27
|
+
{% href [match | [follow] [blank|notarget]] url text to display %}
|
27
28
|
```
|
28
29
|
1. The url must be a single token, without embedded spaces.
|
29
30
|
2. The url need not be enclosed in quotes.
|
@@ -33,10 +34,10 @@ then its name/value pairs are available for substitution.
|
|
33
34
|
## Syntax 2 (always works):
|
34
35
|
This syntax is recommended when the URL contains a colon (:).
|
35
36
|
```
|
36
|
-
{% href [match | [follow] [notarget]]
|
37
|
+
{% href [match | [follow] [blank|notarget]]
|
37
38
|
url="http://link.com with space.html" some text %}
|
38
39
|
|
39
|
-
{% href [match | [follow] [notarget]]
|
40
|
+
{% href [match | [follow] [blank|notarget]]
|
40
41
|
url='http://link.com with space.html' some text %}
|
41
42
|
```
|
42
43
|
1. Each of the above examples contain an embedded newline, which is legal.
|
@@ -44,6 +45,17 @@ This syntax is recommended when the URL contains a colon (:).
|
|
44
45
|
3. The square brackets denote optional keyword parameters, and should not be typed.
|
45
46
|
|
46
47
|
|
48
|
+
## Syntax 3 (implicit URL):
|
49
|
+
```
|
50
|
+
{% href [match | [follow] [blank|notarget]] www.domain.com %}
|
51
|
+
```
|
52
|
+
The URI provided, for example `www.domain.com`,
|
53
|
+
is used to form the URL by prepending `https://`,
|
54
|
+
in this case the result would be `https://www.domain.com`.
|
55
|
+
The displayed URI is enclosed in `<code></code>`,
|
56
|
+
so the resulting text is `<code>www.domain.com</code>`.
|
57
|
+
|
58
|
+
|
47
59
|
## Environment Variable Expansion
|
48
60
|
URLs can contain environment variable references.
|
49
61
|
For example, if `$domain`, `$uri` and `$USER` are environment variables:
|
@@ -56,12 +68,20 @@ For example, if `$domain`, `$uri` and `$USER` are environment variables:
|
|
56
68
|
```
|
57
69
|
|
58
70
|
## Optional Parameters
|
71
|
+
### `blank`
|
72
|
+
The `target='_blank'` attribute is not normally generated for relative links.
|
73
|
+
To enforce the generation of this attribute, preface the link with the word `blank`.
|
74
|
+
The `blank` and `notarget` parameters are mutually exclusive.
|
75
|
+
If both are specified, `blank` prevails.
|
76
|
+
|
59
77
|
### `follow`
|
60
78
|
To suppress the `nofollow` attribute, preface the link with the word `follow`.
|
61
79
|
|
62
80
|
|
63
81
|
### `notarget`
|
64
82
|
To suppress the `target` attribute, preface the link with the word `notarget`.
|
83
|
+
The `blank` and `notarget` parameters are mutually exclusive.
|
84
|
+
If both are specified, `blank` prevails.
|
65
85
|
|
66
86
|
|
67
87
|
### `match`
|
data/lib/jekyll_href/version.rb
CHANGED
data/lib/jekyll_href.rb
CHANGED
@@ -77,7 +77,7 @@ class ExternalHref < Liquid::Tag # rubocop:disable Metrics/ClassLength
|
|
77
77
|
abort msg.red
|
78
78
|
end
|
79
79
|
|
80
|
-
def globals_initial(liquid_context)
|
80
|
+
def globals_initial(liquid_context) # rubocop:disable Metrics/MethodLength
|
81
81
|
# Sets @follow, @helper, @match, @page, @path, @site, @target, @url
|
82
82
|
@helper.liquid_context = liquid_context
|
83
83
|
|
@@ -88,11 +88,13 @@ class ExternalHref < Liquid::Tag # rubocop:disable Metrics/ClassLength
|
|
88
88
|
|
89
89
|
@follow = @helper.parameter_specified?('follow') ? '' : " rel='nofollow'"
|
90
90
|
@match = @helper.parameter_specified?('match')
|
91
|
-
@
|
91
|
+
@blank = @helper.parameter_specified?('blank')
|
92
|
+
@target = @blank ? " target='_blank'" : nil
|
93
|
+
@target ||= @helper.parameter_specified?('notarget') ? '' : " target='_blank'"
|
92
94
|
@url = @helper.parameter_specified?('url')
|
93
95
|
end
|
94
96
|
|
95
|
-
def globals_update(tokens, linkk) # rubocop:disable Metrics/MethodLength
|
97
|
+
def globals_update(tokens, linkk) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
96
98
|
# Might set @follow, @linkk, @target, and @text
|
97
99
|
if linkk.start_with? 'mailto:'
|
98
100
|
@link = linkk
|
@@ -116,13 +118,13 @@ class ExternalHref < Liquid::Tag # rubocop:disable Metrics/ClassLength
|
|
116
118
|
return if @link.start_with? "http"
|
117
119
|
|
118
120
|
@follow = ''
|
119
|
-
@target = ''
|
121
|
+
@target = '' unless @blank
|
120
122
|
end
|
121
123
|
|
122
124
|
def handle_match
|
123
125
|
match_post
|
124
126
|
@follow = ''
|
125
|
-
@target = ''
|
127
|
+
@target = '' unless @blank
|
126
128
|
end
|
127
129
|
|
128
130
|
def match_post # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength
|
data/spec/href_spec.rb
CHANGED
@@ -61,6 +61,22 @@ class MyTest # rubocop:disable Metrics/ClassLength
|
|
61
61
|
)
|
62
62
|
end
|
63
63
|
|
64
|
+
it "Obtains internal link with blank" do
|
65
|
+
href = ExternalHref.send(
|
66
|
+
:new,
|
67
|
+
'href',
|
68
|
+
'blank ./path/page.html internal link text'.dup,
|
69
|
+
parse_context
|
70
|
+
)
|
71
|
+
href.send(:globals_initial, parse_context)
|
72
|
+
linkk = href.send(:compute_linkk)
|
73
|
+
href.send(:globals_update, href.helper.argv, linkk)
|
74
|
+
expect(href.follow).to eq('')
|
75
|
+
expect(href.link).to eq('./path/page.html')
|
76
|
+
expect(href.target).to eq(" target='_blank'")
|
77
|
+
expect(href.text).to eq('internal link text')
|
78
|
+
end
|
79
|
+
|
64
80
|
it "Obtains external link with text" do
|
65
81
|
href = ExternalHref.send(
|
66
82
|
:new,
|
@@ -158,7 +174,39 @@ class MyTest # rubocop:disable Metrics/ClassLength
|
|
158
174
|
expect(href.text).to eq('Awesome')
|
159
175
|
end
|
160
176
|
|
161
|
-
it "Obtains external link with
|
177
|
+
it "Obtains external link with blank" do
|
178
|
+
href = ExternalHref.send(
|
179
|
+
:new,
|
180
|
+
'href',
|
181
|
+
'blank https://www.mslinn.com Awesome'.dup,
|
182
|
+
parse_context
|
183
|
+
)
|
184
|
+
href.send(:globals_initial, parse_context)
|
185
|
+
linkk = href.send(:compute_linkk)
|
186
|
+
href.send(:globals_update, href.helper.argv, linkk)
|
187
|
+
expect(href.follow).to eq(" rel='nofollow'")
|
188
|
+
expect(href.link).to eq('https://www.mslinn.com')
|
189
|
+
expect(href.target).to eq(" target='_blank'")
|
190
|
+
expect(href.text).to eq('Awesome')
|
191
|
+
end
|
192
|
+
|
193
|
+
it "Implicitly computes external link from text" do
|
194
|
+
href = ExternalHref.send(
|
195
|
+
:new,
|
196
|
+
'href',
|
197
|
+
'www.mslinn.com'.dup,
|
198
|
+
parse_context
|
199
|
+
)
|
200
|
+
href.send(:globals_initial, parse_context)
|
201
|
+
linkk = href.send(:compute_linkk)
|
202
|
+
href.send(:globals_update, href.helper.argv, linkk)
|
203
|
+
expect(href.follow).to eq(" rel='nofollow'")
|
204
|
+
expect(href.link).to eq('https://www.mslinn.com')
|
205
|
+
expect(href.target).to eq(" target='_blank'")
|
206
|
+
expect(href.text).to eq('<code>www.mslinn.com</code>')
|
207
|
+
end
|
208
|
+
|
209
|
+
it "Implicitly computes external link from text with follow and notarget" do
|
162
210
|
href = ExternalHref.send(
|
163
211
|
:new,
|
164
212
|
'href',
|
@@ -174,6 +222,22 @@ class MyTest # rubocop:disable Metrics/ClassLength
|
|
174
222
|
expect(href.text).to eq('<code>www.mslinn.com</code>')
|
175
223
|
end
|
176
224
|
|
225
|
+
it "Implicitly computes external link from text with blank" do
|
226
|
+
href = ExternalHref.send(
|
227
|
+
:new,
|
228
|
+
'href',
|
229
|
+
'follow blank www.mslinn.com'.dup,
|
230
|
+
parse_context
|
231
|
+
)
|
232
|
+
href.send(:globals_initial, parse_context)
|
233
|
+
linkk = href.send(:compute_linkk)
|
234
|
+
href.send(:globals_update, href.helper.argv, linkk)
|
235
|
+
expect(href.follow).to eq('')
|
236
|
+
expect(href.link).to eq('https://www.mslinn.com')
|
237
|
+
expect(href.target).to eq(" target='_blank'")
|
238
|
+
expect(href.text).to eq('<code>www.mslinn.com</code>')
|
239
|
+
end
|
240
|
+
|
177
241
|
it "Obtains mailto without text" do
|
178
242
|
href = ExternalHref.send(
|
179
243
|
:new,
|
data/spec/status_persistence.txt
CHANGED
@@ -1,11 +1,15 @@
|
|
1
|
-
example_id
|
2
|
-
|
3
|
-
/mnt/f/work/jekyll/my_plugins/jekyll_href/spec/href_spec.rb[1:1]
|
4
|
-
/mnt/f/work/jekyll/my_plugins/jekyll_href/spec/href_spec.rb[1:2]
|
5
|
-
/mnt/f/work/jekyll/my_plugins/jekyll_href/spec/href_spec.rb[1:3]
|
6
|
-
/mnt/f/work/jekyll/my_plugins/jekyll_href/spec/href_spec.rb[1:4]
|
7
|
-
/mnt/f/work/jekyll/my_plugins/jekyll_href/spec/href_spec.rb[1:5]
|
8
|
-
/mnt/f/work/jekyll/my_plugins/jekyll_href/spec/href_spec.rb[1:6]
|
9
|
-
/mnt/f/work/jekyll/my_plugins/jekyll_href/spec/href_spec.rb[1:7]
|
10
|
-
/mnt/f/work/jekyll/my_plugins/jekyll_href/spec/href_spec.rb[1:8]
|
11
|
-
/mnt/f/work/jekyll/my_plugins/jekyll_href/spec/href_spec.rb[1:9]
|
1
|
+
example_id | status | run_time |
|
2
|
+
----------------------------------------------------------------- | ------ | --------------- |
|
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.0.
|
4
|
+
version: 1.0.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Slinn
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-01-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|