jekyll_plugin_support 0.7.0 → 0.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +64 -24
- data/README.md +58 -27
- data/lib/jekyll_plugin_support/version.rb +1 -1
- data/lib/jekyll_plugin_support.rb +12 -3
- data/spec/status_persistence.txt +6 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e4093bb78659c8a6b9e75df1ed8e288e7ba8a0216b7d870f04856933c992e631
|
4
|
+
data.tar.gz: 69c2191230866feb2552a9a170140008b5d16290703f525d1a6487b28df78706
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e63ab6ea4dc5a241d4fdafd00fd088943dee27591a36297a2a5a4984e0096775365c902bd43ece243cea45ac26e64e5a374c1afcc72f51653825e680e33f40ae
|
7
|
+
data.tar.gz: 25db74e77f3f24dd4d40fb2aba3b3717ff630c6afb6e3e9743ac91dc1331a29139fe79c9c7e596e8e9a7c7149c83c2cedd6503401ff9f83cf1b3eb7ada94197c
|
data/CHANGELOG.md
CHANGED
@@ -1,56 +1,96 @@
|
|
1
|
+
# Change Log
|
2
|
+
|
3
|
+
## 0.7.1 / 2023-08-11
|
4
|
+
|
5
|
+
* Suppressed stack trace from issue [#4](../../issues/4).
|
6
|
+
* Now using Shopify `ruby-lsp` instead of `rebornix.Ruby` by Peng Lv
|
7
|
+
* Debug configurations changed to `rdbg` instead of `ruby`, so the `debase` development dependency was changed to
|
8
|
+
[`debug`](https://marketplace.visualstudio.com/items?itemName=KoichiSasada.vscode-rdbg),
|
9
|
+
which provides the `rdgb` command.
|
10
|
+
The `ruby-debug-ide` development dependency is also no longer required.
|
11
|
+
|
12
|
+
|
1
13
|
## 0.7.0 / 2023-05-22
|
2
|
-
|
14
|
+
|
15
|
+
* Added `error_short_trace` and `warn_short_trace` methods for displaying non-fatal errors on the console.
|
3
16
|
|
4
17
|
## 0.6.2 / 2023-05-15
|
5
|
-
|
18
|
+
|
19
|
+
* Removed annoying blank line output when attribute was invoked.
|
6
20
|
|
7
21
|
## 0.6.1 / 2023-04-12
|
8
|
-
|
22
|
+
|
23
|
+
* Added `CallChain.excerpt_caller` to detect if an excerpt is being generated.
|
24
|
+
|
9
25
|
|
10
26
|
## 0.6.0 / 2023-04-05
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
27
|
+
|
28
|
+
* Added attribution support
|
29
|
+
* Renamed `jekyll_plugin_support_helper.rb` to `jekyll_plugin_helper.rb`.
|
30
|
+
* Now returns `undefined` instead of `false'` when `@keys_values.empty?`
|
31
|
+
and parameter is not specified.
|
32
|
+
|
15
33
|
|
16
34
|
## 0.5.3 / 2023-03-19
|
17
|
-
|
35
|
+
|
36
|
+
* Added properties `argv_original`, `keys_values_original`, `remaining_markup_original`,
|
18
37
|
and `params_original`, which are the original values of `argv`, `keys_values`,
|
19
38
|
`remaining_markup`, and `params`, before environment variable expansion.
|
20
39
|
|
40
|
+
|
21
41
|
## 0.5.2 / 2023-03-17
|
22
|
-
|
42
|
+
|
43
|
+
* Added `@helper.remaining_markup` public method, which returns remaining markup passed to your tag,
|
44
|
+
after keyword and name/value parsing is complete.
|
23
45
|
* Finally wrote proper `rspec` tests.
|
24
46
|
* Finally documented argument parsing.
|
25
47
|
* Fixed bug introduced in v0.5.1 which did not remove elements from `@params`.
|
26
48
|
|
49
|
+
|
27
50
|
## 0.5.1 / 2023-02-17
|
28
|
-
|
51
|
+
|
52
|
+
* `no_arg_parsing` optimization added.
|
53
|
+
|
29
54
|
|
30
55
|
## 0.5.0 / 2023-02-15
|
31
|
-
|
32
|
-
|
33
|
-
|
56
|
+
|
57
|
+
* Plugins now register themselves
|
58
|
+
* Plugins now report their name and version
|
59
|
+
* `@layout`, `@paginator`, and `@theme` have values if supported by the version of Jekyll, and they are active.
|
60
|
+
(See [Jekyll docs](https://jekyllrb.com/docs/variables/).)
|
61
|
+
|
34
62
|
|
35
63
|
## 0.4.1 / 2023-02-14
|
36
|
-
|
37
|
-
|
64
|
+
|
65
|
+
* Fixed several problems
|
66
|
+
* Added demo site
|
67
|
+
|
38
68
|
|
39
69
|
## 0.4.0 / 2023-02-12
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
70
|
+
|
71
|
+
* `render_impl` for tags and blocks now predefines more instance variables:
|
72
|
+
|
73
|
+
* `@liquid_context` – passed to `render`
|
74
|
+
* `@config` Jekyll configuration
|
75
|
+
* `@envs` Environment variables
|
76
|
+
* `@mode` ('development', 'test' or 'production')
|
77
|
+
|
45
78
|
|
46
79
|
## 0.3.1 / 2023-02-07
|
47
|
-
|
80
|
+
|
81
|
+
* `JekyllBlock.render_impl` and `JekyllTag.render_impl` now define `@page` and `@site`.
|
82
|
+
|
48
83
|
|
49
84
|
## 0.3.0 / 2023-01-14
|
50
|
-
|
85
|
+
|
86
|
+
* Added support for tags, which should subclass JekyllSupport::JekyllTag
|
87
|
+
|
51
88
|
|
52
89
|
## 0.2.0 / 2023-01-12
|
53
|
-
|
90
|
+
|
91
|
+
* Refactored
|
92
|
+
|
54
93
|
|
55
94
|
## 0.1.0 / 2023-01-10
|
56
|
-
|
95
|
+
|
96
|
+
* Initial version; only supports Jekyll block tags
|
data/README.md
CHANGED
@@ -1,16 +1,17 @@
|
|
1
|
-
`jekyll_plugin_support`
|
2
|
-
[![Gem Version](https://badge.fury.io/rb/jekyll_plugin_support.svg)](https://badge.fury.io/rb/jekyll_plugin_support)
|
3
|
-
===========
|
1
|
+
# `jekyll_plugin_support` [![Gem Version](https://badge.fury.io/rb/jekyll_plugin_support.svg)](https://badge.fury.io/rb/jekyll_plugin_support)
|
4
2
|
|
5
3
|
`Jekyll_plugin_support` is a Ruby gem that facilitates writing and testing Jekyll plugins.
|
6
4
|
At present, only Jekyll tags and blocks are supported.
|
7
5
|
|
8
6
|
|
9
7
|
## Installation
|
8
|
+
|
10
9
|
`Jekyll_plugin_support` can be used to create simple Jekyll plugins in the `_plugins/` directory, or gem-based Jekyll plugins.
|
11
10
|
|
12
|
-
### Simple
|
13
|
-
|
11
|
+
### Simple Plugins
|
12
|
+
|
13
|
+
For jekyll plugins defined in the `_plugins/` directory,
|
14
|
+
add this line to your Jekyll plugin's `Gemfile`:
|
14
15
|
|
15
16
|
```ruby
|
16
17
|
group :jekyll_plugins do
|
@@ -20,10 +21,13 @@ end
|
|
20
21
|
|
21
22
|
And then execute:
|
22
23
|
|
23
|
-
|
24
|
+
```shell
|
25
|
+
$ bundle
|
26
|
+
```
|
24
27
|
|
25
28
|
|
26
29
|
### Gem-Based Plugins
|
30
|
+
|
27
31
|
Add this line to your Jekyll plugin's `.gemspec`:
|
28
32
|
|
29
33
|
```ruby
|
@@ -32,16 +36,20 @@ spec.add_dependency 'jekyll_plugin_support'
|
|
32
36
|
|
33
37
|
And then execute:
|
34
38
|
|
35
|
-
|
39
|
+
```shell
|
40
|
+
$ bundle
|
41
|
+
```
|
36
42
|
|
37
43
|
|
38
44
|
## General Usage
|
45
|
+
|
39
46
|
`JekyllSupport::JekyllBlock` and `JekyllSupport::JekyllTag`
|
40
47
|
provide support for Jekyll tag blocks and Jekyll tags, respectively.
|
41
48
|
They are very similar in construction and usage.
|
42
49
|
|
43
50
|
Instead of subclassing your Jekyll block tag class from `Liquid::Block`,
|
44
51
|
subclass from `JekyllSupport::JekyllBlock` instead.
|
52
|
+
|
45
53
|
Similarly, instead of subclassing your Jekyll tag class from `Liquid::Tag`,
|
46
54
|
subclass from `JekyllSupport::JekyllTag` instead.
|
47
55
|
|
@@ -64,6 +72,7 @@ Your implementation of `render_impl` can access `@page` and `@site`,
|
|
64
72
|
and can parse parameters passed to the tag / block tag, [as described here](https://mslinn.com/jekyll/10100-jekyll-plugin-background.html#params):
|
65
73
|
|
66
74
|
### For a tag:
|
75
|
+
|
67
76
|
```ruby
|
68
77
|
require 'jekyll_plugin_support'
|
69
78
|
|
@@ -84,6 +93,7 @@ end
|
|
84
93
|
```
|
85
94
|
|
86
95
|
### For a tag block:
|
96
|
+
|
87
97
|
```ruby
|
88
98
|
require 'jekyll_plugin_support'
|
89
99
|
|
@@ -116,6 +126,7 @@ end
|
|
116
126
|
```
|
117
127
|
|
118
128
|
Then your plugin can incorporate the `VERSION` constant into your plugin like this:
|
129
|
+
|
119
130
|
```ruby
|
120
131
|
require 'jekyll_plugin_support'
|
121
132
|
require_relative 'my_block/version'
|
@@ -139,6 +150,7 @@ end
|
|
139
150
|
```
|
140
151
|
|
141
152
|
### Argument Parsing
|
153
|
+
|
142
154
|
Tag arguments can be obtained within `render_impl`.
|
143
155
|
Both keyword options and name/value parameters are supported.
|
144
156
|
|
@@ -167,42 +179,45 @@ The `demo/_plugins/demo_tag.rb` plugin uses `@helper.parameter_specified?` provi
|
|
167
179
|
`jekyll_support_plugin` to parse the string passed to the tag, which is
|
168
180
|
`keyword1 name1='value1' unreferenced_key unreferenced_name="unreferenced_value"`.
|
169
181
|
|
170
|
-
|
182
|
+
* Because `keyword1` was referenced by `@helper.parameter_specified?` above,
|
171
183
|
that keyword option is removed from the argument string.
|
172
|
-
|
184
|
+
* Because the `name1` key/value parameter was referenced by `@helper.parameter_specified?` above,
|
173
185
|
that name/value pair is removed from the argument string.
|
174
|
-
|
186
|
+
* The remainder of the argument string is now `unreferenced_key unreferenced_name="unreferenced_value"`.
|
175
187
|
|
176
188
|
Name/value parameters can be quoted; if the value consists of only one token then it does not need to be quoted.
|
177
189
|
The following name/value parameters all have the same result:
|
178
190
|
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
191
|
+
* `pay_tuesday="true"`
|
192
|
+
* `pay_tuesday='true'`
|
193
|
+
* `pay_tuesday=true`
|
194
|
+
* `pay_tuesday`
|
183
195
|
|
184
196
|
The following also have the same result, however note that because the value has more than one token, quotes must be used:
|
185
197
|
|
186
|
-
|
187
|
-
|
198
|
+
* `pay_tuesday="maybe not"`
|
199
|
+
* `pay_tuesday='maybe not'`
|
188
200
|
|
189
201
|
#### Remaining Markup
|
202
|
+
|
190
203
|
After your plugin has parsed all the keyword options and name/value parameters,
|
191
204
|
call `@helper.remaining_markup` to obtain the remaining markup that was passed to your plugin.
|
192
205
|
|
193
206
|
|
194
207
|
### `no_arg_parsing` Optimization
|
208
|
+
|
195
209
|
If your tag or block plugin only needs access to the raw arguments passed from the web page,
|
196
210
|
without tokenization, and you expect that the plugin might be invoked with large amounts of text,
|
197
211
|
derive your plugin from `JekyllBlockNoArgParsing` or `JekyllTagNoArgParsing`.
|
198
212
|
|
199
213
|
|
200
214
|
## Subclass Attribution
|
215
|
+
|
201
216
|
`JekyllTag` and `JekyllBlock` subclasses of `jekyll_plugin_support` can utilize the `attribution` option IFF they are published as a gem.
|
202
217
|
`JekyllTagNoArgParsing` and `JekyllBlockNoArgParsing` subclasses cannot.
|
203
218
|
|
204
|
-
|
205
|
-
|
219
|
+
* When used as a keyword option, a default value is used for the attribution string.
|
220
|
+
* When used as a name/value option, the attribution string can be specified.
|
206
221
|
|
207
222
|
Using the `attribution` option cause subclasses to replace their usual output with HTML that looks like:
|
208
223
|
|
@@ -218,9 +233,10 @@ The `id` attribute is in the sample HTML above is randomized so more than one at
|
|
218
233
|
|
219
234
|
|
220
235
|
### Usage
|
236
|
+
|
221
237
|
Typical usage for the `attribution` tag is:
|
222
238
|
|
223
|
-
```
|
239
|
+
```html
|
224
240
|
{% my_tag attribution %}
|
225
241
|
```
|
226
242
|
|
@@ -239,14 +255,17 @@ The `date` property is obtained from the plugin/gem publishing date.
|
|
239
255
|
|
240
256
|
An alternative attribution string can be specified properties can be output using any of the above properties:
|
241
257
|
|
242
|
-
```
|
258
|
+
```html
|
243
259
|
{% my_tag attribution="Generated by the #{name} #{version} Jekyll plugin, written by #{author} #{date}" %}
|
244
260
|
```
|
245
261
|
|
246
262
|
### Attribution Generation
|
247
|
-
You can decide where you want the attribution string for your Jekyll tag to appear by invoking `@helper.attribute`. For example, this is how the [`jekyll_outline` tag](https://github.com/mslinn/jekyll_outline/blob/v1.1.1/lib/outline_tag.rb#L32-L46) generates output:
|
248
263
|
|
249
|
-
|
264
|
+
You can decide where you want the attribution string for your Jekyll tag to appear by invoking `@helper.attribute`.
|
265
|
+
For example, this is how the
|
266
|
+
[`jekyll_outline` tag](https://github.com/mslinn/jekyll_outline/blob/v1.1.1/lib/outline_tag.rb#L32-L46) generates output:
|
267
|
+
|
268
|
+
```html
|
250
269
|
<<~HEREDOC
|
251
270
|
<div class="outer_posts">
|
252
271
|
#{make_entries(collection)&.join("\n")}
|
@@ -257,8 +276,9 @@ HEREDOC
|
|
257
276
|
|
258
277
|
|
259
278
|
## Additional Information
|
279
|
+
|
260
280
|
More information is available on
|
261
|
-
[Mike Slinn’s website](https://www.mslinn.com/
|
281
|
+
[Mike Slinn’s website](https://www.mslinn.com/jekyll_plugins/jekyll_plugin_support.html).
|
262
282
|
|
263
283
|
|
264
284
|
## Development
|
@@ -269,6 +289,7 @@ You can also run `bin/console` for an interactive prompt that will allow you to
|
|
269
289
|
|
270
290
|
|
271
291
|
To build and install this gem onto your local machine, run:
|
292
|
+
|
272
293
|
```shell
|
273
294
|
$ bundle exec rake install
|
274
295
|
jekyll_plugin_support 0.1.0 built to pkg/jekyll_plugin_support-0.1.0.gem.
|
@@ -276,6 +297,7 @@ jekyll_plugin_support (0.1.0) installed.
|
|
276
297
|
```
|
277
298
|
|
278
299
|
Examine the newly built gem:
|
300
|
+
|
279
301
|
```shell
|
280
302
|
$ gem info jekyll_plugin_support
|
281
303
|
|
@@ -293,39 +315,48 @@ jekyll_plugin_support (0.1.0)
|
|
293
315
|
|
294
316
|
|
295
317
|
## Demo
|
318
|
+
|
296
319
|
A demo / test website is provided in the `demo` directory.
|
297
320
|
It can be used to debug the plugin or to run freely.
|
298
321
|
|
299
322
|
### Run Freely
|
323
|
+
|
300
324
|
1. Run from the command line:
|
325
|
+
|
301
326
|
```shell
|
302
327
|
$ demo/_bin/debug -r
|
303
328
|
```
|
304
329
|
|
305
|
-
|
330
|
+
2. View the generated website at [`http://localhost:4444`](http://localhost:4444)
|
306
331
|
|
307
332
|
### Plugin Debugging
|
333
|
+
|
308
334
|
1. Set breakpoints in Visual Studio Code.
|
309
335
|
|
310
336
|
2. Initiate a debug session from the command line:
|
337
|
+
|
311
338
|
```shell
|
312
339
|
$ demo/_bin/debug
|
313
340
|
```
|
314
341
|
|
315
|
-
|
316
|
-
configuration called `Attach
|
342
|
+
3. Once the `Fast Debugger` signon appears, launch the Visual Studio Code launch
|
343
|
+
configuration called `Attach with rdbg`.
|
317
344
|
|
318
|
-
|
345
|
+
4. View the generated website at [`http://localhost:4444`](http://localhost:4444)
|
319
346
|
|
320
347
|
|
321
348
|
### Build and Push to RubyGems
|
349
|
+
|
322
350
|
To release a new version,
|
351
|
+
|
323
352
|
1. Update the version number in `version.rb`.
|
324
353
|
2. Commit all changes to git; if you don't the next step might fail with an unexplainable error message.
|
325
354
|
3. Run the following:
|
355
|
+
|
326
356
|
```shell
|
327
357
|
$ bundle exec rake release
|
328
358
|
```
|
359
|
+
|
329
360
|
The above creates a git tag for the version, commits the created tag,
|
330
361
|
and pushes the new `.gem` file to [RubyGems.org](https://rubygems.org).
|
331
362
|
|
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'colorator'
|
1
2
|
require 'jekyll'
|
2
3
|
require 'jekyll_plugin_logger'
|
3
4
|
require_relative 'jekyll_plugin_helper'
|
@@ -139,6 +140,15 @@ module JekyllSupport
|
|
139
140
|
@helper = JekyllPluginHelper.new(tag_name, argument_string, @logger, respond_to?(:no_arg_parsing))
|
140
141
|
end
|
141
142
|
|
143
|
+
def exit_without_stack_trace(error)
|
144
|
+
raise error
|
145
|
+
rescue StandardError => e
|
146
|
+
file, line_number, caller = e.backtrace[1].split(':')
|
147
|
+
caller = caller.tr('`', "'")
|
148
|
+
warn "#{self.class} died with a '#{error.message}' #{caller} on line #{line_number} of #{file}".red
|
149
|
+
exec "echo ''"
|
150
|
+
end
|
151
|
+
|
142
152
|
# @return line number where tag or block was found, relative to the start of the page
|
143
153
|
def jekyll_line_number
|
144
154
|
@page['front_matter'].count("\n") + @line_number
|
@@ -160,12 +170,11 @@ module JekyllSupport
|
|
160
170
|
@site = liquid_context.registers[:site]
|
161
171
|
|
162
172
|
@config = @site.config
|
163
|
-
@mode = @config['env']['JEKYLL_ENV']
|
173
|
+
@mode = @config['env'].key?('JEKYLL_ENV') ? @config['env']['JEKYLL_ENV'] : 'development'
|
164
174
|
|
165
175
|
render_impl
|
166
176
|
rescue StandardError => e
|
167
|
-
|
168
|
-
exit 3
|
177
|
+
exit_without_stack_trace(e)
|
169
178
|
end
|
170
179
|
|
171
180
|
# Jekyll plugins must override this method, not render, so their plugin can be tested more easily
|
@@ -0,0 +1,6 @@
|
|
1
|
+
example_id | status | run_time |
|
2
|
+
------------------------------------------------ | ------ | --------------- |
|
3
|
+
./spec/jekyll_plugin_helper_options_spec.rb[1:1] | passed | 0.00559 seconds |
|
4
|
+
./spec/jekyll_plugin_helper_options_spec.rb[1:2] | passed | 0.00583 seconds |
|
5
|
+
./spec/jekyll_plugin_helper_options_spec.rb[1:3] | passed | 0.00543 seconds |
|
6
|
+
./spec/jekyll_plugin_helper_options_spec.rb[1:4] | passed | 0.00157 seconds |
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll_plugin_support
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.1
|
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-
|
11
|
+
date: 2023-08-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: facets
|
@@ -88,6 +88,7 @@ files:
|
|
88
88
|
- lib/jekyll_plugin_support_spec_support.rb
|
89
89
|
- spec/jekyll_plugin_helper_options_spec.rb
|
90
90
|
- spec/spec_helper.rb
|
91
|
+
- spec/status_persistence.txt
|
91
92
|
homepage: https://www.mslinn.com/jekyll_plugins/jekyll_plugin_support.html
|
92
93
|
licenses:
|
93
94
|
- MIT
|
@@ -122,4 +123,5 @@ summary: Provides support for writing Jekyll plugins.
|
|
122
123
|
test_files:
|
123
124
|
- spec/jekyll_plugin_helper_options_spec.rb
|
124
125
|
- spec/spec_helper.rb
|
126
|
+
- spec/status_persistence.txt
|
125
127
|
...
|