jekyll_href 1.2.10 → 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/.rubocop.yml +3 -0
- data/CHANGELOG.md +12 -1
- data/README.md +33 -5
- data/jekyll_href.gemspec +1 -1
- data/lib/hash_array.rb +1 -1
- data/lib/href_match.rb +13 -10
- data/lib/href_page_title.rb +1 -1
- data/lib/href_private.rb +3 -3
- data/lib/href_summary.rb +1 -1
- data/lib/href_summary_tag.rb +6 -11
- data/lib/href_tag.rb +8 -12
- data/lib/jekyll_href/version.rb +1 -1
- data/lib/jekyll_href.rb +1 -4
- 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/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,9 +1,20 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## 1.2.12 / 2024-08-17
|
4
|
+
|
5
|
+
* Enhanced `match` so that if no label parameter is provided, the title of the matched web page is used.
|
6
|
+
* Now dependent on jekyll_plugin_support v1.0.2+ for better error handling.
|
7
|
+
|
8
|
+
|
9
|
+
## 1.2.11 / 2024-07-27
|
10
|
+
|
11
|
+
* Fixed an unqualified reference to `JekyllPluginHelper`.
|
12
|
+
* Shortened the very long stack dump for an error condition.
|
13
|
+
|
3
14
|
|
4
15
|
## 1.2.10 / 2024-07-23
|
5
16
|
|
6
|
-
* Make compatible with jekyll_plugin_support 1.0.0
|
17
|
+
* Make compatible with `jekyll_plugin_support` 1.0.0
|
7
18
|
|
8
19
|
|
9
20
|
## 1.2.9 / 2024-07-17
|
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/hash_array.rb
CHANGED
@@ -6,7 +6,7 @@ module HashArray
|
|
6
6
|
|
7
7
|
def add_link_for_page(href, hash)
|
8
8
|
enclosing_page = href.path
|
9
|
-
hash[enclosing_page] = []
|
9
|
+
hash[enclosing_page] = hash[enclosing_page] || []
|
10
10
|
pre_existing = hash[enclosing_page].find { |h| h.link_save == href.link_save }
|
11
11
|
if pre_existing
|
12
12
|
if pre_existing.follow != href.follow
|
data/lib/href_match.rb
CHANGED
@@ -1,20 +1,24 @@
|
|
1
|
-
module
|
1
|
+
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 MSlinn
|
|
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_page_title.rb
CHANGED
data/lib/href_private.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
module
|
1
|
+
module JekyllSupport
|
2
2
|
class HRefTag
|
3
3
|
private
|
4
4
|
|
@@ -25,8 +25,8 @@ module MSlinn
|
|
25
25
|
No URL was provided on #{@path}:#{@line_number} (after front matter).
|
26
26
|
<pre>{% href #{@argument_string.strip} %}</pre>
|
27
27
|
END_MESSAGE
|
28
|
-
@logger.error { JekyllPluginHelper.remove_html_tags msg.strip }
|
29
|
-
"<div class='
|
28
|
+
@logger.error { JekyllSupport::JekyllPluginHelper.remove_html_tags msg.strip }
|
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.rb
CHANGED
data/lib/href_summary_tag.rb
CHANGED
@@ -2,10 +2,8 @@ require 'jekyll_plugin_logger'
|
|
2
2
|
require 'jekyll_plugin_support'
|
3
3
|
require_relative 'jekyll_href/version'
|
4
4
|
|
5
|
-
module
|
6
|
-
class HrefSummary <
|
7
|
-
include JekyllHrefVersion
|
8
|
-
|
5
|
+
module JekyllSupport
|
6
|
+
class HrefSummary < JekyllTag
|
9
7
|
# Class instance variables accumulate hrefs across invocations.
|
10
8
|
# These are hashes of arrays;
|
11
9
|
# the hash keys are page paths (strings) and the hash values are arrays of HRefTags.
|
@@ -42,13 +40,10 @@ module MSlinn
|
|
42
40
|
#{@helper.attribute if @helper.attribution && have_refs}
|
43
41
|
END_RENDER
|
44
42
|
rescue HRefError => e # jekyll_plugin_support handles StandardError
|
45
|
-
e.
|
46
|
-
|
47
|
-
@logger.error "#{e.class} raised #{msg}"
|
48
|
-
binding.pry if @pry_on_img_error # rubocop:disable Lint/Debugger
|
49
|
-
raise e if @die_on_href_error
|
43
|
+
@logger.error { e.logger_message }
|
44
|
+
exit! 1 if @die_on_demo_block_error
|
50
45
|
|
51
|
-
|
46
|
+
e.html_message
|
52
47
|
end
|
53
48
|
|
54
49
|
def render_global_refs
|
@@ -85,6 +80,6 @@ module MSlinn
|
|
85
80
|
END_RENDER
|
86
81
|
end
|
87
82
|
|
88
|
-
|
83
|
+
JekyllSupport::JekyllPluginHelper.register(self, 'href_summary')
|
89
84
|
end
|
90
85
|
end
|
data/lib/href_tag.rb
CHANGED
@@ -11,13 +11,13 @@ require_relative 'hash_array'
|
|
11
11
|
# @license SPDX-License-Identifier: Apache-2.0
|
12
12
|
# Generates an href.
|
13
13
|
|
14
|
-
module
|
14
|
+
module JekyllSupport
|
15
15
|
MiniHref = Struct.new(:follow, :html, :link, :line_number, :link_save, :path, :summary_exclude, :summary_href, keyword_init: true)
|
16
16
|
|
17
17
|
HRefError = JekyllSupport.define_error
|
18
18
|
|
19
19
|
# Implements href Jekyll tag
|
20
|
-
class HRefTag <
|
20
|
+
class HRefTag < JekyllTag
|
21
21
|
attr_reader :follow, :helper, :line_number, :link_save, :match, :page, :path, :site,
|
22
22
|
:summary, :summary_exclude, :summary_href, :target, :text, :url
|
23
23
|
attr_accessor :link
|
@@ -46,29 +46,25 @@ module MSlinn
|
|
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(
|
50
|
-
raise HrefError,
|
49
|
+
handle_match(linkk) if @match # Sets @text if not set by now
|
50
|
+
raise HrefError, '@link_type was not set' if @link_type == LinkType::UNKNOWN
|
51
51
|
|
52
52
|
save_summary
|
53
53
|
klass = " class='#{@klass}'" if @klass
|
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
|
-
e.shorten_backtrace
|
60
|
-
@logger.error "#{e.class} raised #{msg}"
|
61
|
-
binding.pry if @pry_on_img_error # rubocop:disable Lint/Debugger
|
62
|
-
raise e if @die_on_href_error
|
57
|
+
@logger.error { e.logger_message }
|
58
|
+
exit 1 if @die_on_demo_tag_error
|
63
59
|
|
64
|
-
|
60
|
+
e.html_message
|
65
61
|
end
|
66
62
|
|
67
63
|
def to_s
|
68
64
|
"On line #{line_number} of #{path}: #{follow} #{match} #{target} #{link} => '#{text}'"
|
69
65
|
end
|
70
66
|
|
71
|
-
|
67
|
+
JekyllSupport::JekyllPluginHelper.register(self, 'href')
|
72
68
|
end
|
73
69
|
end
|
74
70
|
|
data/lib/jekyll_href/version.rb
CHANGED
data/lib/jekyll_href.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'.
|