jekyll_pre 1.2.4 → 1.3.1
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/.rubocop.yml +3 -2
- data/CHANGELOG.md +15 -0
- data/README.md +4 -2
- data/jekyll_pre.gemspec +2 -2
- data/lib/exec_tag.rb +7 -3
- data/lib/jekyll_pre/version.rb +1 -1
- data/lib/pre_tag_block.rb +48 -33
- metadata +6 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 16aa76dad7fdc41eac063227ee8463e9bcb77dd1c9893840e05f22a67c08aef0
|
4
|
+
data.tar.gz: 9e550133932e9b422a30bdccb813dd0c603870bac9bbb08489256a92be9d27ce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8f87a17e7dff740d917a248323822a491559ac3bc3223ca4af7a62c261ca213be8f82f61577b7278112534b0ed5af597f01242fba0ba9adb9158a27425893ffa
|
7
|
+
data.tar.gz: 1227a44360aae2c913a005223c28e0ef1f3a788e43e7acb0973f960fbc618846d587754e9944f15884f184f73b9ed2bd913eeedc1273ee186e694deef31e5fc5
|
data/.rubocop.yml
CHANGED
@@ -20,13 +20,14 @@ Gemspec/RequireMFA:
|
|
20
20
|
Enabled: false
|
21
21
|
|
22
22
|
Layout/HashAlignment:
|
23
|
-
|
23
|
+
EnforcedColonStyle: table
|
24
|
+
EnforcedHashRocketStyle: table
|
24
25
|
|
25
26
|
Layout/LineLength:
|
26
27
|
Max: 150
|
27
28
|
|
28
29
|
Metrics/AbcSize:
|
29
|
-
Max:
|
30
|
+
Max: 35
|
30
31
|
|
31
32
|
Metrics/BlockLength:
|
32
33
|
Exclude:
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,18 @@
|
|
1
|
+
## 1.3.1
|
2
|
+
* Generates outer `div` with `jekyll_pre` class, like this:
|
3
|
+
```html
|
4
|
+
<div class="jekyll_pre">
|
5
|
+
... HTML generated by previous versions of `pre` tag here
|
6
|
+
</div>
|
7
|
+
```
|
8
|
+
* Added `wrapper_class` and `wrapper_style` name/value options.
|
9
|
+
|
10
|
+
## 1.3.0
|
11
|
+
* Updated to `jekyll_plugin_support` v0.6.0 for attribution support.
|
12
|
+
|
13
|
+
## 1.2.5
|
14
|
+
* Empty exec commands are detected and reported.
|
15
|
+
|
1
16
|
## 1.2.4
|
2
17
|
* The `exec` tag now evaluates environment variables in the command before execution.
|
3
18
|
|
data/README.md
CHANGED
@@ -47,14 +47,16 @@ This Jekyll plugin provides 3 new Liquid tags that work together:
|
|
47
47
|
|
48
48
|
- `cd="relative/or/absolute/directory"` - Change to specified directory before executing shell command.
|
49
49
|
Environment variables in the directory path will be expanded.
|
50
|
-
- `no_escape` – Do not HTML escape the result of running the shell command.
|
51
|
-
- `no_strip` – Do not remove leading and trailing whitespace from the result.
|
52
50
|
- `die_if_nonzero` – Set `false` to treat non-zero return codes as non-fatal.
|
53
51
|
Instead of terminating Jekyll with an error message,
|
54
52
|
the message will be displayed as an error by the Jekyll logger,
|
55
53
|
and a red message will appear in place of the result on the web page.
|
56
54
|
- `die_if_error` – Set `false` to treat exceptions generated by this plugin as non-fatal.
|
57
55
|
Instead of terminating Jekyll with an error message, the message will be displayed as an error by the Jekyll logger.
|
56
|
+
- `no_escape` – Do not HTML escape the result of running the shell command.
|
57
|
+
- `no_strip` – Do not remove leading and trailing whitespace from the result.
|
58
|
+
- `wrapper_class` class applied to outer `div`.
|
59
|
+
- `wrapper_style` style applied to outer `div`.
|
58
60
|
|
59
61
|
|
60
62
|
## CSS
|
data/jekyll_pre.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
|
|
10
10
|
END_OF_DESC
|
11
11
|
spec.email = ['mslinn@mslinn.com']
|
12
12
|
spec.files = Dir['.rubocop.yml', 'LICENSE.*', 'Rakefile', '{lib,spec}/**/*', '*.gemspec', '*.md']
|
13
|
-
spec.homepage = 'https://www.mslinn.com/
|
13
|
+
spec.homepage = 'https://www.mslinn.com/jekyll/3000-jekyll-plugins.html#jekyll_pre'
|
14
14
|
spec.license = 'MIT'
|
15
15
|
spec.metadata = {
|
16
16
|
'allowed_push_host' => 'https://rubygems.org',
|
@@ -32,5 +32,5 @@ Gem::Specification.new do |spec|
|
|
32
32
|
spec.version = JekyllPreVersion::VERSION
|
33
33
|
|
34
34
|
spec.add_dependency 'jekyll', '>= 3.5.0'
|
35
|
-
spec.add_dependency 'jekyll_plugin_support', '~> 0.
|
35
|
+
spec.add_dependency 'jekyll_plugin_support', '~> 0.6.0'
|
36
36
|
end
|
data/lib/exec_tag.rb
CHANGED
@@ -12,7 +12,9 @@ module ExecTag
|
|
12
12
|
def render_impl
|
13
13
|
parse_args
|
14
14
|
@original_command = @helper.remaining_markup_original
|
15
|
-
command = JekyllPluginHelper.expand_env
|
15
|
+
command = JekyllPluginHelper.expand_env @original_command
|
16
|
+
raise PreError, "Command is empty on on line #{@line_number} (after front matter) of #{@page['path']}", [] if command.strip.empty?
|
17
|
+
|
16
18
|
response = run_command(command)
|
17
19
|
response = if @child_status.success?
|
18
20
|
compress(response)
|
@@ -27,7 +29,8 @@ module ExecTag
|
|
27
29
|
rescue PreError => e
|
28
30
|
raise PreError, e.message, []
|
29
31
|
rescue StandardError => e
|
30
|
-
msg = self.class.remove_html_tags(e.message) +
|
32
|
+
msg = self.class.remove_html_tags(e.message) +
|
33
|
+
" from executing '#{@original_command}' on line #{@line_number} (after front matter) of #{@page['path']}"
|
31
34
|
raise PreError, msg.red, [] if @die_if_error
|
32
35
|
end
|
33
36
|
|
@@ -85,7 +88,8 @@ module ExecTag
|
|
85
88
|
@child_status = $CHILD_STATUS
|
86
89
|
result
|
87
90
|
rescue StandardError => e
|
88
|
-
msg = self.class.remove_html_tags(e.message) +
|
91
|
+
msg = self.class.remove_html_tags(e.message) +
|
92
|
+
" from executing '#{@original_command}' on line #{@line_number} (after front matter) of #{@page['path']}"
|
89
93
|
raise PreError, msg.red, [] if @die_if_error
|
90
94
|
ensure
|
91
95
|
@child_status = $CHILD_STATUS
|
data/lib/jekyll_pre/version.rb
CHANGED
data/lib/pre_tag_block.rb
CHANGED
@@ -17,35 +17,6 @@ module PreTagBlock
|
|
17
17
|
"#{@@prefix}'##{pre_id}'#{@@suffix}"
|
18
18
|
end
|
19
19
|
|
20
|
-
def self.make_pre(make_copy_button, number_lines, label, dark, highlight_pattern, css_class, style, clear, content) # rubocop:disable Metrics/ParameterLists
|
21
|
-
pre_clear = label_clear = ''
|
22
|
-
if clear
|
23
|
-
if label.to_s.empty?
|
24
|
-
pre_clear = ' clear'
|
25
|
-
else
|
26
|
-
label_clear = ' clear'
|
27
|
-
end
|
28
|
-
end
|
29
|
-
css_class = css_class ? " #{css_class}" : ''
|
30
|
-
style = style ? " style='#{style}'" : ''
|
31
|
-
dark_label = ' darkLabel' if dark
|
32
|
-
label = if label.to_s.empty?
|
33
|
-
''
|
34
|
-
elsif label.to_s.downcase.strip == 'shell'
|
35
|
-
"<div class='codeLabel unselectable#{dark_label}#{label_clear}' data-lt-active='false'>Shell</div>"
|
36
|
-
else
|
37
|
-
"<div class='codeLabel unselectable#{dark_label}#{label_clear}' data-lt-active='false'>#{label}</div>"
|
38
|
-
end
|
39
|
-
pre_id = "id#{SecureRandom.hex(6)}"
|
40
|
-
copy_button = make_copy_button ? PreTagBlock.make_copy_button(pre_id) : ''
|
41
|
-
content = PreTagBlock.highlight(content, highlight_pattern) if highlight_pattern
|
42
|
-
content = PreTagBlock.number_content(content) if number_lines
|
43
|
-
|
44
|
-
classes = "maxOneScreenHigh copyContainer#{dark}#{pre_clear}#{css_class}"
|
45
|
-
pre_content = "#{copy_button}#{content.strip}"
|
46
|
-
"#{label}<pre data-lt-active='false' class='#{classes}'#{style} id='#{pre_id}'>#{pre_content}</pre>"
|
47
|
-
end
|
48
|
-
|
49
20
|
def self.number_content(content)
|
50
21
|
lines = content.split("\n")
|
51
22
|
digits = lines.length.to_s.length
|
@@ -62,21 +33,65 @@ module PreTagBlock
|
|
62
33
|
|
63
34
|
def render_impl(text)
|
64
35
|
text.strip!
|
36
|
+
@helper.gem_file __FILE__ # Enables plugin attribution
|
65
37
|
|
66
|
-
@clear = @helper.parameter_specified? 'clear'
|
67
38
|
@class = @helper.parameter_specified? 'class'
|
39
|
+
@clear = @helper.parameter_specified? 'clear'
|
40
|
+
@dark = ' dark' if @helper.parameter_specified? 'dark'
|
68
41
|
@highlight = @helper.parameter_specified? 'highlight'
|
42
|
+
@label = @helper.parameter_specified? 'label'
|
69
43
|
@make_copy_button = @helper.parameter_specified? 'copyButton'
|
70
44
|
@number_lines = @helper.parameter_specified? 'number'
|
71
|
-
@dark = ' dark' if @helper.parameter_specified? 'dark'
|
72
45
|
@style = @helper.parameter_specified? 'style'
|
73
|
-
@
|
46
|
+
@wrapper_class = @helper.parameter_specified? 'wrapper_class'
|
47
|
+
@wrapper_style = @helper.parameter_specified? 'wrapper_style'
|
48
|
+
|
49
|
+
@class = @class ? " #{@class}" : ''
|
50
|
+
@style = @style ? " style='#{@style}'" : ''
|
51
|
+
@wrapper_class = @wrapper_class ? " #{@wrapper_class}" : ''
|
52
|
+
@wrapper_style = @wrapper_style ? " style='#{@wrapper_style}'" : ''
|
74
53
|
|
75
54
|
# If a label was specified, use it, otherwise concatenate any dangling parameters and use that as the label
|
76
55
|
@label ||= @helper.argv.join(' ')
|
77
56
|
|
78
57
|
@logger.debug { "@make_copy_button = '#{@make_copy_button}'; @label = '#{@label}'" }
|
79
|
-
|
58
|
+
make_pre(text)
|
59
|
+
end
|
60
|
+
|
61
|
+
private
|
62
|
+
|
63
|
+
def make_pre(content)
|
64
|
+
pre_clear = label_clear = ''
|
65
|
+
if @clear
|
66
|
+
if @label.to_s.empty?
|
67
|
+
pre_clear = ' clear'
|
68
|
+
else
|
69
|
+
label_clear = ' clear'
|
70
|
+
end
|
71
|
+
end
|
72
|
+
dark_label = ' darkLabel' if @dark
|
73
|
+
@label = if @label.to_s.empty?
|
74
|
+
''
|
75
|
+
elsif @label.to_s.casecmp('shell').zero?
|
76
|
+
"<div class='codeLabel unselectable#{dark_label}#{label_clear}' data-lt-active='false'>Shell</div>"
|
77
|
+
else
|
78
|
+
"<div class='codeLabel unselectable#{dark_label}#{label_clear}' data-lt-active='false'>#{@label}</div>"
|
79
|
+
end
|
80
|
+
pre_id = "id#{SecureRandom.hex(6)}"
|
81
|
+
copy_button = @make_copy_button ? PreTagBlock.make_copy_button(pre_id) : ''
|
82
|
+
content = PreTagBlock.highlight(content, @highlight) if @highlight
|
83
|
+
content = PreTagBlock.number_content(content) if @number_lines
|
84
|
+
|
85
|
+
classes = "maxOneScreenHigh copyContainer#{@dark}#{pre_clear}#{@class}"
|
86
|
+
pre_content = "#{copy_button}#{content}"
|
87
|
+
attribution = @helper.attribute if @helper.attribution
|
88
|
+
<<~END_OUTPUT
|
89
|
+
<div class="jekyll_pre#{@wrapper_class}" #{@wrapper_style}>
|
90
|
+
#{@label}
|
91
|
+
<pre data-lt-active='false' class='#{classes}'#{@style} id='#{pre_id}'>#{pre_content}</pre>
|
92
|
+
#{attribution}
|
93
|
+
</div>
|
94
|
+
END_OUTPUT
|
80
95
|
end
|
81
96
|
|
82
97
|
JekyllPluginHelper.register(self, 'pre')
|
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
|
+
version: 1.3.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-04-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|
@@ -30,20 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.
|
34
|
-
- - ">="
|
35
|
-
- !ruby/object:Gem::Version
|
36
|
-
version: 0.5.3
|
33
|
+
version: 0.6.0
|
37
34
|
type: :runtime
|
38
35
|
prerelease: false
|
39
36
|
version_requirements: !ruby/object:Gem::Requirement
|
40
37
|
requirements:
|
41
38
|
- - "~>"
|
42
39
|
- !ruby/object:Gem::Version
|
43
|
-
version: 0.
|
44
|
-
- - ">="
|
45
|
-
- !ruby/object:Gem::Version
|
46
|
-
version: 0.5.3
|
40
|
+
version: 0.6.0
|
47
41
|
description: 'Jekyll tags pre and noselect, for HTML <pre/> tag, prompts and unselectable
|
48
42
|
text. Can number lines.
|
49
43
|
|
@@ -68,14 +62,14 @@ files:
|
|
68
62
|
- spec/pre_spec.rb
|
69
63
|
- spec/spec_helper.rb
|
70
64
|
- spec/status_persistence.txt
|
71
|
-
homepage: https://www.mslinn.com/
|
65
|
+
homepage: https://www.mslinn.com/jekyll/3000-jekyll-plugins.html#jekyll_pre
|
72
66
|
licenses:
|
73
67
|
- MIT
|
74
68
|
metadata:
|
75
69
|
allowed_push_host: https://rubygems.org
|
76
70
|
bug_tracker_uri: https://github.com/mslinn/jekyll_pre/issues
|
77
71
|
changelog_uri: https://github.com/mslinn/jekyll_pre/CHANGELOG.md
|
78
|
-
homepage_uri: https://www.mslinn.com/
|
72
|
+
homepage_uri: https://www.mslinn.com/jekyll/3000-jekyll-plugins.html#jekyll_pre
|
79
73
|
source_code_uri: https://github.com/mslinn/jekyll_pre
|
80
74
|
post_install_message: |2+
|
81
75
|
|