jekyll_pre 1.4.1 → 1.4.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f765cdcaf2d5447e9e05c49f02aa47b59feba53ba9dab4133a05eaa35f415555
4
- data.tar.gz: 2b742223bfd91ce5dc8349a8dd5a09e8c678890dbb338a347ac2c463d3db9f1d
3
+ metadata.gz: c9c89dfed1bd63dfb97f8eea204a543d7ea06af6dca9f8b627b2bcf51ad0e65d
4
+ data.tar.gz: e81ee9721c99b5391d401c6a19fbbd2bca8371225b9cc2bf82ff3bfbcc4ab274
5
5
  SHA512:
6
- metadata.gz: f4c15e15ee8390c7c429ce94f5913063d16804a2a61be225d66d1186406995eeed6a326e16fe438efac8dcf266f2e649888aec4c3d581fc10217098d1cbea3b9
7
- data.tar.gz: 7ae60210e08f23519765d3c1064761838f448e4e04f4dd03f8965361b5243d0cbfa543665370b918bbc4e188c97a3ec96b400d884b7c543d39b1b722afffead5
6
+ metadata.gz: 79af8ae474c13a9ad92436e1c916f4b21269b2944fc41725f59976ca543da264ebe8fd669cfe9de119c7f882d138b860006dc70c328c7ad6a58c16c700987a53
7
+ data.tar.gz: 004b17970a50fbe7c9df57d47b38456b36d5786d831db067dba9be7d219fac72823768a63247013beffb02ba9c9a24faa2379323dcdb6e8d1fb08dd99e4c628b
data/.rubocop.yml CHANGED
@@ -7,15 +7,17 @@ require:
7
7
 
8
8
  AllCops:
9
9
  Exclude:
10
- - exe/**/*
10
+ - binstub/**/*
11
11
  - vendor/**/*
12
12
  - Gemfile*
13
13
  NewCops: enable
14
- TargetRubyVersion: 2.6
15
14
 
16
15
  Gemspec/DeprecatedAttributeAssignment:
17
16
  Enabled: false
18
17
 
18
+ Gemspec/RequiredRubyVersion:
19
+ Enabled: false
20
+
19
21
  Gemspec/RequireMFA:
20
22
  Enabled: false
21
23
 
data/CHANGELOG.md CHANGED
@@ -1,77 +1,132 @@
1
+ # Change Log
2
+
3
+ ## 1.4.3
4
+
5
+ * Added the `no_stderr` option, which discards any STDERR output.
6
+
7
+
8
+ ## 1.4.2
9
+
10
+ * Added missing `require` in `pre_tag_block.rb`.
11
+
12
+
1
13
  ## 1.4.1
2
- * Fixed problem that caused exec tag to no produce output.
14
+
15
+ * Fixed problem that caused exec tag to no produce output.
16
+
3
17
 
4
18
  ## 1.4.0
5
- * Added `dedent` option and config setting.
6
- * No longer dies when exec is passed an empty string, or a string with just whitespace.
19
+
20
+ * Added `dedent` option and config setting.
21
+ * No longer dies when exec is passed an empty string, or a string with just whitespace.
22
+
7
23
 
8
24
  ## 1.3.2
9
- * No longer strips leading spaces from exec result lines.
25
+
26
+ * No longer strips leading spaces from exec result lines.
27
+
10
28
 
11
29
  ## 1.3.1
12
- * Generates outer `div` with `jekyll_pre` class, like this:
13
- ```html
14
- <div class="jekyll_pre">
15
- ... HTML generated by previous versions of `pre` tag here
16
- </div>
17
- ```
18
- * Added `wrapper_class` and `wrapper_style` name/value options.
30
+
31
+ * Generates outer `div` with `jekyll_pre` class, like this:
32
+
33
+ ```html
34
+ <div class="jekyll_pre">
35
+ ... HTML generated by previous versions of `pre` tag here
36
+ </div>
37
+ ```
38
+
39
+ * Added `wrapper_class` and `wrapper_style` name/value options.
40
+
19
41
 
20
42
  ## 1.3.0
21
- * Updated to `jekyll_plugin_support` v0.6.0 for attribution support.
43
+
44
+ * Updated to `jekyll_plugin_support` v0.6.0 for attribution support.
45
+
22
46
 
23
47
  ## 1.2.5
24
- * Empty exec commands are detected and reported.
48
+
49
+ * Empty exec commands are detected and reported.
50
+
25
51
 
26
52
  ## 1.2.4
27
- * The `exec` tag now evaluates environment variables in the command before execution.
53
+
54
+ * The `exec` tag now evaluates environment variables in the command before execution.
55
+
28
56
 
29
57
  ## 1.2.3
30
- * Added `cd` option to `exec` tag.
58
+
59
+ * Added `cd` option to `exec` tag.
60
+
31
61
 
32
62
  ## 1.2.2
33
- * Added `exec` tag.
34
- * Demarked CSS for the `exec`, `noselect`, and `pre` tags in `demo/assets/css/style.css`
35
- within `/* Start of pre tag css */` and `/* End of pre tag css */`.
63
+
64
+ * Added `exec` tag.
65
+ * Demarked CSS for the `exec`, `noselect`, and `pre` tags in `demo/assets/css/style.css`
66
+ within `/* Start of pre tag css */` and `/* End of pre tag css */`.
67
+
36
68
 
37
69
  ## 1.2.1
38
- * Updated to `jekyll_plugin_support` v0.5.1 so the `noselect` tag is more efficient.
70
+
71
+ * Updated to `jekyll_plugin_support` v0.5.1 so the `noselect` tag is more efficient.
72
+
39
73
 
40
74
  ## 1.2.0
41
- * Updated to `jekyll_plugin_support` v0.5.0.
75
+
76
+ * Updated to `jekyll_plugin_support` v0.5.0.
77
+
42
78
 
43
79
  ## 1.1.7
44
- * Fixed `noselect` tag content handling.
80
+
81
+ * Fixed `noselect` tag content handling.
82
+
45
83
 
46
84
  ## 1.1.6
47
- * Added `jekyll_plugin_support` as a dependency.
85
+
86
+ * Added `jekyll_plugin_support` as a dependency.
87
+
48
88
 
49
89
  ## 1.1.5
50
- * Added `class` and `style` options to allow for specifying additional CSS classes and inline CSS
51
- * Added `clear` option to ensure no images overlap the pre output
90
+
91
+ * Added `class` and `style` options to allow for specifying additional CSS classes and inline CSS
92
+ * Added `clear` option to ensure no images overlap the pre output
93
+
52
94
 
53
95
  ## 1.1.4
54
- * Added `highlight` regex option
55
- * Now using `lib/jekyll_tag_helper.rb` to parse markup
96
+
97
+ * Added `highlight` regex option
98
+ * Now using `lib/jekyll_tag_helper.rb` to parse markup
99
+
56
100
 
57
101
  ## 1.1.3
58
- * Documented the `data-lt-active="false"` attribute.
59
- * Added the `dark` option, and [provided CSS](https://www.mslinn.com/blog/2020/10/03/jekyll-plugins.html#pre_css).
102
+
103
+ * Documented the `data-lt-active="false"` attribute.
104
+ * Added the `dark` option, and [provided CSS](https://www.mslinn.com/blog/2020/10/03/jekyll-plugins.html#pre_css).
105
+
60
106
 
61
107
  ## 1.1.2 / 2022-04-05
62
- * Updated to `jekyll_plugin_logger` v2.1.0
108
+
109
+ * Updated to `jekyll_plugin_logger` v2.1.0
110
+
63
111
 
64
112
  ## 1.1.1 / 2022-03-31
65
- * Added `numbered_line` CSS class for unselectable line numbers
113
+
114
+ * Added `numbered_line` CSS class for unselectable line numbers
115
+
66
116
 
67
117
  ## 1.1.0 / 2022-03-31
68
- * Added `number` option, which generates unselectable line numbers for contents
118
+
119
+ * Added `number` option, which generates unselectable line numbers for contents
120
+
69
121
 
70
122
  ## 1.0.0 / 2022-03-13
71
- * Made into a Ruby gem and published on RubyGems.org as [jekyll_pre](https://rubygems.org/gems/jekyll_pre).
72
- * `bin/attach` script added for debugging
73
- * Rubocop standards added
74
- * Proper versioning and CHANGELOG.md added
123
+
124
+ * Made into a Ruby gem and published on RubyGems.org as [jekyll_pre](https://rubygems.org/gems/jekyll_pre).
125
+ * `bin/attach` script added for debugging
126
+ * Rubocop standards added
127
+ * Proper versioning and CHANGELOG.md added
128
+
75
129
 
76
130
  ## 2020-12-29
77
- * Initial version published
131
+
132
+ * Initial version published
data/README.md CHANGED
@@ -1,65 +1,83 @@
1
- Jekyll_pre
2
- [![Gem Version](https://badge.fury.io/rb/jekyll_pre.svg)](https://badge.fury.io/rb/jekyll_pre)
3
- ===========
1
+ # Jekyll_pre [![Gem Version](https://badge.fury.io/rb/jekyll_pre.svg)](https://badge.fury.io/rb/jekyll_pre)
4
2
 
5
3
  This Jekyll plugin provides 3 new Liquid tags that work together:
6
4
 
7
- * A `pre` block tag that can be displayed various ways.
8
- ```
9
- {% pre [Options] [free text label] %}
10
- Contents of pre tag
11
- {% endpre %}
12
- ```
13
- `Options` are:
14
- - `class="class1 class2"` &ndash; Apply CSS classes
15
- - `clear` &ndash; Line break after floating HTML elements
16
- - `copyButton` &ndash; Generate a copy button
17
- - `dark` &ndash; Dark mode
18
- - `dedent` &ndash; Remove leading spaces common to all lines, like Ruby's <<~ squiggly heredoc (default is false)
19
- - `label='This is a label'` &ndash; Apply text above `pre` tag.
20
- The `label` parameter value can also be specified in free text.
21
- For example, the following produce the same results:
22
-
23
- - {% pre label="This is a label" %}<br>Contents of pre tag<br>{% endpre %}
24
-
25
- - {% pre This is a label %}<br>Contents of pre tag<br>{% endpre %}
26
- - `number` &ndash; Number the lines
27
- - `shell` &ndash; Equivalent to `label='Shell'`
28
- - `style` &ndash; Apply inline CSS styles
29
-
30
- The generated &lt;pre>&lt;/pre> tag has an `data-lt-active="false"` attribute, so [LanguageTool](https://forum.languagetool.org/t/avoid-spell-check-on-certain-html-inputs-manually/3944) does not check the spelling or grammar of the contents.
31
-
32
- * A `noselect` tag that can renders HTML content passed to it unselectable,
33
- and generates a <code>$</code> prompt if no content is provided.
34
- ```
35
- {% pre %}
36
- {% noselect [optional text string, defaults to $]%}Command
37
- {% noselect unselectable output goes here %}
38
- {% endpre %}
39
- ```
40
-
41
- * An `exec` tag that executes shell commands and incorporates the command and its output into the content of the `pre` tag.
42
- Environment variables are evaluated,
43
- output data is escaped, whitespace is condensed, and wrapped in the same `unselectable` class as does `unselectable`.
44
- ```
45
- {% exec [Options] [shell command] %}
46
- ```
47
- `Options` are:
48
-
49
- - `cd="relative/or/absolute/directory"` - Change to specified directory before executing shell command.
50
- Environment variables in the directory path will be expanded.
51
- - `die_if_nonzero` – Set `false` to treat non-zero return codes as non-fatal.
52
- Instead of terminating Jekyll with an error message,
53
- the message will be displayed as an error by the Jekyll logger,
54
- and a red message will appear in place of the result on the web page.
55
- - `die_if_error` – Set `false` to treat exceptions generated by this plugin as non-fatal.
56
- Instead of terminating Jekyll with an error message, the message will be displayed as an error by the Jekyll logger.
57
- - `no_escape` Do not HTML escape the result of running the shell command.
58
- - `no_strip` Do not remove leading and trailing whitespace from the result.
59
- - `wrapper_class` class applied to outer `div`.
60
- - `wrapper_style` style applied to outer `div`.
5
+ * A `pre` block tag that can be displayed various ways.
6
+
7
+ ```html
8
+ {% pre [Options] [free text label] %}
9
+ Contents of pre tag
10
+ {% endpre %}
11
+ ```
12
+
13
+ `Options` are:
14
+
15
+ - `class="class1 class2"` &ndash; Apply CSS classes
16
+ - `clear` &ndash; Line break after floating HTML elements
17
+ - `copyButton` &ndash; Generate a copy button
18
+ - `dark` &ndash; Dark mode
19
+ - `dedent` &ndash; Remove leading spaces common to all lines, like Ruby's <<~ squiggly heredoc (default is false)
20
+ - `label='This is a label'` &ndash; Apply text above `pre` tag.
21
+ The `label` parameter value can also be specified in free text.
22
+ For example, the following produce the same results:
23
+
24
+ - {% pre label="This is a label" %}<br>Contents of pre tag<br>{% endpre %}
25
+
26
+ - {% pre This is a label %}<br>Contents of pre tag<br>{% endpre %}
27
+ - `number` &ndash; Number the lines
28
+ - `shell` &ndash; Equivalent to `label='Shell'`
29
+ - `style` &ndash; Apply inline CSS styles
30
+
31
+ The generated &lt;pre>&lt;/pre> tag has an `data-lt-active="false"` attribute, so
32
+ [LanguageTool](https://forum.languagetool.org/t/avoid-spell-check-on-certain-html-inputs-manually/3944)
33
+ does not check the spelling or grammar of the contents.
34
+
35
+ * A `noselect` tag that can renders HTML content passed to it unselectable,
36
+ and generates a <code>$</code> prompt if no content is provided.
37
+
38
+ ```html
39
+ {% pre %}
40
+ {% noselect [optional text string, defaults to $]%}Command
41
+ {% noselect unselectable output goes here %}
42
+ {% endpre %}
43
+ ```
44
+
45
+ * An `exec` tag that executes shell commands and incorporates the command and its output into the content of the `pre` tag.
46
+ Environment variables are evaluated,
47
+ output data is escaped, whitespace is condensed, and wrapped in the same `unselectable` class as does `unselectable`.
48
+
49
+ ```html
50
+ {% exec [Options] [shell command] %}
51
+ ```
52
+
53
+ `Options` are:
54
+
55
+ - `cd="relative/or/absolute/directory"` - Change to specified directory before executing shell command.
56
+ Environment variables in the directory path will be expanded.
57
+ - `die_if_nonzero` Set `false` to treat non-zero return codes as non-fatal.
58
+ Instead of terminating Jekyll with an error message,
59
+ the message will be displayed as an error by the Jekyll logger,
60
+ and a red message will appear in place of the result on the web page.
61
+ - `die_if_error` – Set `false` to treat exceptions generated by this plugin as non-fatal.
62
+ Instead of terminating Jekyll with an error message, the message will be displayed as an error by the Jekyll logger.
63
+ - `no_escape` – Do not HTML escape the result of running the shell command.
64
+ - `no_stderr` - Discard STDERR output.
65
+ This is helpful for suppressing annoying `groff` error messages that are emitted when the `exec` subcommand runs `man`.
66
+ Use it like this:
67
+
68
+ ```html
69
+ {% pre copyButton dedent shell %}
70
+ {% noselect %}{% exec no_stderr man netplan %}
71
+ {% endpre %}
72
+ ```
73
+
74
+ - `no_strip` – Do not remove leading and trailing whitespace from the result.
75
+ - `wrapper_class` class applied to outer `div`.
76
+ - `wrapper_style` style applied to outer `div`.
77
+
61
78
 
62
79
  ## Keyword Options
80
+
63
81
  For all keyword options, including keyword options for the `pre` and `exec` tags:
64
82
 
65
83
  - Option values specified in the document *may* be provided.
@@ -70,19 +88,24 @@ For all keyword options, including keyword options for the `pre` and `exec` tags
70
88
  Values that do not contain special characters *may* be wrapped in single or double quotes.
71
89
 
72
90
  ### Examples
91
+
73
92
  #### Specifying Tag Option Values
93
+
74
94
  The following sets `die_if_error` `true`:
75
- ```
95
+
96
+ ```html
76
97
  {% pre die_if_error %} ... {% endpre %}
77
98
  ```
78
99
 
79
100
  The above is the same as writing:
80
- ```
101
+
102
+ ```html
81
103
  {% pre die_if_error='true' %} ... {% endpre %}
82
104
  ```
83
105
 
84
106
  Or writing:
85
- ```
107
+
108
+ ```html
86
109
  {% pre die_if_error="true" %} ... {% endpre %}
87
110
  ```
88
111
 
@@ -92,23 +115,27 @@ For the `pre` tag, this means the erroneous string becomes part of the `label` v
92
115
  For the `exec` tag, this means the erroneous string becomes part of the command to execute.
93
116
  The following demonstrates the error.
94
117
 
95
- ```
118
+ ```html
96
119
  {% pre die_if_error=false %} ... {% endpre %}
97
120
  ```
121
+
98
122
  The above causes the label to be `die_if_error=false`.
99
123
 
100
- ```
124
+ ```html
101
125
  {% exec die_if_error=false ls %} ... {% endpre %}
102
126
  ```
127
+
103
128
  The above causes the command to be executed to be `die_if_error=false ls` instead of `ls`.
104
129
 
105
130
 
106
131
  ## CSS
132
+
107
133
  See [`demo/assets/css/style.css`](demo/assets/css/style.css) for the CSS declarations,
108
134
  between `/* Start of pre tag css */` and `/* End of pre tag css */`.
109
135
 
110
136
 
111
137
  ## Configuration
138
+
112
139
  Default options can be set for the `pre` tag by entries in `_config.yml`.
113
140
  The following demonstrates setting a default value for every possible option:
114
141
 
@@ -137,8 +164,10 @@ pre:
137
164
  ```
138
165
 
139
166
 
140
- #### Specifying Default Option Values
167
+ ### Specifying Default Option Values
168
+
141
169
  Specifying a default value for `die_if_error` in `_config.yml` could be done as follows:
170
+
142
171
  ```yaml
143
172
  pre:
144
173
  die_if_error: true
@@ -156,6 +185,7 @@ pre:
156
185
 
157
186
 
158
187
  ## Additional Information
188
+
159
189
  More information is available on
160
190
  [Mike Slinn&rsquo;s website](https://www.mslinn.com/jekyll_plugins/jekyll_pre.html).
161
191
 
@@ -172,26 +202,33 @@ end
172
202
 
173
203
  And then execute:
174
204
 
175
- $ bundle
205
+ ```shell
206
+ $ bundle
207
+ ```
176
208
 
177
209
 
178
210
  ## Usage
211
+
179
212
  The following examples are rendered on
180
213
  [Mike Slinn&rsquo;s website](https://www.mslinn.com/jekyll_plugins/jekyll_pre.html).
181
214
 
182
215
  ### Example 0
216
+
183
217
  <pre data-lt-active="false" class="maxOneScreenHigh copyContainer" id="id110c50d624b4">{% pre dedent %}
184
218
  This line was indented 4 spaces
185
219
  This line was indented 6 spaces
186
220
  This line was indented 4 spaces
187
221
  {% endpre %}</pre>
222
+
188
223
  Which renders as:
189
224
 
190
225
  <pre data-lt-active="false" class="maxOneScreenHigh copyContainer" id="id377433c30186">This line was indented 4 spaces
191
226
  This line was indented 6 spaces
192
227
  This line was indented 4 spaces</pre>
193
228
 
229
+
194
230
  ### Example 1
231
+
195
232
  This example does not generate a copy button and does not demonstrate `noselect`.
196
233
  <pre data-lt-active="false" class="maxOneScreenHigh copyContainer" id="id110c50d624b4">{% pre %}
197
234
  Contents of pre tag
@@ -206,11 +243,12 @@ Which renders as:
206
243
 
207
244
 
208
245
  ### Example 2
246
+
209
247
  This example generates a copy button and does not demonstrate `noselect`.
210
248
 
211
- {% pre copyButton %}
212
- Contents of pre tag
213
- {% endpre %}
249
+ {% pre copyButton %}
250
+ Contents of pre tag
251
+ {% endpre %}
214
252
 
215
253
  Generates:
216
254
  <pre data-lt-active="false" class="maxOneScreenHigh copyContainer" id="id08a5d26db177">&lt;pre data-lt-active='false' class='maxOneScreenHigh copyContainer' id='id6a831a3e8992'&gt;&lt;button class='copyBtn' data-clipboard-target='#id6a831a3e8992' title='Copy to clipboard'&gt;&lt;img src='images/clippy.svg' alt='Copy to clipboard' style='width: 13px'&gt;&lt;/button&gt;Contents of pre tag&lt;/pre&gt;</pre>
@@ -220,8 +258,10 @@ Which renders as (note the clipboard icon at the far right):
220
258
 
221
259
 
222
260
  ### Example 3
261
+
223
262
  This example generates a copy button and does demonstrates the default usage of `noselect`, which renders an unselectable dollar sign followed by a space.
224
- ```
263
+
264
+ ```html
225
265
  {% pre copyButton %}
226
266
  {% noselect %}Contents of pre tag
227
267
  {% endpre %}
@@ -229,7 +269,7 @@ This example generates a copy button and does demonstrates the default usage of
229
269
 
230
270
  Generates:
231
271
 
232
- ```
272
+ ```html
233
273
  <pre data-lt-active='false' class='maxOneScreenHigh copyContainer' id='id1e4a8fe53480'><button class='copyBtn' data-clipboard-target='#id1e4a8fe53480' title='Copy to clipboard'><img src='/assets/images/clippy.svg' alt='Copy to clipboard' style='width: 13px'></button><span class='unselectable'>$ </span>Contents of pre tag</pre>
234
274
  ```
235
275
 
@@ -239,11 +279,12 @@ Which renders as:
239
279
 
240
280
 
241
281
  ### Example 4
282
+
242
283
  This example generates a copy button and does demonstrates the `noselect` being used twice:
243
284
  the first time to render an unselectable custom prompt,
244
285
  and the second time to render unselectable output.
245
286
 
246
- ```
287
+ ```html
247
288
  {% pre copyButton %}
248
289
  {% noselect &gt;&gt;&gt; %}Contents of pre tag
249
290
  {% noselect How now brown cow%}
@@ -251,7 +292,8 @@ and the second time to render unselectable output.
251
292
  ```
252
293
 
253
294
  Generates:
254
- ```
295
+
296
+ ```html
255
297
  <pre data-lt-active='false' class='maxOneScreenHigh copyContainer' id='idb58a6cf1761c'><button class='copyBtn' data-clipboard-target='#idb58a6cf1761c' title='Copy to clipboard'><img src='/assets/images/clippy.svg' alt='Copy to clipboard' style='width: 13px'></button><span class='unselectable'>>>> </span>contents of pre tag
256
298
  <span class='unselectable'>How now brown cow</span></pre>
257
299
  ```
@@ -262,6 +304,7 @@ Which renders as:
262
304
 
263
305
 
264
306
  ### Example 5
307
+
265
308
  A regular expression can be passed to the `highlight` option.
266
309
  This causes text that matches the regex pattern to be wrapped within a &lt;span class="bg_yellow">&lt;/span> tag.
267
310
 
@@ -274,9 +317,11 @@ The CSS stylesheet used for this page contains the following:
274
317
  }
275
318
  ```
276
319
 
277
- This example demonstrates highlighting text that matches a regular expression. Regular expressions match against lines, which are delimited via newlines (\n).
320
+ This example demonstrates highlighting text that matches a regular expression.
321
+ Regular expressions match against lines,
322
+ which are delimited via newlines (\n).
278
323
 
279
- ```
324
+ ```html
280
325
  {% pre copyButton highlight="Line 2" %}
281
326
  Line 1
282
327
  Line 2
@@ -290,11 +335,12 @@ Line 7
290
335
 
291
336
 
292
337
  ### Example 6
338
+
293
339
  Regular expressions match against lines, which are delimited via newlines (`\n`).
294
340
  Thus to match an entire line that contains a phrase, specify the regex as `.*phrase.*`.
295
341
  The following matches 3 possible phrases (`2`, `4` or `6`), then selects the entire line if matched.
296
342
 
297
- ```
343
+ ```html
298
344
  {% pre copyButton highlight=".*(2|4|6).*" %}
299
345
  Line 1
300
346
  Line 2
@@ -308,10 +354,11 @@ Line 7
308
354
 
309
355
 
310
356
  ### Example 7
357
+
311
358
  This example floats an image to the right.
312
359
  The `jekyll_pre plugin`’s `clear` option moves the generated HTML below the image.
313
360
 
314
- ```
361
+ ```html
315
362
  &lt;img src="jekyll.webp" style="float: right; width: 100px; height: auto;">
316
363
  {% pre clear copyButton label='Clear example' %}
317
364
  Using clear, copyButton and label parameters
@@ -319,27 +366,30 @@ Using clear, copyButton and label parameters
319
366
  ```
320
367
 
321
368
  ### Example 8
369
+
322
370
  The following executes `ls -alF /` and displays the output.
323
371
 
324
- ```
372
+ ```html
325
373
  {% pre clear copyButton label='Exec without error' %}
326
374
  {% noselect %}{% exec die_if_nonzero='false' ls -alF / %}
327
375
  {% endpre %}
328
376
  ```
329
377
 
330
378
  ### Example 9
379
+
331
380
  The following changes to the home directory (`$HOME`), then executes `pwd` and displays the output.
332
381
 
333
- ```
382
+ ```html
334
383
  {% pre clear copyButton label='Exec without error' %}
335
384
  {% noselect %}{% exec cd="$HOME" die_if_nonzero='false' pwd %}
336
385
  {% endpre %}
337
386
  ```
338
387
 
339
388
  ### Example 10
389
+
340
390
  The following executes `echo $USER` and displays the output.
341
391
 
342
- ```
392
+ ```html
343
393
  {% pre clear copyButton label='Exec display &dollar;USER' %}
344
394
  {% noselect %}{% exec die_if_nonzero='false' echo $USER %}
345
395
  {% endpre %}
@@ -347,10 +397,11 @@ The following executes `echo $USER` and displays the output.
347
397
 
348
398
 
349
399
  ### Comprehensive Example
400
+
350
401
  The code I wrote to generate the above CSS was a good example of how the plugins work together with
351
402
  the `from` and `to` tags from my [`from_to_until`](https://github.com/mslinn/jekyll_from_to_until) plugin:
352
403
 
353
- ```
404
+ ```html
354
405
  {% capture css %}{% flexible_include '_sass/mystyle.scss' %}{% endcapture %}
355
406
  {% pre copyButton %}{{ css | from: '.copyBtn' | to: '^$' | strip }}
356
407
 
@@ -371,20 +422,22 @@ You can also run `bin/console` for an interactive prompt that will allow you to
371
422
 
372
423
 
373
424
  ## Test
425
+
374
426
  A test website is provided in the `demo` directory.
375
- 1. Set breakpoints.
376
427
 
377
- 2. Initiate a debug session from the command line:
378
- ```shell
379
- $ bin/attach demo
380
- ```
428
+ 1. Set breakpoints.
429
+ 2. Initiate a debug session from the command line:
381
430
 
382
- 3. Once the `Fast Debugger` signon appears, launch the Visual Studio Code launch configuration called `Attach rdebug-ide`.
431
+ ```shell
432
+ $ bin/attach demo
433
+ ```
383
434
 
384
- 4. View the generated website at [`http://localhost:4444`](http://localhost:4444)
435
+ 3. Once the `Fast Debugger` signon appears, launch the Visual Studio Code launch configuration called `Attach rdebug-ide`.
436
+ 4. View the generated website at [`http://localhost:4444`](http://localhost:4444)
385
437
 
386
438
 
387
439
  ### Build and Install Locally
440
+
388
441
  To build and install this gem onto your local machine, run:
389
442
 
390
443
  ```shell
@@ -392,6 +445,7 @@ $ bundle exec rake install
392
445
  ```
393
446
 
394
447
  Examine the newly built gem:
448
+
395
449
  ```shell
396
450
  $ gem info jekyll_pre
397
451
 
@@ -409,18 +463,23 @@ jekyll_pre (1.0.0)
409
463
 
410
464
 
411
465
  ### Build and Push to RubyGems
466
+
412
467
  To release a new version,
468
+
413
469
  1. Update the version number in `version.rb`.
414
470
  2. Commit all changes to git; if you don't the next step might fail with an unexplainable error message.
415
471
  3. Run the following:
472
+
416
473
  ```shell
417
474
  $ bundle exec rake release
418
475
  ```
476
+
419
477
  The above creates a git tag for the version, commits the created tag,
420
478
  and pushes the new `.gem` file to [RubyGems.org](https://rubygems.org).
421
479
 
422
480
 
423
481
  ## Contributing
482
+
424
483
  1. Fork the project
425
484
  2. Create a descriptively named feature branch
426
485
  3. Add your feature
data/lib/exec_tag.rb CHANGED
@@ -77,31 +77,44 @@ module JekyllPreModule
77
77
 
78
78
  @no_escape = @helper.parameter_specified? 'no_escape'
79
79
  @no_strip = @helper.parameter_specified? 'no_strip'
80
+ @no_stderr = @helper.parameter_specified? 'no_stderr'
80
81
  @die_if_nonzero = @helper.parameter_specified?('die_if_nonzero') # Implies die_if_error
81
82
  @die_if_error = @helper.parameter_specified?('die_if_error') | @die_if_nonzero
82
83
  end
83
84
 
84
85
  # References @cd
85
86
  # Defines @child_status
87
+ # Ignores stderr output
86
88
  # @return result of running command
87
89
  # @param command [String] Shell command to execute
88
90
  def run_command(command)
89
- result = if @cd
90
- Dir.chdir(@cd) do
91
- `#{command}`
92
- end
93
- else
94
- `#{command}`
95
- end
96
- @child_status = $CHILD_STATUS
97
- result
91
+ stdout_str = ''
92
+ stderr_str = ''
93
+ if @cd
94
+ Dir.chdir(@cd) do
95
+ @logger.debug { "Executing '#{command}' from '#{@cd}'" }
96
+ stdout_str, stderr_str, @child_status = Open3.capture3 command
97
+ end
98
+ else
99
+ @logger.debug { "Executing '#{command}'" }
100
+ stdout_str, stderr_str, @child_status = Open3.capture3 command
101
+ end
102
+ unless @no_stderr
103
+ stderr_str.strip!
104
+ unless stderr_str.empty?
105
+ @logger.info do
106
+ "'#{command}' STDERR=#{stderr_str}\nThe exec subcommand's 'no_stderr' option suppresses this message."
107
+ end
108
+ end
109
+ end
110
+ stdout_str
98
111
  rescue StandardError => e
99
112
  msg = self.class.remove_html_tags(e.message) +
100
113
  " from executing '#{@original_command}' on line #{@line_number} (after front matter) of #{@page['path']}"
101
114
  raise PreError, msg.red, [] if @die_if_error
102
115
  ensure
103
116
  @child_status = $CHILD_STATUS
104
- result
117
+ stdout_str
105
118
  end
106
119
 
107
120
  JekyllPluginHelper.register(self, 'exec')
@@ -1,3 +1,3 @@
1
1
  module JekyllPreVersion
2
- VERSION = '1.4.1'.freeze
2
+ VERSION = '1.4.3'.freeze
3
3
  end
data/lib/pre_tag_block.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require 'jekyll_plugin_support'
2
+ require 'securerandom'
2
3
  require_relative 'jekyll_pre/version'
3
4
 
4
5
  module JekyllPreModule
data/spec/spec_helper.rb CHANGED
@@ -10,9 +10,8 @@ require_relative '../lib/jekyll_pre'
10
10
  Jekyll.logger.log_level = :info
11
11
 
12
12
  RSpec.configure do |config|
13
- config.filter_run :focus
13
+ config.filter_run_when_matching focus: true
14
14
  # config.order = 'random'
15
- config.run_all_when_everything_filtered = true
16
15
 
17
16
  # See https://relishapp.com/rspec/rspec-core/docs/command-line/only-failures
18
17
  config.example_status_persistence_file_path = 'spec/status_persistence.txt'
@@ -1,13 +1,8 @@
1
- example_id | status | run_time |
2
- --------------------------------------------------------------- | ------ | --------------- |
3
- ./spec/exec_spec.rb[1:1] | passed | 0.00377 seconds |
4
- ./spec/pre_spec.rb[1:1] | passed | 0.00014 seconds |
5
- ./spec/pre_spec.rb[1:2] | passed | 0.00351 seconds |
6
- ./spec/pre_spec.rb[1:3] | passed | 0.00016 seconds |
7
- ./spec/pre_spec.rb[1:4] | passed | 0.00011 seconds |
8
- /mnt/_/work/jekyll/my_plugins/jekyll_pre/spec/exec_spec.rb[1:1] | passed | 0.00457 seconds |
9
- /mnt/_/work/jekyll/my_plugins/jekyll_pre/spec/pre_spec.rb[1:1] | passed | 0.00326 seconds |
10
- /mnt/_/work/jekyll/my_plugins/jekyll_pre/spec/pre_spec.rb[1:2] | passed | 0.00067 seconds |
11
- /mnt/_/work/jekyll/my_plugins/jekyll_pre/spec/pre_spec.rb[1:3] | passed | 0.00362 seconds |
12
- /mnt/_/work/jekyll/my_plugins/jekyll_pre/spec/pre_spec.rb[1:4] | passed | 0.00033 seconds |
13
- /mnt/_/work/jekyll/my_plugins/jekyll_pre/spec/pre_spec.rb[1:5] | passed | 0.00083 seconds |
1
+ example_id | status | run_time |
2
+ ------------------------ | ------ | --------------- |
3
+ ./spec/exec_spec.rb[1:1] | passed | 0.00133 seconds |
4
+ ./spec/pre_spec.rb[1:1] | passed | 0.00007 seconds |
5
+ ./spec/pre_spec.rb[1:2] | passed | 0.00003 seconds |
6
+ ./spec/pre_spec.rb[1:3] | passed | 0.00133 seconds |
7
+ ./spec/pre_spec.rb[1:4] | passed | 0.00005 seconds |
8
+ ./spec/pre_spec.rb[1:5] | passed | 0.00004 seconds |
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll_pre
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.1
4
+ version: 1.4.3
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-06-25 00:00:00.000000000 Z
11
+ date: 2023-12-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll
@@ -104,7 +104,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
104
104
  - !ruby/object:Gem::Version
105
105
  version: '0'
106
106
  requirements: []
107
- rubygems_version: 3.3.3
107
+ rubygems_version: 3.3.7
108
108
  signing_key:
109
109
  specification_version: 4
110
110
  summary: Jekyll tags pre and noselect, for HTML <pre/> tag, prompts and unselectable