markdown_exec 3.4.0 → 3.5.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.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +25 -0
  3. data/Dockerfile.test +42 -0
  4. data/Gemfile +1 -0
  5. data/Gemfile.lock +11 -1
  6. data/README.md +283 -144
  7. data/Rakefile +34 -26
  8. data/bats/block-type-shell-require-ux.bats +15 -0
  9. data/bats/block-type-ux-echo.bats +1 -1
  10. data/bats/block-type-ux-require-context.bats +14 -0
  11. data/bats/import-directive-line-continuation.bats +1 -1
  12. data/bats/import-directive-parameter-symbols.bats +1 -1
  13. data/bats/import-parameter-symbols.bats +1 -1
  14. data/bats/options.bats +2 -2
  15. data/bin/bmde +1 -1
  16. data/demo/trap.demo1.gif +0 -0
  17. data/demo/trap.demo1.mp4 +0 -0
  18. data/docs/dev/block-type-shell-require-ux.md +18 -0
  19. data/docs/dev/block-type-ux-echo.md +2 -1
  20. data/docs/dev/block-type-ux-format.md +10 -0
  21. data/docs/dev/block-type-ux-require-context.md +32 -0
  22. data/docs/dev/block-type-ux-require.md +8 -4
  23. data/docs/dev/import-directive-line-continuation.md +0 -1
  24. data/docs/dev/import-directive-parameter-symbols.md +0 -2
  25. data/docs/dev/import-parameter-symbols-template.md +7 -5
  26. data/docs/dev/import-parameter-symbols.md +10 -2
  27. data/docs/docker-testing.md +115 -0
  28. data/docs/tab-completion.md +33 -0
  29. data/examples/colors.md +31 -29
  30. data/lib/cached_nested_file_reader.rb +15 -47
  31. data/lib/collapser.rb +1 -1
  32. data/lib/command_result.rb +5 -5
  33. data/lib/constants.rb +3 -1
  34. data/lib/evaluate_shell_expressions.rb +1 -1
  35. data/lib/fcb.rb +7 -1
  36. data/lib/find_files.rb +1 -2
  37. data/lib/hash_delegator.rb +76 -32
  38. data/lib/input_sequencer.rb +1 -1
  39. data/lib/instance_method_wrapper.rb +1 -1
  40. data/lib/link_history.rb +1 -1
  41. data/lib/markdown_exec/version.rb +1 -1
  42. data/lib/markdown_exec.rb +1 -1
  43. data/lib/menu.src.yml +18 -8
  44. data/lib/menu.yml +14 -5
  45. data/lib/parameter_expansion.rb +918 -0
  46. data/lib/parse_animation_to_tts.rb +4417 -0
  47. data/lib/resize_terminal.rb +21 -32
  48. metadata +14 -2
@@ -1,19 +1,20 @@
1
- #!/usr/bin/env bundle exec ruby
1
+ #!/usr/bin/env -S bundle exec ruby
2
2
  # frozen_string_literal: true
3
3
 
4
4
  # encoding=utf-8
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)
@@ -106,20 +107,6 @@ class ResizeTerminalTest < Minitest::Test
106
107
  EnvInterface.set('LINES', @original_lines)
107
108
  end
108
109
 
109
- # def test_resize_terminal_successful
110
- # # Simulate interactive terminal
111
- # $stdin.stub(:tty?, true) do
112
- # ARGV.replace([])
113
- # ENV['COLUMNS'] = '80'
114
- # ENV['LINES'] = '24'
115
- # response = "\e[999;999H\e[6n\e[24;80R"
116
- # $stdin.stub(:getch, -> { response.slice!(0) || '' }) do
117
- # assert_output(nil, /24x80/) do
118
- # resize_terminal
119
- # end
120
- # end
121
- # end
122
- # end
123
110
  def test_resize_terminal_successful
124
111
  # Simulate interactive terminal
125
112
  $stdin.stub(:tty?, true) do
@@ -129,7 +116,7 @@ class ResizeTerminalTest < Minitest::Test
129
116
  EnvInterface.set('LINES', '24')
130
117
  response = "\e[999;999H\e[6n\e[24;#{columns}R".dup
131
118
  $stdin.stub(:getch, -> { response.slice!(0) || '' }) do
132
- assert_output(/xterm-256color #{columns}x24$/) do
119
+ assert_output(/xterm(-256color)? #{columns}x24$/) do
133
120
  resize_terminal(require_stdout: false)
134
121
  end
135
122
  end
@@ -141,11 +128,10 @@ class ResizeTerminalTest < Minitest::Test
141
128
  $stdin.stub(:tty?, true) do
142
129
  ARGV.replace([])
143
130
  $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)
131
+ error = assert_raises(StandardError) do
132
+ resize_terminal(require_stdout: false, debug: true)
148
133
  end
134
+ assert_equal 'Error: Timeout while reading terminal response. Unsupported terminal emulator.', error.message
149
135
  end
150
136
  end
151
137
  end
@@ -156,10 +142,11 @@ class ResizeTerminalTest < Minitest::Test
156
142
  ARGV.replace([])
157
143
  response = "\e[999;999H\e[6n\e[InvalidResponse".dup
158
144
  $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)
145
+ error = assert_raises(StandardError) do
146
+ resize_terminal(require_stdout: false, debug: true)
162
147
  end
148
+ assert_match /Error: Failed to match terminal response pattern/, error.message
149
+
163
150
  end
164
151
  end
165
152
  end
@@ -169,9 +156,11 @@ class ResizeTerminalTest < Minitest::Test
169
156
  $stdin.stub(:tty?, true) do
170
157
  ARGV.replace([])
171
158
  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)
159
+ error = assert_raises(StandardError) do
160
+ resize_terminal(require_stdout: false, debug: true)
174
161
  end
162
+ assert_match /Error: Timeout while reading terminal response/, error.message
163
+
175
164
  end
176
165
  end
177
166
  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.1
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-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: clipboard
@@ -96,6 +96,7 @@ files:
96
96
  - ".rubocop.yml"
97
97
  - CHANGELOG.md
98
98
  - CODE_OF_CONDUCT.md
99
+ - Dockerfile.test
99
100
  - Gemfile
100
101
  - Gemfile.lock
101
102
  - LICENSE.txt
@@ -112,6 +113,7 @@ files:
112
113
  - bats/block-type-link.bats
113
114
  - bats/block-type-opts.bats
114
115
  - bats/block-type-port.bats
116
+ - bats/block-type-shell-require-ux.bats
115
117
  - bats/block-type-ux-act-init.bats
116
118
  - bats/block-type-ux-allowed.bats
117
119
  - bats/block-type-ux-auto.bats
@@ -130,6 +132,7 @@ files:
130
132
  - bats/block-type-ux-no-name.bats
131
133
  - bats/block-type-ux-readonly.bats
132
134
  - bats/block-type-ux-require-chained.bats
135
+ - bats/block-type-ux-require-context.bats
133
136
  - bats/block-type-ux-require.bats
134
137
  - bats/block-type-ux-required-variables.bats
135
138
  - bats/block-type-ux-row-format.bats
@@ -174,11 +177,14 @@ files:
174
177
  - bin/setup
175
178
  - bin/tab_completion.sh
176
179
  - bin/tab_completion.sh.erb
180
+ - demo/trap.demo1.gif
181
+ - demo/trap.demo1.mp4
177
182
  - docs/dev/bats-document-configuration.md
178
183
  - docs/dev/block-hide.md
179
184
  - docs/dev/block-type-bash.md
180
185
  - docs/dev/block-type-opts.md
181
186
  - docs/dev/block-type-port.md
187
+ - docs/dev/block-type-shell-require-ux.md
182
188
  - docs/dev/block-type-ux-act-init.md
183
189
  - docs/dev/block-type-ux-allowed.md
184
190
  - docs/dev/block-type-ux-auto.md
@@ -191,12 +197,14 @@ files:
191
197
  - docs/dev/block-type-ux-exec-hash.md
192
198
  - docs/dev/block-type-ux-exec.md
193
199
  - docs/dev/block-type-ux-force.md
200
+ - docs/dev/block-type-ux-format.md
194
201
  - docs/dev/block-type-ux-formats.md
195
202
  - docs/dev/block-type-ux-hidden.md
196
203
  - docs/dev/block-type-ux-invalid.md
197
204
  - docs/dev/block-type-ux-no-name.md
198
205
  - docs/dev/block-type-ux-readonly.md
199
206
  - docs/dev/block-type-ux-require-chained.md
207
+ - docs/dev/block-type-ux-require-context.md
200
208
  - docs/dev/block-type-ux-require.md
201
209
  - docs/dev/block-type-ux-required-variables.md
202
210
  - docs/dev/block-type-ux-row-format.md
@@ -260,6 +268,8 @@ files:
260
268
  - docs/dev/text-decoration.md
261
269
  - docs/dev/variable-expansion-multiline.md
262
270
  - docs/dev/variable-expansion.md
271
+ - docs/docker-testing.md
272
+ - docs/tab-completion.md
263
273
  - docs/ux-blocks-examples.md
264
274
  - docs/ux-blocks-init-act.md
265
275
  - examples/bash-blocks.md
@@ -356,6 +366,8 @@ files:
356
366
  - lib/null_result.rb
357
367
  - lib/object_present.rb
358
368
  - lib/option_value.rb
369
+ - lib/parameter_expansion.rb
370
+ - lib/parse_animation_to_tts.rb
359
371
  - lib/regexp.rb
360
372
  - lib/resize_terminal.rb
361
373
  - lib/rspec_helpers.rb