jekyll_href 1.2.11 → 1.2.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +33 -5
- data/jekyll_href.gemspec +1 -1
- data/lib/href_match.rb +12 -9
- data/lib/href_private.rb +1 -1
- data/lib/href_summary_tag.rb +3 -6
- data/lib/href_tag.rb +4 -9
- data/lib/jekyll_href/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9b91d0d8398def7c990920615a1e12f97de4472f5444ae9fc3869504d49084b8
|
4
|
+
data.tar.gz: 19f84b38dc1f3205763a1be316671bad0ac65a3af25621e5455164f362c39ec8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 92e483de85abd7cfdf2aeede0de99d0cc0772d3d112b6652394f04f3f97f52d6aaa2b4f39ac150c02cbd25d0162b56809b8c8dec1a356d5a9777b86d888b21aa
|
7
|
+
data.tar.gz: fd835168ec7beb443ea70c646aac51cb80b4ab9a9826f881b74ee0af6670ad9ffe74937e3e063f762f44b32d7c060f4c69faeda6d8fe0935fd68525c8d3dbdf2
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -46,7 +46,22 @@ href_summary:
|
|
46
46
|
pry_on_href_error: true # Default value is false
|
47
47
|
```
|
48
48
|
|
49
|
-
##
|
49
|
+
## Suppprted Syntaxes
|
50
|
+
|
51
|
+
Square brackets in the [BNF notation](https://en.wikipedia.org/wiki/Backus%E2%80%93Naur_form)
|
52
|
+
below denote optional keyword parameters, and are not meant to be typed.
|
53
|
+
|
54
|
+
## Syntax 1 (most verbose, but provides best results and enables implicit matching title)
|
55
|
+
|
56
|
+
```html
|
57
|
+
{% href [match | [follow] [blank|notarget] [summary_exclude]] url="local_page.html" label="text to display" %}
|
58
|
+
```
|
59
|
+
|
60
|
+
1. The url can be #relative, a page in the Jekyll website, or prefaced with a protocol, such as `https:`
|
61
|
+
2. If `match` is provided, and `label` is not provided, then the title of the matched page is used as the label.
|
62
|
+
|
63
|
+
|
64
|
+
## Syntax 2 (requires `url` without embedded spaces)
|
50
65
|
|
51
66
|
```html
|
52
67
|
{% href [match | [follow] [blank|notarget] [page_title] [summary_exclude]] url text to display %}
|
@@ -54,10 +69,9 @@ href_summary:
|
|
54
69
|
|
55
70
|
1. The url must be a single token, without embedded spaces.
|
56
71
|
2. The url need not be enclosed in quotes.
|
57
|
-
3. The square brackets denote optional keyword parameters, and should not be typed.
|
58
72
|
|
59
73
|
|
60
|
-
## Syntax
|
74
|
+
## Syntax 3 (always works)
|
61
75
|
|
62
76
|
This syntax is recommended when the URL contains a colon (:).
|
63
77
|
|
@@ -68,10 +82,9 @@ This syntax is recommended when the URL contains a colon (:).
|
|
68
82
|
|
69
83
|
1. Each of the above examples contain an embedded newline, which is legal.
|
70
84
|
2. The url must be enclosed by either single or double quotes.
|
71
|
-
3. The square brackets denote optional keyword parameters, and should not be typed.
|
72
85
|
|
73
86
|
|
74
|
-
## Syntax
|
87
|
+
## Syntax 4 (implicit URL)
|
75
88
|
|
76
89
|
```html
|
77
90
|
{% href [match | [follow] [blank|notarget] [page_title] [summary_exclude]] [shy|wbr] www.domain.com %}
|
@@ -287,6 +300,21 @@ Expands to:
|
|
287
300
|
|
288
301
|
Substitutions are only made to the URL, not to the linked text.
|
289
302
|
|
303
|
+
8. Dollar signs
|
304
|
+
|
305
|
+
If the URL has a dollar sign in it, jekyll_href will attempt to replace an environment variable with its value.
|
306
|
+
That will likely fail silently. To work around the problem, replace dollar signs in URLs with $.
|
307
|
+
|
308
|
+
For example, given this URL:
|
309
|
+
https://ammonite.io/#import$ivy
|
310
|
+
rewrite as:
|
311
|
+
https://ammonite.io/#import$ivy.
|
312
|
+
|
313
|
+
Here is a complete invocation:
|
314
|
+
|
315
|
+
{% href url="https://ammonite.io/#import$ivy"
|
316
|
+
label="<code>import $ivy</code>" %}
|
317
|
+
|
290
318
|
|
291
319
|
## References Generation
|
292
320
|
|
data/jekyll_href.gemspec
CHANGED
@@ -33,6 +33,6 @@ Gem::Specification.new do |spec|
|
|
33
33
|
spec.add_dependency 'ipaddress'
|
34
34
|
spec.add_dependency 'jekyll', '>= 3.5.0'
|
35
35
|
spec.add_dependency 'jekyll_all_collections'
|
36
|
-
spec.add_dependency 'jekyll_plugin_support', '>= 1.0.
|
36
|
+
spec.add_dependency 'jekyll_plugin_support', '>= 1.0.2'
|
37
37
|
spec.add_dependency 'typesafe_enum'
|
38
38
|
end
|
data/lib/href_match.rb
CHANGED
@@ -2,19 +2,23 @@ module JekyllSupport
|
|
2
2
|
class HRefTag
|
3
3
|
private
|
4
4
|
|
5
|
-
def compute_link_and_text
|
6
|
-
|
7
|
-
case
|
5
|
+
def compute_link_and_text
|
6
|
+
page_matches = @site.all_collections.map.select { |page| page.url&.include? @path }
|
7
|
+
case page_matches.length
|
8
8
|
when 0
|
9
|
-
|
9
|
+
msg = "HRef error: No url matches '#{@link}', found on line #{@line_number} (after front matter) of #{@path}"
|
10
|
+
@logger.error { msg }
|
11
|
+
abort msg if @die_if_nomatch
|
12
|
+
@text = "<i class='h_ref_error'>#{@link} is not available</i>"
|
10
13
|
@link_save = @link = '#'
|
11
|
-
@text = "<i>#{@link} is not available</i>"
|
12
14
|
when 1
|
13
|
-
@link =
|
15
|
+
@link = page_matches.first.url
|
14
16
|
@link = "#{@link}##{@fragment}" if @fragment
|
15
17
|
@link_save = @link
|
18
|
+
@text = page_matches.first.title unless @label
|
16
19
|
else
|
17
|
-
|
20
|
+
logger.error { "Error: More than one url matched '#{@path}': #{url_matches.join(', ')}" }
|
21
|
+
exit! 2
|
18
22
|
end
|
19
23
|
end
|
20
24
|
|
@@ -31,8 +35,7 @@ module JekyllSupport
|
|
31
35
|
END_DEBUG
|
32
36
|
end
|
33
37
|
|
34
|
-
|
35
|
-
compute_link_and_text(all_urls)
|
38
|
+
compute_link_and_text
|
36
39
|
end
|
37
40
|
end
|
38
41
|
end
|
data/lib/href_private.rb
CHANGED
@@ -26,7 +26,7 @@ module JekyllSupport
|
|
26
26
|
<pre>{% href #{@argument_string.strip} %}</pre>
|
27
27
|
END_MESSAGE
|
28
28
|
@logger.error { JekyllSupport::JekyllPluginHelper.remove_html_tags msg.strip }
|
29
|
-
"<div class='
|
29
|
+
"<div class='h_ref_error'>HRefError: #{msg}</div>"
|
30
30
|
end
|
31
31
|
|
32
32
|
# Sets @follow, @helper, @match, @path, @target, @url, @hyphenation
|
data/lib/href_summary_tag.rb
CHANGED
@@ -40,13 +40,10 @@ module JekyllSupport
|
|
40
40
|
#{@helper.attribute if @helper.attribution && have_refs}
|
41
41
|
END_RENDER
|
42
42
|
rescue HRefError => e # jekyll_plugin_support handles StandardError
|
43
|
-
e.
|
44
|
-
|
45
|
-
@logger.error "#{e.class} raised #{msg}"
|
46
|
-
binding.pry if @pry_on_img_error # rubocop:disable Lint/Debugger
|
47
|
-
raise e if @die_on_href_error
|
43
|
+
@logger.error { e.logger_message }
|
44
|
+
exit! 1 if @die_on_demo_block_error
|
48
45
|
|
49
|
-
|
46
|
+
e.html_message
|
50
47
|
end
|
51
48
|
|
52
49
|
def render_global_refs
|
data/lib/href_tag.rb
CHANGED
@@ -46,7 +46,7 @@ module JekyllSupport
|
|
46
46
|
|
47
47
|
@helper_save = @helper.clone
|
48
48
|
globals_update(@helper.argv, linkk) # Sets @link and @text, might clear @follow and @target
|
49
|
-
handle_match(
|
49
|
+
handle_match(linkk) if @match # Sets @text if not set by now
|
50
50
|
raise HrefError, '@link_type was not set' if @link_type == LinkType::UNKNOWN
|
51
51
|
|
52
52
|
save_summary
|
@@ -54,15 +54,10 @@ module JekyllSupport
|
|
54
54
|
style = " style='#{@style}'" if @style
|
55
55
|
"<a href='#{@link}'#{klass}#{style}#{@target}#{@follow}>#{@text}</a>"
|
56
56
|
rescue HRefError => e # jekyll_plugin_support handles StandardError
|
57
|
-
|
58
|
-
|
59
|
-
@text = "<div class='href_error'>#{msg}</div>"
|
60
|
-
e.shorten_backtrace
|
61
|
-
@logger.error "#{e.class} raised #{msg}"
|
62
|
-
binding.pry if @pry_on_img_error # rubocop:disable Lint/Debugger
|
63
|
-
raise e if @die_on_href_error
|
57
|
+
@logger.error { e.logger_message }
|
58
|
+
exit 1 if @die_on_demo_tag_error
|
64
59
|
|
65
|
-
|
60
|
+
e.html_message
|
66
61
|
end
|
67
62
|
|
68
63
|
def to_s
|
data/lib/jekyll_href/version.rb
CHANGED
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
|
+
version: 1.2.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Slinn
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-08-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ipaddress
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 1.0.
|
61
|
+
version: 1.0.2
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 1.0.
|
68
|
+
version: 1.0.2
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: typesafe_enum
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -136,7 +136,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
136
136
|
- !ruby/object:Gem::Version
|
137
137
|
version: '0'
|
138
138
|
requirements: []
|
139
|
-
rubygems_version: 3.5.
|
139
|
+
rubygems_version: 3.5.17
|
140
140
|
signing_key:
|
141
141
|
specification_version: 4
|
142
142
|
summary: Generates an 'a href' tag, possibly with target='_blank' and rel='nofollow'.
|