jekyll_href 1.2.12 → 1.3.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 +4 -4
- data/CHANGELOG.md +15 -0
- data/README.md +139 -56
- data/jekyll_href.gemspec +12 -11
- data/lib/enums.rb +1 -0
- data/lib/href_match.rb +10 -4
- data/lib/href_page_title.rb +8 -4
- data/lib/href_private.rb +6 -5
- data/lib/href_summary.rb +1 -1
- data/lib/href_summary_tag.rb +1 -1
- data/lib/href_tag.rb +19 -5
- data/lib/jekyll_href/version.rb +1 -1
- metadata +7 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 92c3c54bedf52250d2880861ddb2e082438f09abcab7250584c10e319472a76e
|
4
|
+
data.tar.gz: db09257b439fdf22e086f9c398e592033ebbbfd60373c8fa7161ef554c87a88c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c203993a355885d0660a97d0db3208b2a75434ec6657542b40611cfb5020934f652dda3a2371e739967d3939011df7bd14e2f034171af5a9fdbeb24cacd09185
|
7
|
+
data.tar.gz: 2d00af4a425fb696b27ea070cf9ca32ed5777bf536988bab78e9123cc60a623690b2c5fdeb5453261fb2e1497fe22931a438dae7a556ffc50506b17f01fffc3b
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,20 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## 1.3.0 / 2025/-02-07
|
4
|
+
|
5
|
+
* The `match` option now searches all files, not just pages in collections.
|
6
|
+
* A binary search is now used.
|
7
|
+
* Launch configurations are now provided for `production` and `development` modes of the demo website.
|
8
|
+
* Renamed `HRef_error` to `HrefError`.
|
9
|
+
|
10
|
+
|
11
|
+
## 1.2.13 / 2024-12-23
|
12
|
+
|
13
|
+
* Fixed reference to undefined `url_matches`.
|
14
|
+
* References that point to draft pages are rendered differently in production mode,
|
15
|
+
and an info-level log message is generated
|
16
|
+
|
17
|
+
|
3
18
|
## 1.2.12 / 2024-08-17
|
4
19
|
|
5
20
|
* Enhanced `match` so that if no label parameter is provided, the title of the matched web page is used.
|
data/README.md
CHANGED
@@ -1,31 +1,61 @@
|
|
1
1
|
# `Jekyll_href` [](https://badge.fury.io/rb/jekyll_href)
|
2
2
|
|
3
|
-
`Jekyll_href` is a Jekyll plugin that
|
4
|
-
It provides a convenient way to generate formatted and clickable URIs.
|
5
|
-
The Liquid tag generates an `a href` HTML tag,
|
6
|
-
which by default contains `target="_blank"` and `rel="nofollow"`.
|
3
|
+
`Jekyll_href` is a flexible Jekyll plugin that is designed to minimize the work of creating and maintaining a Jekyll website.
|
7
4
|
|
8
|
-
If the url starts with `http`, or the `match` keyword is specified:
|
9
5
|
|
10
|
-
|
11
|
-
|
6
|
+
## Features
|
7
|
+
|
8
|
+
1. It provides a new Liquid tag: `href` with default options such as generating `target="_blank"` and `rel="nofollow"`
|
9
|
+
that can be overridden.
|
10
|
+
2. The `match` keyword causes the title of the linked Jekyll page to be used as the link text;
|
11
|
+
an error is displayed if the page does not exist.
|
12
|
+
3. Provides a convenient syntax for generating links with monospaced text that display the URL being linked to.
|
13
|
+
4. Can generate soft hyphens (&shy; and <wbr>).
|
14
|
+
5. If the url starts with `http`, or the `match` keyword is specified:
|
15
|
+
|
16
|
+
a. The url will open in a new tab or window.
|
17
|
+
|
18
|
+
b. The url will include `rel="nofollow"` for SEO purposes.
|
19
|
+
|
20
|
+
6. URLs can be composed from environment variable references.
|
21
|
+
7. The href tags in a page can be summarized by the `href_summary` tag.
|
12
22
|
|
13
23
|
CAUTION: if linked text contains a single or double quote,
|
14
24
|
you will see the error message: `Liquid Exception: Unmatched quote`.
|
15
25
|
Instead, use one of the following:
|
16
26
|
|
17
|
-
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
27
|
+
<ul style="column-count: 3; list-style-type: none; padding: 0; margin: 0 2em;">
|
28
|
+
<li><code>&apos;</code> (')</li>
|
29
|
+
<li><code>&quot;</code> (")</li>
|
30
|
+
<li><code>&lsquo;</code> (‘)</li>
|
31
|
+
<li><code>&rsquo;</code> (’)</li>
|
32
|
+
<li><code>&ldquo;</code> (“)</li>
|
33
|
+
<li><code>&rdquo;</code> (”)</li>
|
34
|
+
</ul>
|
35
|
+
|
36
|
+
|
37
|
+
## Installation
|
38
|
+
|
39
|
+
Add the following to your Jekyll website's `Gemfile`, within the `jekyll_plugins` group:
|
40
|
+
|
41
|
+
```text
|
42
|
+
group :jekyll_plugins do
|
43
|
+
gem 'jekyll_href'
|
44
|
+
end
|
45
|
+
```
|
46
|
+
|
47
|
+
And then execute:
|
48
|
+
|
49
|
+
```shell
|
50
|
+
$ bundle
|
51
|
+
```
|
23
52
|
|
24
53
|
|
25
54
|
## Configuration
|
26
55
|
|
27
56
|
In `_config.yml`, if a section called `plugin-vars` exists,
|
28
57
|
then its name/value pairs are available for substitution.
|
58
|
+
When referenced from a web page, the names must be enclosed within {{double curly braces}} in order for substitution to occur.
|
29
59
|
|
30
60
|
```yaml
|
31
61
|
plugin-vars:
|
@@ -33,6 +63,15 @@ plugin-vars:
|
|
33
63
|
django-oscar-github: 'https://github.com/django-oscar/django-oscar/blob/3.0.2'
|
34
64
|
```
|
35
65
|
|
66
|
+
Use it as shown below. The lines have been folded for legibility; whitespace formatting is optional:
|
67
|
+
|
68
|
+
```text
|
69
|
+
{% href
|
70
|
+
label="django.core.management.execute_from_command_line"
|
71
|
+
url="{{django-github}}/django/core/management/__init__.py#L398-L401"
|
72
|
+
%}
|
73
|
+
```
|
74
|
+
|
36
75
|
The following sections and settings can be set:
|
37
76
|
`Pry_on_href_error` has priority over `die_on_href_error`.
|
38
77
|
|
@@ -46,55 +85,108 @@ href_summary:
|
|
46
85
|
pry_on_href_error: true # Default value is false
|
47
86
|
```
|
48
87
|
|
88
|
+
|
89
|
+
## Common Usages
|
90
|
+
|
91
|
+
1. For local links (links within a Jekyll website), the best way to make them is with an incantation like this:
|
92
|
+
```text
|
93
|
+
{% href match url='trust_winning.html' %}{% endraw %}
|
94
|
+
```
|
95
|
+
|
96
|
+
The above uses the page title of <code>trust_winning.html</code> as the link text;
|
97
|
+
an error is displayed if the page does not exist.
|
98
|
+
It renders like this: {% href match url='trust_winning.html' %}.
|
99
|
+
|
100
|
+
2. To display external links with a monospaced font, and use the URL as the link text, use an incantation like this:
|
101
|
+
```text
|
102
|
+
{% href url='mslinn.com' %}{% endraw %}
|
103
|
+
```
|
104
|
+
The above renders as: <a href="https://mslinn.com"><code>mslinn.com</code></a>.
|
105
|
+
|
106
|
+
|
49
107
|
## Suppprted Syntaxes
|
50
108
|
|
51
109
|
Square brackets in the [BNF notation](https://en.wikipedia.org/wiki/Backus%E2%80%93Naur_form)
|
52
110
|
below denote optional keyword parameters, and are not meant to be typed.
|
111
|
+
Additional usage examples follow.
|
53
112
|
|
54
|
-
|
113
|
+
|
114
|
+
## Syntax 1: Mmost verbose
|
115
|
+
|
116
|
+
This is the most verbose syntax, but it provides most reliable results.
|
117
|
+
If `match` is specified, the title from the matching page is used as the link
|
118
|
+
text unless overridden by the value of the `label` parameter.
|
119
|
+
|
120
|
+
Options are:
|
55
121
|
|
56
122
|
```html
|
57
|
-
{% href [match | [follow] [blank|notarget] [summary_exclude]]
|
123
|
+
{% href [match | [follow] [blank|notarget] [summary_exclude]]
|
124
|
+
label="text to display"
|
125
|
+
url="local_page.html"
|
126
|
+
%}
|
58
127
|
```
|
59
128
|
|
60
129
|
1. The url can be #relative, a page in the Jekyll website, or prefaced with a protocol, such as `https:`
|
61
|
-
2.
|
130
|
+
2. Embedded newlines within the label are legal.
|
131
|
+
3. The `url` and `label` parameter values can be enclosed in single or double quotes.
|
132
|
+
4. If `match` is provided, and `label` is not provided, then the title of the matched page is used as the label.
|
133
|
+
|
62
134
|
|
135
|
+
## Syntax 2: Easiest to Type
|
63
136
|
|
64
|
-
|
137
|
+
This syntax uses positional parameters instead of labeled parameters.
|
138
|
+
This syntax can only be used if the url does not contain embedded spaces.
|
139
|
+
You can write the tag on one line, or several lines as shown.
|
65
140
|
|
66
141
|
```html
|
67
|
-
{% href [match | [follow] [blank|notarget] [page_title] [summary_exclude]]
|
142
|
+
{% href [match | [follow] [blank|notarget] [page_title] [summary_exclude]]
|
143
|
+
url
|
144
|
+
text to display
|
145
|
+
%}
|
68
146
|
```
|
69
147
|
|
70
|
-
1.
|
148
|
+
1. Embedded newlines within the tag are legal.
|
71
149
|
2. The url need not be enclosed in quotes.
|
150
|
+
3. The `match` keyword causes the title of the linked page to be used as the link text unless the `label` option is provided.
|
151
|
+
4. If `url` is not provided, then the text to display is assumed to be a URI,
|
152
|
+
as described in syntax 4, and is formatted into a clickable link.
|
72
153
|
|
73
154
|
|
74
|
-
## Syntax 3
|
155
|
+
## Syntax 3: `url` Option
|
75
156
|
|
76
|
-
This syntax is recommended when the URL contains a
|
157
|
+
This syntax is recommended when the URL contains a problematic character,
|
158
|
+
such as a colon (`:`) or space, and you are too lazy to type out label=.
|
159
|
+
Contrast with the explicit `label` parameter syntax, described next.
|
77
160
|
|
78
161
|
```html
|
79
162
|
{% href [match | [follow] [blank|notarget]] [page_title] [summary_exclude]
|
80
|
-
url="http://link.com with space.html"
|
163
|
+
url="http://link.com with space.html"
|
164
|
+
some text
|
165
|
+
%}
|
81
166
|
```
|
82
167
|
|
83
168
|
1. Each of the above examples contain an embedded newline, which is legal.
|
84
169
|
2. The url must be enclosed by either single or double quotes.
|
85
170
|
|
86
171
|
|
87
|
-
## Syntax 4
|
172
|
+
## Syntax 4 Explicit `label` Option
|
173
|
+
|
174
|
+
This syntax is recommended when the linked text contains an option keyword, such as `summary` or `label`.
|
175
|
+
It can be combined with an explicit url, described above.
|
88
176
|
|
89
177
|
```html
|
90
|
-
{% href [match | [follow] [blank|notarget] [page_title] [summary_exclude]] [shy|wbr]
|
178
|
+
{% href [match | [follow] [blank|notarget] [page_title] [summary_exclude]] [shy|wbr]
|
179
|
+
www.domain.com
|
180
|
+
%}
|
91
181
|
```
|
92
182
|
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
183
|
+
1. Embedded newlines within the tag are legal.
|
184
|
+
|
185
|
+
2. The URI provided, for example `www.domain.com`,
|
186
|
+
is used to form the URL by prepending `https://`,
|
187
|
+
in this case the result would be `https://www.domain.com`.
|
188
|
+
The displayed URI is enclosed in `<code></code>`,
|
189
|
+
so the resulting text is `<code>www.domain.com</code>`.
|
98
190
|
|
99
191
|
|
100
192
|
## Environment Variable Expansion
|
@@ -103,22 +195,19 @@ URLs can contain environment variable references.
|
|
103
195
|
For example, if `$domain`, `$uri` and `$USER` are environment variables:
|
104
196
|
|
105
197
|
```html
|
198
|
+
Using keyword options:
|
106
199
|
{% href http://$domain.html some text %}
|
107
200
|
|
201
|
+
Using the url option and positional link text:
|
108
202
|
{% href url="$uri" some text %}
|
109
203
|
|
204
|
+
Using positional parameters for the URL and the link text:
|
110
205
|
{% href https://mslinn.html <code>USER=$USER</code> %}
|
111
206
|
```
|
112
207
|
|
113
208
|
|
114
209
|
## Optional Parameters
|
115
210
|
|
116
|
-
### `page_title`
|
117
|
-
|
118
|
-
For local pages, use the linked page title as the link text.
|
119
|
-
This value overrides any provided link text.
|
120
|
-
|
121
|
-
|
122
211
|
### `blank`
|
123
212
|
|
124
213
|
The `target='_blank'` attribute is not normally generated for relative links.
|
@@ -166,10 +255,14 @@ Both of the following produce the same output:
|
|
166
255
|
### `match`
|
167
256
|
|
168
257
|
`match` will attempt to match the url fragment (specified as a regex) to a URL in any collection.
|
169
|
-
If multiple documents have matching
|
258
|
+
If multiple documents have matching URLs an error is thrown.
|
170
259
|
The `match` option looks through the pages collection for a URL with containing the provided substring.
|
171
260
|
`Match` implies `follow` and `notarget`.
|
172
261
|
|
262
|
+
```text
|
263
|
+
{% href match url="page6.html" %}
|
264
|
+
```
|
265
|
+
|
173
266
|
|
174
267
|
### `notarget`
|
175
268
|
|
@@ -178,6 +271,12 @@ The `blank` and `notarget` parameters are mutually exclusive.
|
|
178
271
|
If both are specified, `blank` prevails.
|
179
272
|
|
180
273
|
|
274
|
+
### `page_title`
|
275
|
+
|
276
|
+
For local pages, use the linked page title as the link text.
|
277
|
+
This value overrides any provided link text.
|
278
|
+
|
279
|
+
|
181
280
|
### `shy`
|
182
281
|
|
183
282
|
The `shy` keyword option is only applicable for syntax 3 (implicit URL).
|
@@ -253,7 +352,7 @@ Expands to:
|
|
253
352
|
```
|
254
353
|
|
255
354
|
|
256
|
-
## Examples
|
355
|
+
## Usage Examples
|
257
356
|
|
258
357
|
1. Generates `nofollow` and `target` attributes:
|
259
358
|
|
@@ -312,9 +411,10 @@ Expands to:
|
|
312
411
|
|
313
412
|
Here is a complete invocation:
|
314
413
|
|
414
|
+
```text
|
315
415
|
{% href url="https://ammonite.io/#import$ivy"
|
316
416
|
label="<code>import $ivy</code>" %}
|
317
|
-
|
417
|
+
```
|
318
418
|
|
319
419
|
## References Generation
|
320
420
|
|
@@ -368,7 +468,7 @@ Given these `href` and `href_summary` usages in a web page:
|
|
368
468
|
{% href_summary attribution include_local %}
|
369
469
|
```
|
370
470
|
|
371
|
-
|
471
|
+
The generated HTML looks like the following:
|
372
472
|
|
373
473
|
```html
|
374
474
|
<h2 id="reference">References</h2>
|
@@ -401,23 +501,6 @@ More information is available on my website about
|
|
401
501
|
[my Jekyll plugins](https://www.mslinn.com/blog/2020/10/03/jekyll-plugins.html).
|
402
502
|
|
403
503
|
|
404
|
-
## Installation
|
405
|
-
|
406
|
-
Add this line to your Jekyll website's `Gemfile`, within the `jekyll_plugins` group:
|
407
|
-
|
408
|
-
```ruby
|
409
|
-
group :jekyll_plugins do
|
410
|
-
gem 'jekyll_href'
|
411
|
-
end
|
412
|
-
```
|
413
|
-
|
414
|
-
And then execute:
|
415
|
-
|
416
|
-
```shell
|
417
|
-
$ bundle
|
418
|
-
```
|
419
|
-
|
420
|
-
|
421
504
|
## Generated HTML
|
422
505
|
|
423
506
|
### Without Keywords
|
data/jekyll_href.gemspec
CHANGED
@@ -3,15 +3,15 @@ require_relative 'lib/jekyll_href/version'
|
|
3
3
|
Gem::Specification.new do |spec|
|
4
4
|
github = 'https://github.com/mslinn/jekyll_href'
|
5
5
|
|
6
|
-
spec.authors
|
7
|
-
spec.bindir
|
6
|
+
spec.authors = ['Mike Slinn']
|
7
|
+
spec.bindir = 'exe'
|
8
8
|
spec.description = <<~END_OF_DESC
|
9
9
|
Generates an 'a href' tag, possibly with target='_blank' and rel='nofollow'.
|
10
10
|
END_OF_DESC
|
11
|
-
spec.email
|
12
|
-
spec.files
|
11
|
+
spec.email = ['mslinn@mslinn.com']
|
12
|
+
spec.files = Dir['.rubocop.yml', 'LICENSE.*', 'Rakefile', '{lib,spec}/**/*', '*.gemspec', '*.md']
|
13
13
|
spec.homepage = 'https://www.mslinn.com/jekyll_plugins/jekyll_href.html'
|
14
|
-
spec.license
|
14
|
+
spec.license = 'MIT'
|
15
15
|
spec.metadata = {
|
16
16
|
'allowed_push_host' => 'https://rubygems.org',
|
17
17
|
'bug_tracker_uri' => "#{github}/issues",
|
@@ -19,20 +19,21 @@ Gem::Specification.new do |spec|
|
|
19
19
|
'homepage_uri' => spec.homepage,
|
20
20
|
'source_code_uri' => github,
|
21
21
|
}
|
22
|
-
spec.name
|
22
|
+
spec.name = 'jekyll_href'
|
23
|
+
spec.platform = Gem::Platform::RUBY
|
23
24
|
spec.post_install_message = <<~END_MESSAGE
|
24
25
|
|
25
26
|
Thanks for installing #{spec.name}!
|
26
27
|
|
27
28
|
END_MESSAGE
|
28
|
-
spec.require_paths
|
29
|
+
spec.require_paths = ['lib']
|
29
30
|
spec.required_ruby_version = '>= 2.6.0'
|
30
|
-
spec.summary
|
31
|
-
spec.version
|
31
|
+
spec.summary = "Generates an 'a href' tag, possibly with target='_blank' and rel='nofollow'."
|
32
|
+
spec.version = JekyllHrefVersion::VERSION
|
32
33
|
|
33
34
|
spec.add_dependency 'ipaddress'
|
34
35
|
spec.add_dependency 'jekyll', '>= 3.5.0'
|
35
|
-
spec.add_dependency 'jekyll_all_collections'
|
36
|
-
spec.add_dependency 'jekyll_plugin_support', '>= 1.0
|
36
|
+
spec.add_dependency 'jekyll_all_collections', '>= 0.4.0'
|
37
|
+
spec.add_dependency 'jekyll_plugin_support', '>= 1.1.0'
|
37
38
|
spec.add_dependency 'typesafe_enum'
|
38
39
|
end
|
data/lib/enums.rb
CHANGED
data/lib/href_match.rb
CHANGED
@@ -2,14 +2,20 @@ module JekyllSupport
|
|
2
2
|
class HRefTag
|
3
3
|
private
|
4
4
|
|
5
|
+
# This is a computationally intense method, and really slows down site generation.
|
6
|
+
# TODO: implement cache in front of sorted objects containing paths and page reference
|
7
|
+
# This cache is also needed by page_match in jekyll_draft
|
5
8
|
def compute_link_and_text
|
6
|
-
page_matches = @site.
|
9
|
+
page_matches = @site.everything # ? all_documents ?
|
10
|
+
.select { |page| page.url&.include? @path }
|
11
|
+
.reject { |x| x.path == 'redirect.html' } || []
|
7
12
|
case page_matches.length
|
8
13
|
when 0
|
9
|
-
msg = "HRef error: No url matches '#{@
|
14
|
+
msg = "HRef error: No url matches '#{@path}', found on line #{@line_number} (after front matter) of #{@path}"
|
10
15
|
@logger.error { msg }
|
11
16
|
abort msg if @die_if_nomatch
|
12
|
-
|
17
|
+
|
18
|
+
@text = "<i class='not_public_yet'><code>#{@path}</code> is not a public page yet</i>"
|
13
19
|
@link_save = @link = '#'
|
14
20
|
when 1
|
15
21
|
@link = page_matches.first.url
|
@@ -17,7 +23,7 @@ module JekyllSupport
|
|
17
23
|
@link_save = @link
|
18
24
|
@text = page_matches.first.title unless @label
|
19
25
|
else
|
20
|
-
logger.error { "Error: More than one url matched '#{@path}'
|
26
|
+
logger.error { "Error: More than one url matched '#{@path}', referenced in '#{@page['path']}':\n #{page_matches.map(&:url).join("\n ")}" }
|
21
27
|
exit! 2
|
22
28
|
end
|
23
29
|
end
|
data/lib/href_page_title.rb
CHANGED
@@ -18,15 +18,19 @@ module JekyllSupport
|
|
18
18
|
# Uses the linked page title as the link text
|
19
19
|
def handle_page_title(linkk)
|
20
20
|
@follow = @target = ''
|
21
|
-
|
21
|
+
unless @link_type == LinkType::LOCAL
|
22
|
+
puts 'Oops'
|
23
|
+
raise HrefError, 'href tags with page_title require local links.'
|
24
|
+
end
|
22
25
|
|
23
26
|
page = find_page linkk
|
24
27
|
unless page
|
25
28
|
msg = "There is no page at path #{linkk}"
|
26
|
-
@text = "<div class='
|
27
|
-
raise
|
29
|
+
@text = "<div class='h_ref_error'>HrefError: #{msg}</div>\n<pre> {% href #{@argument_string.strip} %}</pre>"
|
30
|
+
raise HrefError, msg
|
28
31
|
end
|
29
|
-
@text =
|
32
|
+
@text = ''
|
33
|
+
@label = page.title
|
30
34
|
handle_empty_text linkk if @text.to_s.empty?
|
31
35
|
@label
|
32
36
|
end
|
data/lib/href_private.rb
CHANGED
@@ -16,7 +16,7 @@ module JekyllSupport
|
|
16
16
|
return nil, error_no_uri
|
17
17
|
end
|
18
18
|
[linkk, nil]
|
19
|
-
rescue
|
19
|
+
rescue HrefError => e
|
20
20
|
[nil, e]
|
21
21
|
end
|
22
22
|
|
@@ -26,13 +26,12 @@ 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='h_ref_error'>
|
29
|
+
"<div class='h_ref_error'>HrefError: #{msg}</div>"
|
30
30
|
end
|
31
31
|
|
32
32
|
# Sets @follow, @helper, @match, @path, @target, @url, @hyphenation
|
33
33
|
def globals_initial
|
34
34
|
@path = @page['path']
|
35
|
-
AllCollectionsHooks.compute @site
|
36
35
|
@hyphenation = Hyphenation::NONE
|
37
36
|
|
38
37
|
@blank = @helper.parameter_specified? 'blank'
|
@@ -83,8 +82,10 @@ module JekyllSupport
|
|
83
82
|
return
|
84
83
|
end
|
85
84
|
|
86
|
-
@link_type = if linkk.start_with? 'http'
|
85
|
+
@link_type = if linkk.start_with? 'http:', 'https:'
|
87
86
|
LinkType::EXTERNAL
|
87
|
+
elsif linkk.start_with? 'file:'
|
88
|
+
LinkType::FILE
|
88
89
|
elsif linkk.start_with? '#'
|
89
90
|
LinkType::FRAGMENT
|
90
91
|
else
|
@@ -101,7 +102,7 @@ module JekyllSupport
|
|
101
102
|
linkk
|
102
103
|
end
|
103
104
|
@link_save = @link
|
104
|
-
return if @link_type == LinkType::EXTERNAL
|
105
|
+
return if @link_type == LinkType::EXTERNAL || @link_type == LinkType::FILE
|
105
106
|
|
106
107
|
@follow = ''
|
107
108
|
@target = '' unless @blank
|
data/lib/href_summary.rb
CHANGED
data/lib/href_summary_tag.rb
CHANGED
@@ -39,7 +39,7 @@ module JekyllSupport
|
|
39
39
|
#{local_refs}
|
40
40
|
#{@helper.attribute if @helper.attribution && have_refs}
|
41
41
|
END_RENDER
|
42
|
-
rescue
|
42
|
+
rescue HrefError => e # jekyll_plugin_support handles StandardError
|
43
43
|
@logger.error { e.logger_message }
|
44
44
|
exit! 1 if @die_on_demo_block_error
|
45
45
|
|
data/lib/href_tag.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'ipaddress'
|
2
|
+
require 'jekyll_draft'
|
2
3
|
require 'jekyll_all_collections'
|
3
4
|
require 'jekyll_plugin_logger'
|
4
5
|
require 'jekyll_plugin_support'
|
@@ -14,8 +15,6 @@ require_relative 'hash_array'
|
|
14
15
|
module JekyllSupport
|
15
16
|
MiniHref = Struct.new(:follow, :html, :link, :line_number, :link_save, :path, :summary_exclude, :summary_href, keyword_init: true)
|
16
17
|
|
17
|
-
HRefError = JekyllSupport.define_error
|
18
|
-
|
19
18
|
# Implements href Jekyll tag
|
20
19
|
class HRefTag < JekyllTag
|
21
20
|
attr_reader :follow, :helper, :line_number, :link_save, :match, :page, :path, :site,
|
@@ -46,15 +45,30 @@ module JekyllSupport
|
|
46
45
|
|
47
46
|
@helper_save = @helper.clone
|
48
47
|
globals_update(@helper.argv, linkk) # Sets @link and @text, might clear @follow and @target
|
49
|
-
handle_match(linkk) if @match # Sets @text if not set by now
|
48
|
+
handle_match(linkk) if @match # Sets @text if not set by now, also @link_type, etc.
|
50
49
|
raise HrefError, '@link_type was not set' if @link_type == LinkType::UNKNOWN
|
51
50
|
|
52
51
|
save_summary
|
52
|
+
|
53
53
|
klass = " class='#{@klass}'" if @klass
|
54
54
|
style = " style='#{@style}'" if @style
|
55
|
+
|
56
|
+
if @link_type == LinkType::LOCAL &&
|
57
|
+
@mode == 'production' &&
|
58
|
+
@label_source != LabelSource::FROM_IMPLICIT_LABEL &&
|
59
|
+
@link != '#'
|
60
|
+
path, _fragment = @link.split('#')
|
61
|
+
page = ::Jekyll::Draft.page_match path
|
62
|
+
if ::Jekyll::Draft.draft? page
|
63
|
+
klass = "draft_link #{@klass}".strip
|
64
|
+
raise HrefError,
|
65
|
+
"<span class='#{klass}'#{style}><span class='draft_title'>#{page.title}</span> <span class='draft_label'>#{@text}</span></span>"
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
55
69
|
"<a href='#{@link}'#{klass}#{style}#{@target}#{@follow}>#{@text}</a>"
|
56
|
-
rescue
|
57
|
-
@logger.error { e.logger_message }
|
70
|
+
rescue HrefError => e # jekyll_plugin_support handles StandardError
|
71
|
+
@logger.error { JekyllPluginHelper.remove_html_tags e.logger_message }
|
58
72
|
exit 1 if @die_on_demo_tag_error
|
59
73
|
|
60
74
|
e.html_message
|
data/lib/jekyll_href/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll_href
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Slinn
|
8
|
-
autorequire:
|
9
8
|
bindir: exe
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 2025-02-07 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: ipaddress
|
@@ -44,28 +43,28 @@ dependencies:
|
|
44
43
|
requirements:
|
45
44
|
- - ">="
|
46
45
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
46
|
+
version: 0.4.0
|
48
47
|
type: :runtime
|
49
48
|
prerelease: false
|
50
49
|
version_requirements: !ruby/object:Gem::Requirement
|
51
50
|
requirements:
|
52
51
|
- - ">="
|
53
52
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
53
|
+
version: 0.4.0
|
55
54
|
- !ruby/object:Gem::Dependency
|
56
55
|
name: jekyll_plugin_support
|
57
56
|
requirement: !ruby/object:Gem::Requirement
|
58
57
|
requirements:
|
59
58
|
- - ">="
|
60
59
|
- !ruby/object:Gem::Version
|
61
|
-
version: 1.0
|
60
|
+
version: 1.1.0
|
62
61
|
type: :runtime
|
63
62
|
prerelease: false
|
64
63
|
version_requirements: !ruby/object:Gem::Requirement
|
65
64
|
requirements:
|
66
65
|
- - ">="
|
67
66
|
- !ruby/object:Gem::Version
|
68
|
-
version: 1.0
|
67
|
+
version: 1.1.0
|
69
68
|
- !ruby/object:Gem::Dependency
|
70
69
|
name: typesafe_enum
|
71
70
|
requirement: !ruby/object:Gem::Requirement
|
@@ -136,8 +135,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
136
135
|
- !ruby/object:Gem::Version
|
137
136
|
version: '0'
|
138
137
|
requirements: []
|
139
|
-
rubygems_version: 3.
|
140
|
-
signing_key:
|
138
|
+
rubygems_version: 3.6.3
|
141
139
|
specification_version: 4
|
142
140
|
summary: Generates an 'a href' tag, possibly with target='_blank' and rel='nofollow'.
|
143
141
|
test_files: []
|