jekyll_pre 1.4.2 → 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: 9891991d8f4517372a76f9a52f60dd8d063a5527738b2bd5194fc749bba5a02e
4
- data.tar.gz: 52b238c5f9aee99c593bd552552411503a0dd49f2c470b1c48bc6600c257e114
3
+ metadata.gz: c9c89dfed1bd63dfb97f8eea204a543d7ea06af6dca9f8b627b2bcf51ad0e65d
4
+ data.tar.gz: e81ee9721c99b5391d401c6a19fbbd2bca8371225b9cc2bf82ff3bfbcc4ab274
5
5
  SHA512:
6
- metadata.gz: 3629fe65cd677c4d964b89e5197f6f18862177da853d862a905bd0162eb6265aa3922e196a34c0149bfd627e9d959155a39675b5ebccde9dfc5cd5f6fa05a355
7
- data.tar.gz: 341e7a4863fc7dccb227d997154cccf677ef4576403f8c75b74cc1a596cbc1c1232d95df1257d052c03f6a65d0fb2104024398902b1fa98e68f54b912df46974
6
+ metadata.gz: 79af8ae474c13a9ad92436e1c916f4b21269b2944fc41725f59976ca543da264ebe8fd669cfe9de119c7f882d138b860006dc70c328c7ad6a58c16c700987a53
7
+ data.tar.gz: 004b17970a50fbe7c9df57d47b38456b36d5786d831db067dba9be7d219fac72823768a63247013beffb02ba9c9a24faa2379323dcdb6e8d1fb08dd99e4c628b
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Change Log
2
2
 
3
+ ## 1.4.3
4
+
5
+ * Added the `no_stderr` option, which discards any STDERR output.
6
+
7
+
3
8
  ## 1.4.2
4
9
 
5
10
  * Added missing `require` in `pre_tag_block.rb`.
data/README.md CHANGED
@@ -61,6 +61,16 @@ This Jekyll plugin provides 3 new Liquid tags that work together:
61
61
  - `die_if_error` – Set `false` to treat exceptions generated by this plugin as non-fatal.
62
62
  Instead of terminating Jekyll with an error message, the message will be displayed as an error by the Jekyll logger.
63
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
+
64
74
  - `no_strip` – Do not remove leading and trailing whitespace from the result.
65
75
  - `wrapper_class` class applied to outer `div`.
66
76
  - `wrapper_style` style applied to outer `div`.
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.2'.freeze
2
+ VERSION = '1.4.3'.freeze
3
3
  end
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.2
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-11-29 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