markdown_exec 2.7.2 → 2.7.4
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 +46 -1
- data/Gemfile.lock +1 -1
- data/Rakefile +29 -11
- data/bats/block-type-opts.bats +23 -0
- data/bats/block-type-vars.bats +26 -0
- data/bats/block-types.bats +0 -36
- data/bats/line-wrapping.bats +8 -0
- data/bats/options-collapse.bats +5 -5
- data/bin/tab_completion.sh +1 -1
- data/docs/dev/block-type-opts.md +4 -1
- data/docs/dev/block-type-vars.md +11 -4
- data/docs/dev/line-wrapping.md +24 -0
- data/docs/dev/options-collapse.md +1 -1
- data/examples/link-blocks-vars.md +69 -41
- data/lib/collapser.rb +35 -21
- data/lib/colorize.rb +11 -37
- data/lib/fcb.rb +47 -11
- data/lib/format_table.rb +55 -17
- data/lib/hash_delegator.rb +201 -111
- data/lib/hierarchy_string.rb +9 -0
- data/lib/markdown_exec/version.rb +1 -1
- data/lib/markdown_exec.rb +2 -2
- data/lib/mdoc.rb +16 -86
- data/lib/menu.src.yml +7 -2
- data/lib/menu.yml +6 -1
- data/lib/ww.rb +6 -4
- metadata +7 -3
- /data/examples/{wrap.md → wrapped-blocks.md} +0 -0
data/lib/hash_delegator.rb
CHANGED
@@ -43,6 +43,7 @@ require_relative 'table_extractor'
|
|
43
43
|
require_relative 'text_analyzer'
|
44
44
|
|
45
45
|
$pd = false unless defined?($pd)
|
46
|
+
$table_cell_truncate = true
|
46
47
|
|
47
48
|
class String
|
48
49
|
# Checks if the string is not empty.
|
@@ -91,6 +92,10 @@ module HashDelegatorSelf
|
|
91
92
|
blocks.find { |item| item.send(msg) == value } || default
|
92
93
|
end
|
93
94
|
|
95
|
+
def block_select(blocks, msg, value, default = nil)
|
96
|
+
blocks.select { |item| item.send(msg) == value }
|
97
|
+
end
|
98
|
+
|
94
99
|
def code_merge(*bodies)
|
95
100
|
merge_lists(*bodies)
|
96
101
|
end
|
@@ -287,9 +292,25 @@ module HashDelegatorSelf
|
|
287
292
|
row: delegate_object[:table_row_color],
|
288
293
|
separator_line: delegate_object[:table_separator_line_color]
|
289
294
|
},
|
290
|
-
lines: lines
|
295
|
+
lines: lines,
|
296
|
+
table_width: screen_width_for_table,
|
297
|
+
truncate: $table_cell_truncate
|
291
298
|
)
|
292
299
|
|
300
|
+
truncated_table_cell = false
|
301
|
+
table__hs.each do |table_hs|
|
302
|
+
table_hs.substrings.each do |substrings|
|
303
|
+
substrings.each do |node|
|
304
|
+
if node[:text].class == TrackedString
|
305
|
+
truncated_table_cell = node[:text].truncated
|
306
|
+
break if truncated_table_cell
|
307
|
+
end
|
308
|
+
end
|
309
|
+
break if truncated_table_cell
|
310
|
+
end
|
311
|
+
break if truncated_table_cell
|
312
|
+
end
|
313
|
+
|
293
314
|
unless table__hs.count == range.size
|
294
315
|
raise 'Invalid result from MarkdownTableFormatter.format_table()'
|
295
316
|
end
|
@@ -313,6 +334,13 @@ module HashDelegatorSelf
|
|
313
334
|
end
|
314
335
|
fcb.s3indent ||= ''
|
315
336
|
fcb.dname = fcb.indented_decorated = fcb.s3indent + fcb.s3formatted_table_row.decorate
|
337
|
+
|
338
|
+
if ind.zero?
|
339
|
+
fcb.truncated_table_cell = truncated_table_cell
|
340
|
+
# if truncated_table_cell
|
341
|
+
fcb.delete_key(:disabled)
|
342
|
+
# end
|
343
|
+
end
|
316
344
|
end
|
317
345
|
end
|
318
346
|
end
|
@@ -577,7 +605,8 @@ module MarkdownExec
|
|
577
605
|
@p_params = {}
|
578
606
|
@p_rest = []
|
579
607
|
|
580
|
-
@compressed_ids =
|
608
|
+
@compressed_ids = {}
|
609
|
+
@expanded_ids = {}
|
581
610
|
end
|
582
611
|
|
583
612
|
##
|
@@ -898,8 +927,10 @@ module MarkdownExec
|
|
898
927
|
|
899
928
|
# private
|
900
929
|
|
901
|
-
def build_replacement_dictionary(
|
902
|
-
|
930
|
+
def build_replacement_dictionary(
|
931
|
+
commands, link_state,
|
932
|
+
initial_code_required: false, key_format:
|
933
|
+
)
|
903
934
|
evaluate_shell_expressions(
|
904
935
|
(link_state&.inherited_lines_block || ''), commands,
|
905
936
|
initial_code_required: initial_code_required,
|
@@ -980,15 +1011,18 @@ module MarkdownExec
|
|
980
1011
|
# sets ENV
|
981
1012
|
def code_from_vars_block_to_set_environment_variables(selected)
|
982
1013
|
code_lines = []
|
983
|
-
YAML.load(selected.body.join("\n"))
|
984
|
-
|
985
|
-
|
1014
|
+
case data = YAML.load(selected.body.join("\n"))
|
1015
|
+
when Hash
|
1016
|
+
data.each do |key, value|
|
1017
|
+
ENV[key] = value.to_s
|
1018
|
+
code_lines.push "#{key}=#{Shellwords.escape(value)}"
|
986
1019
|
|
987
|
-
|
1020
|
+
next unless @delegate_object[:menu_vars_set_format].present?
|
988
1021
|
|
989
|
-
|
990
|
-
|
991
|
-
|
1022
|
+
formatted_string = format(@delegate_object[:menu_vars_set_format],
|
1023
|
+
{ key: key, value: value })
|
1024
|
+
print string_send_color(formatted_string, :menu_vars_set_color)
|
1025
|
+
end
|
992
1026
|
end
|
993
1027
|
code_lines
|
994
1028
|
end
|
@@ -1225,18 +1259,26 @@ module MarkdownExec
|
|
1225
1259
|
# to the block's display name.
|
1226
1260
|
# return number of lines added
|
1227
1261
|
def create_and_add_chrome_block(
|
1228
|
-
blocks:,
|
1229
|
-
|
1230
|
-
|
1231
|
-
|
1232
|
-
|
1233
|
-
|
1262
|
+
blocks:,
|
1263
|
+
case_conversion: nil,
|
1264
|
+
center: nil,
|
1265
|
+
collapse: nil,
|
1266
|
+
color_method:,
|
1267
|
+
decor_patterns: [],
|
1268
|
+
disabled: true,
|
1269
|
+
fcb: nil,
|
1270
|
+
format_option:,
|
1271
|
+
id: '',
|
1272
|
+
level: 0,
|
1273
|
+
match_data:,
|
1274
|
+
type: '',
|
1275
|
+
wrap: nil
|
1234
1276
|
)
|
1235
|
-
line_cap = NamedCaptureExtractor.
|
1277
|
+
line_cap = NamedCaptureExtractor.extract_named_group_match_data(match_data)
|
1236
1278
|
# replace tabs in indent
|
1237
1279
|
line_cap[:indent] ||= ''
|
1238
1280
|
line_cap[:indent] = line_cap[:indent].dup if line_cap[:indent].frozen?
|
1239
|
-
line_cap[:indent].gsub!("\t", ' ')
|
1281
|
+
line_cap[:indent].gsub!("\t", ' ') # TAB_SIZE = 4
|
1240
1282
|
# replace tabs in text
|
1241
1283
|
line_cap[:text] ||= ''
|
1242
1284
|
line_cap[:text] = line_cap[:text].dup if line_cap[:text].frozen?
|
@@ -1264,6 +1306,7 @@ module MarkdownExec
|
|
1264
1306
|
end
|
1265
1307
|
end
|
1266
1308
|
|
1309
|
+
use_fcb = !fcb.nil? # fcb only for the first record if any
|
1267
1310
|
line_caps.each_with_index do |line_obj, index|
|
1268
1311
|
next if line_obj[:text].nil?
|
1269
1312
|
|
@@ -1287,7 +1330,24 @@ module MarkdownExec
|
|
1287
1330
|
|
1288
1331
|
line_obj[:line] = line_obj[:indent] + line_obj[:text]
|
1289
1332
|
|
1290
|
-
if
|
1333
|
+
if use_fcb
|
1334
|
+
fcb.center = center
|
1335
|
+
fcb.chrome = true
|
1336
|
+
fcb.collapse = collapse.nil? ? (line_obj[:collapse] == COLLAPSIBLE_TOKEN_COLLAPSE) : collapse
|
1337
|
+
fcb.token = line_obj[:collapse]
|
1338
|
+
fcb.disabled = disabled ? TtyMenu::DISABLE : nil
|
1339
|
+
fcb.id = "#{id}.#{index}"
|
1340
|
+
fcb.level = level
|
1341
|
+
fcb.s0indent = indent
|
1342
|
+
fcb.s0printable = line_obj[:text]
|
1343
|
+
fcb.s1decorated = decorated
|
1344
|
+
fcb.dname = line_obj[:indent] + decorated
|
1345
|
+
fcb.indent = line_obj[:indent]
|
1346
|
+
fcb.oname = line_obj[:text]
|
1347
|
+
fcb.text = line_obj[:text]
|
1348
|
+
fcb.type = type
|
1349
|
+
use_fcb = false # next line is new record
|
1350
|
+
else
|
1291
1351
|
fcb = FCB.new(
|
1292
1352
|
center: center,
|
1293
1353
|
chrome: true,
|
@@ -1305,22 +1365,6 @@ module MarkdownExec
|
|
1305
1365
|
text: line_obj[:text],
|
1306
1366
|
type: type
|
1307
1367
|
)
|
1308
|
-
else
|
1309
|
-
fcb.center = center
|
1310
|
-
fcb.chrome = true
|
1311
|
-
fcb.collapse = collapse.nil? ? (line_obj[:collapse] == COLLAPSIBLE_TOKEN_COLLAPSE) : collapse
|
1312
|
-
fcb.token = line_obj[:collapse]
|
1313
|
-
fcb.disabled = disabled ? TtyMenu::DISABLE : nil
|
1314
|
-
fcb.id = "#{id}.#{index}"
|
1315
|
-
fcb.level = level
|
1316
|
-
fcb.s0indent = indent
|
1317
|
-
fcb.s0printable = line_obj[:text]
|
1318
|
-
fcb.s1decorated = decorated
|
1319
|
-
fcb.dname = line_obj[:indent] + decorated
|
1320
|
-
fcb.indent = line_obj[:indent]
|
1321
|
-
fcb.oname = line_obj[:text]
|
1322
|
-
fcb.text = line_obj[:text]
|
1323
|
-
fcb.type = type
|
1324
1368
|
end
|
1325
1369
|
|
1326
1370
|
blocks.push fcb
|
@@ -1368,7 +1412,7 @@ module MarkdownExec
|
|
1368
1412
|
@delegate_object[criteria[:color]].to_sym,
|
1369
1413
|
decor_patterns:
|
1370
1414
|
@decor_patterns_from_delegate_object_for_block_create,
|
1371
|
-
disabled: !(criteria[:collapsible] && @delegate_object[criteria[:collapsible]]),
|
1415
|
+
disabled: fcb.truncated_table_cell.nil? && !(criteria[:collapsible] && @delegate_object[criteria[:collapsible]]),
|
1372
1416
|
fcb: fcb,
|
1373
1417
|
id: "#{id}.#{index}",
|
1374
1418
|
format_option: criteria[:format] &&
|
@@ -1659,7 +1703,13 @@ module MarkdownExec
|
|
1659
1703
|
selected:, mdoc:, block_source:, link_state: LinkState.new
|
1660
1704
|
)
|
1661
1705
|
# order should not be important other than else clause
|
1662
|
-
if selected.type == BlockType::
|
1706
|
+
if selected.type == BlockType::TEXT && !selected.truncated_table_cell.nil?
|
1707
|
+
debounce_reset
|
1708
|
+
$table_cell_truncate = !$table_cell_truncate
|
1709
|
+
|
1710
|
+
LoadFileLinkState.new(LoadFile::REUSE, link_state)
|
1711
|
+
|
1712
|
+
elsif selected.type == BlockType::EDIT
|
1663
1713
|
debounce_reset
|
1664
1714
|
vux_edit_inherited
|
1665
1715
|
return :break if pause_user_exit
|
@@ -1804,7 +1854,7 @@ module MarkdownExec
|
|
1804
1854
|
filename: '*',
|
1805
1855
|
form: '%{line}',
|
1806
1856
|
link_state:,
|
1807
|
-
regexp:
|
1857
|
+
regexp: '^(?<line>.*)$',
|
1808
1858
|
selected:
|
1809
1859
|
)
|
1810
1860
|
block_data = HashDelegator.parse_yaml_data_from_body(selected.body)
|
@@ -1956,7 +2006,7 @@ module MarkdownExec
|
|
1956
2006
|
[exit_prompt] + dirs.sort.map do |file|
|
1957
2007
|
{ name: format(
|
1958
2008
|
block_data['view'] || view,
|
1959
|
-
NamedCaptureExtractor.
|
2009
|
+
NamedCaptureExtractor.extract_named_group_match_data(
|
1960
2010
|
file.match(
|
1961
2011
|
Regexp.new(block_data['filename_pattern'] ||
|
1962
2012
|
filename_pattern)
|
@@ -2197,7 +2247,8 @@ module MarkdownExec
|
|
2197
2247
|
def execute_required_lines(
|
2198
2248
|
blockname: '',
|
2199
2249
|
erls: {},
|
2200
|
-
required_lines: [],
|
2250
|
+
required_lines: [],
|
2251
|
+
shell:
|
2201
2252
|
)
|
2202
2253
|
if @delegate_object[:save_executed_script]
|
2203
2254
|
write_command_file(blockname: blockname,
|
@@ -2232,15 +2283,14 @@ module MarkdownExec
|
|
2232
2283
|
end
|
2233
2284
|
|
2234
2285
|
def expand_variable_references!(
|
2235
|
-
echo_format: 'echo $%s',
|
2236
|
-
link_state:,
|
2237
2286
|
blocks:,
|
2287
|
+
echo_format: 'echo $%s',
|
2238
2288
|
group_name: :variable,
|
2239
2289
|
initial_code_required: false,
|
2240
2290
|
key_format: '${%s}',
|
2291
|
+
link_state:,
|
2241
2292
|
pattern: nil
|
2242
2293
|
)
|
2243
|
-
# defined($x) ? '' : ($x = 1; pp [__LINE__, caller.deref])
|
2244
2294
|
pattern ||= options_variable_expression_regexp
|
2245
2295
|
return if pattern.nil?
|
2246
2296
|
|
@@ -2553,20 +2603,35 @@ module MarkdownExec
|
|
2553
2603
|
label_format_above = @delegate_object[:shell_code_label_format_above]
|
2554
2604
|
label_format_below = @delegate_object[:shell_code_label_format_below]
|
2555
2605
|
|
2556
|
-
[
|
2557
|
-
|
2558
|
-
|
2559
|
-
|
2560
|
-
|
2561
|
-
|
2562
|
-
|
2563
|
-
|
2564
|
-
|
2565
|
-
|
2566
|
-
|
2567
|
-
|
2568
|
-
|
2569
|
-
|
2606
|
+
([
|
2607
|
+
if label_format_above.present?
|
2608
|
+
format(
|
2609
|
+
label_format_above,
|
2610
|
+
block_source.merge({ block_name: selected.pub_name })
|
2611
|
+
)
|
2612
|
+
else
|
2613
|
+
nil
|
2614
|
+
end
|
2615
|
+
] +
|
2616
|
+
output_lines.map do |line|
|
2617
|
+
re = Regexp.new(link_block_data.fetch('pattern', '(?<line>.*)'))
|
2618
|
+
next unless re =~ line
|
2619
|
+
|
2620
|
+
re.gsub_format(
|
2621
|
+
line,
|
2622
|
+
link_block_data.fetch('format', '%{line}')
|
2623
|
+
)
|
2624
|
+
end +
|
2625
|
+
[
|
2626
|
+
if label_format_below.present?
|
2627
|
+
format(
|
2628
|
+
label_format_below,
|
2629
|
+
block_source.merge({ block_name: selected.pub_name })
|
2630
|
+
)
|
2631
|
+
else
|
2632
|
+
nil
|
2633
|
+
end
|
2634
|
+
]).compact
|
2570
2635
|
end
|
2571
2636
|
|
2572
2637
|
def link_history_push_and_next(
|
@@ -2641,43 +2706,23 @@ module MarkdownExec
|
|
2641
2706
|
return
|
2642
2707
|
end
|
2643
2708
|
|
2644
|
-
|
2645
|
-
return
|
2709
|
+
blocks = HashDelegator.block_select(all_blocks, :oname, block_name)
|
2710
|
+
return if blocks.empty?
|
2646
2711
|
|
2647
|
-
|
2648
|
-
|
2649
|
-
|
2712
|
+
update_menu_base(
|
2713
|
+
blocks.each.with_object({}) do |block, merged_options|
|
2714
|
+
options_state = read_show_options_and_trigger_reuse(
|
2715
|
+
mdoc: mdoc,
|
2716
|
+
selected: block
|
2717
|
+
)
|
2718
|
+
merged_options.merge!(options_state.options)
|
2719
|
+
end
|
2650
2720
|
)
|
2651
|
-
update_menu_base(options_state.options)
|
2652
2721
|
|
2653
2722
|
@opts_most_recent_filename = @delegate_object[:filename]
|
2654
2723
|
true
|
2655
2724
|
end
|
2656
2725
|
|
2657
|
-
def load_document_shell_block(all_blocks, mdoc: nil)
|
2658
|
-
block_name = @delegate_object[:document_load_shell_block_name]
|
2659
|
-
unless block_name.present? &&
|
2660
|
-
@shell_most_recent_filename != @delegate_object[:filename]
|
2661
|
-
return
|
2662
|
-
end
|
2663
|
-
|
2664
|
-
fcb = HashDelegator.block_find(all_blocks, :oname, block_name)
|
2665
|
-
return unless fcb
|
2666
|
-
|
2667
|
-
@shell_most_recent_filename = @delegate_object[:filename]
|
2668
|
-
|
2669
|
-
if mdoc
|
2670
|
-
mdoc.collect_recursively_required_code(
|
2671
|
-
anyname: fcb.pub_name,
|
2672
|
-
label_format_above: @delegate_object[:shell_code_label_format_above],
|
2673
|
-
label_format_below: @delegate_object[:shell_code_label_format_below],
|
2674
|
-
block_source: block_source
|
2675
|
-
)[:code]
|
2676
|
-
else
|
2677
|
-
fcb.body
|
2678
|
-
end
|
2679
|
-
end
|
2680
|
-
|
2681
2726
|
def load_auto_vars_block(all_blocks,
|
2682
2727
|
block_name: @delegate_object[:document_load_vars_block_name])
|
2683
2728
|
unless block_name.present? &&
|
@@ -2685,11 +2730,16 @@ module MarkdownExec
|
|
2685
2730
|
return
|
2686
2731
|
end
|
2687
2732
|
|
2688
|
-
|
2689
|
-
return
|
2733
|
+
blocks = HashDelegator.block_select(all_blocks, :oname, block_name)
|
2734
|
+
return if blocks.empty?
|
2690
2735
|
|
2691
2736
|
@vars_most_recent_filename = @delegate_object[:filename]
|
2692
|
-
|
2737
|
+
|
2738
|
+
(blocks.each.with_object([]) do |block, merged_options|
|
2739
|
+
merged_options.push(
|
2740
|
+
code_from_vars_block_to_set_environment_variables(block)
|
2741
|
+
)
|
2742
|
+
end).to_a
|
2693
2743
|
end
|
2694
2744
|
|
2695
2745
|
def load_cli_or_user_selected_block(all_blocks: [], menu_blocks: [],
|
@@ -2712,6 +2762,30 @@ module MarkdownExec
|
|
2712
2762
|
SelectedBlockMenuState.new(block, source, state)
|
2713
2763
|
end
|
2714
2764
|
|
2765
|
+
def load_document_shell_block(all_blocks, mdoc: nil)
|
2766
|
+
block_name = @delegate_object[:document_load_shell_block_name]
|
2767
|
+
unless block_name.present? &&
|
2768
|
+
@shell_most_recent_filename != @delegate_object[:filename]
|
2769
|
+
return
|
2770
|
+
end
|
2771
|
+
|
2772
|
+
fcb = HashDelegator.block_find(all_blocks, :oname, block_name)
|
2773
|
+
return unless fcb
|
2774
|
+
|
2775
|
+
@shell_most_recent_filename = @delegate_object[:filename]
|
2776
|
+
|
2777
|
+
if mdoc
|
2778
|
+
mdoc.collect_recursively_required_code(
|
2779
|
+
anyname: fcb.pub_name,
|
2780
|
+
label_format_above: @delegate_object[:shell_code_label_format_above],
|
2781
|
+
label_format_below: @delegate_object[:shell_code_label_format_below],
|
2782
|
+
block_source: block_source
|
2783
|
+
)[:code]
|
2784
|
+
else
|
2785
|
+
fcb.body
|
2786
|
+
end
|
2787
|
+
end
|
2788
|
+
|
2715
2789
|
# format + glob + select for file in load block
|
2716
2790
|
# name has references to ENV vars and doc and batch vars
|
2717
2791
|
# incl. timestamp
|
@@ -2782,9 +2856,11 @@ module MarkdownExec
|
|
2782
2856
|
def mdoc_menu_and_blocks_from_nested_files(link_state, source_id: '')
|
2783
2857
|
# read blocks, load document opts block, and re-process blocks
|
2784
2858
|
#
|
2859
|
+
reload_blocks = false
|
2860
|
+
|
2785
2861
|
all_blocks, mdoc = mdoc_and_blocks_from_nested_files(source_id: source_id)
|
2786
2862
|
if load_auto_opts_block(all_blocks, mdoc: mdoc)
|
2787
|
-
|
2863
|
+
reload_blocks = true
|
2788
2864
|
end
|
2789
2865
|
|
2790
2866
|
# load document shell block
|
@@ -2792,6 +2868,7 @@ module MarkdownExec
|
|
2792
2868
|
if code_lines = load_document_shell_block(all_blocks, mdoc: mdoc)
|
2793
2869
|
next_state_set_code(nil, link_state, code_lines)
|
2794
2870
|
link_state.inherited_lines = code_lines
|
2871
|
+
reload_blocks = true
|
2795
2872
|
end
|
2796
2873
|
|
2797
2874
|
# load document vars block
|
@@ -2801,15 +2878,31 @@ module MarkdownExec
|
|
2801
2878
|
code_lines)
|
2802
2879
|
next_state_set_code(nil, link_state, new_code)
|
2803
2880
|
link_state.inherited_lines = new_code
|
2881
|
+
reload_blocks = true
|
2882
|
+
end
|
2883
|
+
|
2884
|
+
if reload_blocks
|
2885
|
+
all_blocks, mdoc = mdoc_and_blocks_from_nested_files(source_id: source_id)
|
2804
2886
|
end
|
2805
2887
|
|
2806
2888
|
# filter by name, collapsed
|
2807
2889
|
#
|
2808
|
-
menu_blocks
|
2809
|
-
@delegate_object.merge!(compressed_ids: @compressed_ids
|
2890
|
+
menu_blocks = mdoc.fcbs_per_options(
|
2891
|
+
@delegate_object.merge!(compressed_ids: @compressed_ids,
|
2892
|
+
expanded_ids: @expanded_ids)
|
2810
2893
|
)
|
2811
2894
|
|
2895
|
+
# restore pre-expansion (raw) values
|
2896
|
+
#
|
2897
|
+
menu_blocks.each do |fcb|
|
2898
|
+
fcb.dname = fcb.raw_dname unless fcb.raw_dname.nil?
|
2899
|
+
fcb.s0printable = fcb.raw_s0printable unless fcb.raw_s0printable.nil?
|
2900
|
+
fcb.s1decorated = fcb.raw_s1decorated unless fcb.raw_s1decorated.nil?
|
2901
|
+
fcb.body = fcb.raw_body unless fcb.raw_body.nil?
|
2902
|
+
end
|
2903
|
+
|
2812
2904
|
# re-expand blocks
|
2905
|
+
#
|
2813
2906
|
menu_blocks.each do |fcb|
|
2814
2907
|
fcb.body = fcb.raw_body || fcb.body || []
|
2815
2908
|
fcb.dname = fcb.raw_dname || fcb.dname
|
@@ -2831,6 +2924,7 @@ module MarkdownExec
|
|
2831
2924
|
HashDelegator.tables_into_columns!(menu_blocks, @delegate_object,
|
2832
2925
|
screen_width_for_table)
|
2833
2926
|
|
2927
|
+
|
2834
2928
|
[all_blocks, menu_blocks, mdoc]
|
2835
2929
|
end
|
2836
2930
|
|
@@ -2891,19 +2985,16 @@ module MarkdownExec
|
|
2891
2985
|
end
|
2892
2986
|
end
|
2893
2987
|
|
2894
|
-
def menu_compress_collapsible_block(selected)
|
2895
|
-
@compressed_ids.merge!(selected.id => selected.level)
|
2896
|
-
end
|
2897
|
-
|
2898
|
-
def menu_expand_collapsible_block(selected)
|
2899
|
-
@compressed_ids.delete(selected.id)
|
2900
|
-
end
|
2901
|
-
|
2902
2988
|
def menu_toggle_collapsible_block(selected)
|
2903
|
-
if @
|
2904
|
-
|
2905
|
-
|
2906
|
-
|
2989
|
+
# return true if @compress_ids.key?(fcb.id) && !!@compress_ids[fcb.id]
|
2990
|
+
# return false if @expand_ids.key?(fcb.id) && !!@expand_ids[fcb.id]
|
2991
|
+
# binding.irb
|
2992
|
+
if @compressed_ids.key?(selected.id) && !!@compressed_ids[selected.id]
|
2993
|
+
@compressed_ids.delete(selected.id)
|
2994
|
+
@expanded_ids[selected.id] = selected.level
|
2995
|
+
else # @expand_ids.key?(fcb.id) && !!@expand_ids[fcb.id]
|
2996
|
+
@compressed_ids[selected.id] = selected.level
|
2997
|
+
@expanded_ids.delete(selected.id)
|
2907
2998
|
end
|
2908
2999
|
end
|
2909
3000
|
|
@@ -3376,7 +3467,6 @@ module MarkdownExec
|
|
3376
3467
|
def saved_asset_for_history(
|
3377
3468
|
file:, form:, match_info:
|
3378
3469
|
)
|
3379
|
-
|
3380
3470
|
OpenStruct.new(
|
3381
3471
|
file: file[(Dir.pwd.length + 1)..-1],
|
3382
3472
|
full: file,
|
@@ -3839,10 +3929,10 @@ module MarkdownExec
|
|
3839
3929
|
shell: fcb_title_groups.fetch(:shell, ''),
|
3840
3930
|
start_line: line,
|
3841
3931
|
stdin: if (tn = rest.match(/<(?<type>\$)?(?<name>[A-Za-z_-]\S+)/))
|
3842
|
-
NamedCaptureExtractor.
|
3932
|
+
NamedCaptureExtractor.extract_named_group_match_data(tn)
|
3843
3933
|
end,
|
3844
3934
|
stdout: if (tn = rest.match(/>(?<type>\$)?(?<name>[\w.\-]+)/))
|
3845
|
-
NamedCaptureExtractor.
|
3935
|
+
NamedCaptureExtractor.extract_named_group_match_data(tn)
|
3846
3936
|
end,
|
3847
3937
|
title: title,
|
3848
3938
|
type: fcb_title_groups.fetch(:type, ''),
|
@@ -4468,9 +4558,9 @@ module MarkdownExec
|
|
4468
4558
|
when nil
|
4469
4559
|
nil
|
4470
4560
|
when String
|
4471
|
-
menu_blocks.find
|
4561
|
+
menu_blocks.find do |block|
|
4472
4562
|
block.dname.include?(prior_answer)
|
4473
|
-
|
4563
|
+
end&.name
|
4474
4564
|
when Struct
|
4475
4565
|
prior_answer.index || prior_answer.name
|
4476
4566
|
end
|
data/lib/hierarchy_string.rb
CHANGED
@@ -2,6 +2,15 @@
|
|
2
2
|
|
3
3
|
require_relative 'ansi_string'
|
4
4
|
|
5
|
+
class TrackedString < String
|
6
|
+
attr_accessor :truncated
|
7
|
+
|
8
|
+
def initialize(str)
|
9
|
+
super(str)
|
10
|
+
@truncated = false
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
5
14
|
# Class representing a hierarchy of substrings stored as Hash nodes
|
6
15
|
# HierarchyString is a class that represents and manipulates strings based on a hierarchical structure.
|
7
16
|
# The input to the class can be a single hash or an array of nested hashes, where each hash contains a
|
data/lib/markdown_exec.rb
CHANGED
@@ -19,7 +19,6 @@ require_relative 'ansi_formatter'
|
|
19
19
|
require_relative 'cached_nested_file_reader'
|
20
20
|
require_relative 'cli'
|
21
21
|
require_relative 'color_scheme'
|
22
|
-
require_relative 'colorize'
|
23
22
|
require_relative 'directory_searcher'
|
24
23
|
require_relative 'env'
|
25
24
|
require_relative 'exceptions'
|
@@ -95,7 +94,7 @@ class NamedCaptureExtractor
|
|
95
94
|
str&.match(regexp)&.named_captures&.transform_keys(&:to_sym)
|
96
95
|
end
|
97
96
|
|
98
|
-
def self.
|
97
|
+
def self.extract_named_group_match_data(match_data)
|
99
98
|
match_data&.named_captures&.transform_keys(&:to_sym)
|
100
99
|
end
|
101
100
|
end
|
@@ -283,6 +282,7 @@ module MarkdownExec
|
|
283
282
|
include StringUtil
|
284
283
|
|
285
284
|
def initialize(options = {})
|
285
|
+
# ww0 'options', options, caller.deref
|
286
286
|
@option_parser = nil
|
287
287
|
|
288
288
|
@options = HashDelegator.new(options)
|