markdown_exec 3.4.0 → 3.5.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.
@@ -5,15 +5,16 @@
5
5
  require 'io/console'
6
6
  require 'timeout'
7
7
  require_relative 'env_interface'
8
+ require_relative 'ww'
8
9
 
9
10
  # This function attempts to resize the terminal to its maximum supported size.
10
11
  # It checks if the script is running in an interactive terminal with no arguments.
11
12
  # If so, it sends escape sequences to query the terminal size and reads the response.
12
13
  # It then compares the current terminal size with the calculated size and adjusts if necessary.
13
14
  # If the terminal emulator is unsupported, it prints an error message.
14
- # 2024-8-23 add require_stdout to allow for testing
15
+ # 2024-08-23 add require_stdout to allow for testing
15
16
  def resize_terminal(show_dims: false, show_rectangle: false,
16
- require_stdout: true)
17
+ require_stdout: true, debug: $debug)
17
18
  # Check if running in an interactive terminal and no arguments are provided
18
19
  unless $stdin.tty?
19
20
  warn 'Usage: resize_terminal'
@@ -37,14 +38,14 @@ def resize_terminal(show_dims: false, show_rectangle: false,
37
38
  end
38
39
 
39
40
  if response.empty?
40
- warn "Error: No response received from terminal. Response: #{response.inspect}"
41
+ wwe "Error: No response received from terminal. Response: #{response.inspect}" if debug
41
42
  return 1
42
43
  end
43
44
 
44
45
  # Match the response to extract the terminal dimensions
45
46
  match_data = response.match(/\[(\d+);(\d+)R/)
46
47
  unless match_data
47
- warn "Error: Failed to match terminal response pattern. Response: #{response.inspect}"
48
+ wwe "Error: Failed to match terminal response pattern. Response: #{response.inspect}" if debug
48
49
  return 1
49
50
  end
50
51
 
@@ -60,7 +61,7 @@ def resize_terminal(show_dims: false, show_rectangle: false,
60
61
  nil)} -> #{calculated_columns}x#{calculated_rows}" if show_dims
61
62
  system("stty cols #{calculated_columns} rows #{calculated_rows}")
62
63
  else
63
- warn "Error: Calculated terminal size is invalid. Columns: #{calculated_columns}, Rows: #{calculated_rows}"
64
+ wwe "Error: Calculated terminal size is invalid. Columns: #{calculated_columns}, Rows: #{calculated_rows}" if debug
64
65
  return 1
65
66
  end
66
67
 
@@ -68,10 +69,10 @@ def resize_terminal(show_dims: false, show_rectangle: false,
68
69
  display_terminal_rectangle(calculated_columns,
69
70
  calculated_rows) if show_rectangle
70
71
  rescue Timeout::Error
71
- warn 'Error: Timeout while reading terminal response. Unsupported terminal emulator.'
72
+ wwe 'Error: Timeout while reading terminal response. Unsupported terminal emulator.' if debug
72
73
  1
73
74
  rescue StandardError => err
74
- warn "Error: #{err.message}. Unsupported terminal emulator."
75
+ wwe "Error: #{err.message}. Unsupported terminal emulator." if debug
75
76
  1
76
77
  ensure
77
78
  EnvInterface.set('COLUMNS', @original_columns)
@@ -141,11 +142,10 @@ class ResizeTerminalTest < Minitest::Test
141
142
  $stdin.stub(:tty?, true) do
142
143
  ARGV.replace([])
143
144
  $stdin.stub(:getch, -> { '' }) do
144
- # assert_output(nil, /Error: No response received from terminal/) do
145
- assert_output(nil,
146
- "Error: Timeout while reading terminal response. Unsupported terminal emulator.\n") do
147
- assert_equal 1, resize_terminal(require_stdout: false)
145
+ error = assert_raises(StandardError) do
146
+ resize_terminal(require_stdout: false, debug: true)
148
147
  end
148
+ assert_equal 'Error: Timeout while reading terminal response. Unsupported terminal emulator.', error.message
149
149
  end
150
150
  end
151
151
  end
@@ -156,10 +156,11 @@ class ResizeTerminalTest < Minitest::Test
156
156
  ARGV.replace([])
157
157
  response = "\e[999;999H\e[6n\e[InvalidResponse".dup
158
158
  $stdin.stub(:getch, -> { response.slice!(0) || '' }) do
159
- assert_output(nil,
160
- /Error: Failed to match terminal response pattern/) do
161
- assert_equal 1, resize_terminal(require_stdout: false)
159
+ error = assert_raises(StandardError) do
160
+ resize_terminal(require_stdout: false, debug: true)
162
161
  end
162
+ assert_match /Error: Failed to match terminal response pattern/, error.message
163
+
163
164
  end
164
165
  end
165
166
  end
@@ -169,9 +170,11 @@ class ResizeTerminalTest < Minitest::Test
169
170
  $stdin.stub(:tty?, true) do
170
171
  ARGV.replace([])
171
172
  Timeout.stub(:timeout, ->(_) { raise Timeout::Error }) do
172
- assert_output(nil, /Error: Timeout while reading terminal response/) do
173
- assert_equal 1, resize_terminal(require_stdout: false)
173
+ error = assert_raises(StandardError) do
174
+ resize_terminal(require_stdout: false, debug: true)
174
175
  end
176
+ assert_match /Error: Timeout while reading terminal response/, error.message
177
+
175
178
  end
176
179
  end
177
180
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: markdown_exec
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.4.0
4
+ version: 3.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fareed Stevenson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-09-17 00:00:00.000000000 Z
11
+ date: 2025-11-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: clipboard
@@ -112,6 +112,7 @@ files:
112
112
  - bats/block-type-link.bats
113
113
  - bats/block-type-opts.bats
114
114
  - bats/block-type-port.bats
115
+ - bats/block-type-shell-require-ux.bats
115
116
  - bats/block-type-ux-act-init.bats
116
117
  - bats/block-type-ux-allowed.bats
117
118
  - bats/block-type-ux-auto.bats
@@ -130,6 +131,7 @@ files:
130
131
  - bats/block-type-ux-no-name.bats
131
132
  - bats/block-type-ux-readonly.bats
132
133
  - bats/block-type-ux-require-chained.bats
134
+ - bats/block-type-ux-require-context.bats
133
135
  - bats/block-type-ux-require.bats
134
136
  - bats/block-type-ux-required-variables.bats
135
137
  - bats/block-type-ux-row-format.bats
@@ -174,11 +176,14 @@ files:
174
176
  - bin/setup
175
177
  - bin/tab_completion.sh
176
178
  - bin/tab_completion.sh.erb
179
+ - demo/trap.demo1.gif
180
+ - demo/trap.demo1.mp4
177
181
  - docs/dev/bats-document-configuration.md
178
182
  - docs/dev/block-hide.md
179
183
  - docs/dev/block-type-bash.md
180
184
  - docs/dev/block-type-opts.md
181
185
  - docs/dev/block-type-port.md
186
+ - docs/dev/block-type-shell-require-ux.md
182
187
  - docs/dev/block-type-ux-act-init.md
183
188
  - docs/dev/block-type-ux-allowed.md
184
189
  - docs/dev/block-type-ux-auto.md
@@ -191,12 +196,14 @@ files:
191
196
  - docs/dev/block-type-ux-exec-hash.md
192
197
  - docs/dev/block-type-ux-exec.md
193
198
  - docs/dev/block-type-ux-force.md
199
+ - docs/dev/block-type-ux-format.md
194
200
  - docs/dev/block-type-ux-formats.md
195
201
  - docs/dev/block-type-ux-hidden.md
196
202
  - docs/dev/block-type-ux-invalid.md
197
203
  - docs/dev/block-type-ux-no-name.md
198
204
  - docs/dev/block-type-ux-readonly.md
199
205
  - docs/dev/block-type-ux-require-chained.md
206
+ - docs/dev/block-type-ux-require-context.md
200
207
  - docs/dev/block-type-ux-require.md
201
208
  - docs/dev/block-type-ux-required-variables.md
202
209
  - docs/dev/block-type-ux-row-format.md
@@ -356,6 +363,8 @@ files:
356
363
  - lib/null_result.rb
357
364
  - lib/object_present.rb
358
365
  - lib/option_value.rb
366
+ - lib/parameter_expansion.rb
367
+ - lib/parse_animation_to_tts.rb
359
368
  - lib/regexp.rb
360
369
  - lib/resize_terminal.rb
361
370
  - lib/rspec_helpers.rb