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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +14 -0
- data/Gemfile +1 -0
- data/Gemfile.lock +8 -1
- data/README.md +262 -116
- data/bats/block-type-shell-require-ux.bats +15 -0
- data/bats/block-type-ux-require-context.bats +14 -0
- data/bats/import-directive-line-continuation.bats +1 -1
- data/bats/import-directive-parameter-symbols.bats +1 -1
- data/bats/import-parameter-symbols.bats +1 -1
- data/bats/options.bats +2 -2
- data/demo/trap.demo1.gif +0 -0
- data/demo/trap.demo1.mp4 +0 -0
- data/docs/dev/block-type-shell-require-ux.md +18 -0
- data/docs/dev/block-type-ux-format.md +10 -0
- data/docs/dev/block-type-ux-require-context.md +32 -0
- data/docs/dev/block-type-ux-require.md +8 -4
- data/docs/dev/import-directive-line-continuation.md +0 -1
- data/docs/dev/import-directive-parameter-symbols.md +0 -2
- data/docs/dev/import-parameter-symbols-template.md +7 -5
- data/docs/dev/import-parameter-symbols.md +10 -2
- data/examples/colors.md +31 -29
- data/lib/cached_nested_file_reader.rb +15 -47
- data/lib/command_result.rb +5 -5
- data/lib/constants.rb +3 -1
- data/lib/fcb.rb +7 -1
- data/lib/hash_delegator.rb +76 -32
- data/lib/link_history.rb +1 -1
- data/lib/markdown_exec/version.rb +1 -1
- data/lib/menu.src.yml +18 -8
- data/lib/menu.yml +14 -5
- data/lib/parameter_expansion.rb +918 -0
- data/lib/parse_animation_to_tts.rb +4417 -0
- data/lib/resize_terminal.rb +19 -16
- metadata +11 -2
data/lib/resize_terminal.rb
CHANGED
|
@@ -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-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
72
|
+
wwe 'Error: Timeout while reading terminal response. Unsupported terminal emulator.' if debug
|
|
72
73
|
1
|
|
73
74
|
rescue StandardError => err
|
|
74
|
-
|
|
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
|
-
|
|
145
|
-
|
|
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
|
-
|
|
160
|
-
|
|
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
|
-
|
|
173
|
-
|
|
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
|
+
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-
|
|
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
|