markdown_exec 3.2.0 → 3.3.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.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +27 -0
  3. data/Gemfile.lock +1 -1
  4. data/Rakefile +3 -3
  5. data/bats/block-type-ux-auto.bats +1 -1
  6. data/bats/block-type-ux-default.bats +1 -1
  7. data/bats/block-type-ux-echo-hash-transform.bats +1 -1
  8. data/bats/block-type-ux-echo-hash.bats +2 -2
  9. data/bats/block-type-ux-exec-hash-transform.bats +8 -0
  10. data/bats/block-type-ux-exec-hash.bats +15 -0
  11. data/bats/block-type-ux-exec.bats +1 -1
  12. data/bats/block-type-ux-force.bats +9 -0
  13. data/bats/block-type-ux-formats.bats +8 -0
  14. data/bats/block-type-ux-readonly.bats +1 -1
  15. data/bats/block-type-ux-row-format.bats +1 -1
  16. data/bats/block-type-ux-transform.bats +1 -1
  17. data/bats/import-directive-parameter-symbols.bats +9 -0
  18. data/bats/import-duplicates.bats +4 -2
  19. data/bats/import-parameter-symbols.bats +8 -0
  20. data/bats/markup.bats +1 -1
  21. data/bats/options.bats +1 -1
  22. data/bin/tab_completion.sh +5 -1
  23. data/docs/dev/block-type-ux-echo-hash-transform.md +14 -12
  24. data/docs/dev/block-type-ux-exec-hash-transform.md +37 -0
  25. data/docs/dev/block-type-ux-exec-hash.md +93 -0
  26. data/docs/dev/block-type-ux-force.md +20 -0
  27. data/docs/dev/block-type-ux-formats.md +58 -0
  28. data/docs/dev/hexdump_format.md +267 -0
  29. data/docs/dev/import/parameter-symbols.md +6 -0
  30. data/docs/dev/import-directive-parameter-symbols.md +9 -0
  31. data/docs/dev/import-parameter-symbols-template.md +24 -0
  32. data/docs/dev/import-parameter-symbols.md +6 -0
  33. data/docs/dev/load-vars-state-demo.md +35 -0
  34. data/docs/ux-blocks-examples.md +2 -3
  35. data/examples/import_with_substitution_demo.md +130 -26
  36. data/examples/imports/organism_template.md +86 -29
  37. data/lib/cached_nested_file_reader.rb +265 -27
  38. data/lib/constants.rb +8 -1
  39. data/lib/env_interface.rb +13 -7
  40. data/lib/evaluate_shell_expressions.rb +1 -0
  41. data/lib/fcb.rb +120 -28
  42. data/lib/format_table.rb +56 -23
  43. data/lib/fout.rb +5 -0
  44. data/lib/hash_delegator.rb +1158 -347
  45. data/lib/markdown_exec/version.rb +1 -1
  46. data/lib/markdown_exec.rb +2 -0
  47. data/lib/mdoc.rb +13 -11
  48. data/lib/menu.src.yml +139 -34
  49. data/lib/menu.yml +116 -32
  50. data/lib/string_util.rb +80 -0
  51. data/lib/table_extractor.rb +170 -64
  52. data/lib/ww.rb +325 -29
  53. metadata +18 -2
@@ -8,5 +8,5 @@ module MarkdownExec
8
8
  BIN_NAME = 'mde'
9
9
  GEM_NAME = 'markdown_exec'
10
10
  TAP_DEBUG = 'MDE_DEBUG'
11
- VERSION = '3.2.0'
11
+ VERSION = '3.3.0'
12
12
  end
data/lib/markdown_exec.rb CHANGED
@@ -1045,6 +1045,8 @@ module MarkdownExec
1045
1045
  def simple_commands(options)
1046
1046
  # !!b
1047
1047
  {
1048
+ # [stage, function]
1049
+ blocks: [2, -> { list_blocks }],
1048
1050
  doc_glob: [1, -> { @fout.fout options[:md_filename_glob] }],
1049
1051
  history: [1, -> { history }],
1050
1052
  list_blocks: [2, -> { list_blocks }],
data/lib/mdoc.rb CHANGED
@@ -119,22 +119,22 @@ module MarkdownExec
119
119
  raise "Named code block `#{anyname}` not found. (@#{__LINE__})"
120
120
  end
121
121
 
122
- # nickname = name_block.pub_name
123
- ####
124
- nickname = name_block.id
122
+ nickname = name_block.pub_name
123
+ ref = name_block.id
124
+ dependencies = collect_dependencies(pubname: ref)
125
+ wwt :dependencies, 'dependencies.count:', dependencies.count
125
126
 
126
- dependencies = collect_dependencies(pubname: nickname)
127
- # !!t dependencies.count
128
127
  all_dependency_names =
129
- collect_unique_names(dependencies).push(nickname).uniq
130
- # !!t all_dependency_names.count
128
+ collect_unique_names(dependencies).push(ref).uniq
129
+ wwt :dependencies, 'all_dependency_names.count:',
130
+ all_dependency_names.count
131
131
 
132
132
  # select blocks in order of appearance in source documents
133
133
  #
134
134
  blocks = table_not_split.select do |fcb|
135
135
  fcb.is_dependency_of?(all_dependency_names)
136
136
  end
137
- # !!t blocks.count
137
+ wwt :blocks, 'blocks.count:', blocks.count
138
138
 
139
139
  ## add cann key to blocks, calc unmet_dependencies
140
140
  #
@@ -149,12 +149,16 @@ module MarkdownExec
149
149
  []
150
150
  end + [fcb]
151
151
  end.flatten(1)
152
- # !!t unmet_dependencies.count
152
+ wwt :unmet_dependencies, 'unmet_dependencies.count:',
153
+ unmet_dependencies.count
154
+ wwt :dependencies, 'dependencies.keys:', dependencies.keys
153
155
 
154
156
  { all_dependency_names: all_dependency_names,
155
157
  blocks: blocks,
156
158
  dependencies: dependencies,
157
159
  unmet_dependencies: unmet_dependencies }
160
+ rescue StandardError
161
+ wwe $!
158
162
  end
159
163
 
160
164
  # Collects recursively required code blocks and returns them as an array of strings.
@@ -166,8 +170,6 @@ module MarkdownExec
166
170
  anyname:, block_source:,
167
171
  label_body: true, label_format_above: nil, label_format_below: nil
168
172
  )
169
- ww 'anyname:', anyname
170
- ww 'block_source:', block_source
171
173
  block_search = collect_block_dependencies(anyname: anyname)
172
174
  if block_search[:blocks]
173
175
  blocks = collect_wrapped_blocks(block_search[:blocks])
data/lib/menu.src.yml CHANGED
@@ -115,6 +115,14 @@
115
115
  :default: ": ${%{key}:=%{value}}"
116
116
  :procname: val_as_str
117
117
 
118
+ - :opt_name: blocks
119
+ :arg_name: MESSAGE
120
+ :default:
121
+ :description: List the blocks displayed
122
+ :env_var: MDE_BLOCKS_LIST_MESSAGE
123
+ :long_name: blocks
124
+ :procname: val_as_str
125
+
118
126
  - :opt_name: clear_screen_for_select_block
119
127
  :env_var: MDE_CLEAR_SCREEN_FOR_SELECT_BLOCK
120
128
  :description: clear_screen_for_select_block
@@ -147,13 +155,6 @@
147
155
  :default: true
148
156
  :procname: val_as_bool
149
157
 
150
- - :opt_name: tables_into_columns
151
- :env_var: MDE_TABLES_INTO_COLUMNS
152
- :description: Format tables as columns
153
- :arg_name: BOOL
154
- :default: true
155
- :procname: val_as_bool
156
-
157
158
  - :long_name: debug
158
159
  :short_name: d
159
160
  :env_var: MDE_DEBUG
@@ -250,16 +251,9 @@
250
251
  :default: document_configurations/%{document_filename}_*.sh
251
252
  :procname: val_as_str
252
253
 
253
- - :opt_name: menu_for_saved_lines
254
- :env_var: MDE_MENU_FOR_SAVED_LINES
255
- :description: Add menu options for saved lines
256
- :arg_name: BOOL
257
- :default: true
258
- :procname: val_as_bool
259
-
260
- - :opt_name: menu_for_history
261
- :env_var: MDE_MENU_FOR_HISTORY
262
- :description: Add menu options for history
254
+ - :opt_name: document_save_make_directory
255
+ :env_var: MDE_DOCUMENT_SAVE_MAKE_DIRECTORY
256
+ :description: Make the directory if it does not exist when saving
263
257
  :arg_name: BOOL
264
258
  :default: true
265
259
  :procname: val_as_bool
@@ -578,10 +572,46 @@
578
572
  :default:
579
573
  :procname: val_as_str
580
574
 
581
- - :opt_name: import_pattern
575
+ - :opt_name: import_directive_line_pattern
582
576
  :env_var: MDE_IMPORT_PATTERN
583
577
  :default: >-
584
- ^(?<indention> *)@import +(?<name>\S+)(?<params>(?: +[A-Za-z_]\w*=(?:"[^"]*"|'[^']*'|\S+))*) *$
578
+ ^(?<indention> *)@import +(?<name>\S+)(?<params>(?: +\w+(?::c=|:e=|:q=|:v=|=)(?:"[^"]*"|'[^']*'|\S+))*) *$
579
+ :procname: val_as_str
580
+
581
+ - :opt_name: import_directive_parameter_scan
582
+ :env_var: MDE_IMPORT_PATTERN_SCAN
583
+ :default: >-
584
+ (\w+)(:c=|:e=|:q=|:v=|=)(?:"([^"]*)"|'([^']*)'|(\S+))
585
+ :procname: val_as_str
586
+
587
+ - :opt_name: import_parameter_variable_assignment
588
+ :env_var: MDE_IMPORT_PARAMETER_VARIABLE_ASSIGNMENT
589
+ :default: "%{key}=%{value}"
590
+ :procname: val_as_str
591
+
592
+ - :opt_name: import_symbol_command_substitution
593
+ :env_var: MDE_IMPORT_SYMBOL_COMMAND_SUBSTITUTION
594
+ :default: ':c='
595
+ :procname: val_as_str
596
+
597
+ - :opt_name: import_symbol_evaluated_expression
598
+ :env_var: MDE_IMPORT_SYMBOL_EVALUATED_EXPRESSION
599
+ :default: ':e='
600
+ :procname: val_as_str
601
+
602
+ - :opt_name: import_symbol_raw_literal
603
+ :env_var: MDE_IMPORT_SYMBOL_RAW_LITERAL
604
+ :default: '='
605
+ :procname: val_as_str
606
+
607
+ - :opt_name: import_symbol_force_quoted_literal
608
+ :env_var: MDE_IMPORT_SYMBOL_FORCE_QUOTED_LITERAL
609
+ :default: ':q='
610
+ :procname: val_as_str
611
+
612
+ - :opt_name: import_symbol_variable_reference
613
+ :env_var: MDE_IMPORT_SYMBOL_VARIABLE_REFERENCE
614
+ :default: ':v='
585
615
  :procname: val_as_str
586
616
 
587
617
  - :opt_name: line_decor_main
@@ -691,7 +721,7 @@
691
721
  - :opt_name: local_name_pattern
692
722
  :env_var: MDE_LOCAL_NAME_PATTERN
693
723
  :description: Pattern for variables not exported in a series of evaluations
694
- :default: '^.{1,3}$'
724
+ :default: '^_\S{0,12}$'
695
725
  :procname: val_as_str
696
726
 
697
727
  - :opt_name: logged_stdout_filename_prefix
@@ -805,6 +835,20 @@
805
835
  :default:
806
836
  :line: "~~~"
807
837
 
838
+ - :opt_name: menu_for_history
839
+ :env_var: MDE_MENU_FOR_HISTORY
840
+ :description: Add menu options for history
841
+ :arg_name: BOOL
842
+ :default: true
843
+ :procname: val_as_bool
844
+
845
+ - :opt_name: menu_for_saved_lines
846
+ :env_var: MDE_MENU_FOR_SAVED_LINES
847
+ :description: Add menu options for saved lines
848
+ :arg_name: BOOL
849
+ :default: true
850
+ :procname: val_as_bool
851
+
808
852
  - :opt_name: menu_heading1_color
809
853
  :env_var: MDE_MENU_HEADING1_COLOR
810
854
  :description: Color for heading 1 in menu
@@ -864,7 +908,7 @@
864
908
  :env_var: MDE_MENU_INCLUDE_IMPORTED_NOTES
865
909
  :description: Whether imported blocks should be included in the menu
866
910
  :arg_name: BOOL
867
- :default: false
911
+ :default: true
868
912
  :procname: val_as_bool
869
913
 
870
914
  - :opt_name: menu_inherited_lines_at_top
@@ -1031,12 +1075,6 @@
1031
1075
  # :default: fg_rgbh_e0_e0_20
1032
1076
  :procname: val_as_str
1033
1077
 
1034
- - :opt_name: menu_table_rows_match
1035
- :env_var: MDE_MENU_TABLE_ROWS_MATCH
1036
- :description: Pattern for table rows
1037
- :default: '^(?<indent>[ \t]*)(?<line>(?<text>\|.*?)(?<trailing>[ \t]*))$'
1038
- :procname: val_as_str
1039
-
1040
1078
  - :opt_name: menu_task_color
1041
1079
  :env_var: MDE_MENU_TASK_COLOR
1042
1080
  :description: Color of menu task
@@ -1063,10 +1101,40 @@
1063
1101
 
1064
1102
  - :opt_name: menu_ux_color
1065
1103
  :env_var: MDE_MENU_UX_COLOR
1066
- :description: Color of menu ux
1104
+ :description: Default color of menu ux
1067
1105
  :default: fg_rgbh_df_c0_df
1068
1106
  :procname: val_as_str
1069
1107
 
1108
+ - :opt_name: menu_ux_color_allow
1109
+ :env_var: MDE_MENU_UX_COLOR_ALLOW
1110
+ :description: Color of menu ux when it is allow
1111
+ :default:
1112
+ :procname: val_as_str
1113
+
1114
+ - :opt_name: menu_ux_color_echo
1115
+ :env_var: MDE_MENU_UX_COLOR_ECHO
1116
+ :description: Color of menu ux when it is echo
1117
+ :default:
1118
+ :procname: val_as_str
1119
+
1120
+ - :opt_name: menu_ux_color_edit
1121
+ :env_var: MDE_MENU_UX_COLOR_EDIT
1122
+ :description: Color of menu ux when it is edit
1123
+ :default:
1124
+ :procname: val_as_str
1125
+
1126
+ - :opt_name: menu_ux_color_exec
1127
+ :env_var: MDE_MENU_UX_COLOR_EXEC
1128
+ :description: Color of menu ux when it is exec
1129
+ :default:
1130
+ :procname: val_as_str
1131
+
1132
+ - :opt_name: menu_ux_color_readonly
1133
+ :env_var: MDE_MENU_UX_COLOR_READONLY
1134
+ :description: Color of menu ux when it is read-only
1135
+ :default:
1136
+ :procname: val_as_str
1137
+
1070
1138
  - :opt_name: menu_ux_row_format
1071
1139
  :env_var: MDE_MENU_UX_ROW_FORMAT
1072
1140
  :description: Format for UX row
@@ -1368,12 +1436,6 @@
1368
1436
  :default: "\nChoose a file:"
1369
1437
  :procname: val_as_str
1370
1438
 
1371
- - :opt_name: prompt_select_output
1372
- :env_var: MDE_PROMPT_SELECT_OUTPUT
1373
- :default: "\nChoose a file:"
1374
- :description: Prompt to select a saved file
1375
- :procname: val_as_str
1376
-
1377
1439
  - :opt_name: prompt_ux_enter_a_value
1378
1440
  :env_var: MDE_PROMPT_UX_ENTER_A_VALUE
1379
1441
  :description: Prompt to enter a value for UX blocks
@@ -1434,6 +1496,12 @@
1434
1496
  :long_name: pwd
1435
1497
  :description: Print the gem's home directory
1436
1498
 
1499
+ - :opt_name: required_lines_with_source_comments
1500
+ :env_var: MDE_REQUIRED_LINES_WITH_SOURCE_COMMENTS
1501
+ :description: Add comments about source to blocks of required lines
1502
+ :default: false
1503
+ :procname: val_as_bool
1504
+
1437
1505
  - :opt_name: run_last_script
1438
1506
  :long_name: run-last-script
1439
1507
  :description: Run most recently saved script
@@ -1537,6 +1605,12 @@
1537
1605
  :default: 0
1538
1606
  :procname: val_as_int
1539
1607
 
1608
+ - :opt_name: script_comment_block_name_format
1609
+ :env_var: MDE_SCRIPT_COMMENT_BLOCK_NAME_FORMAT
1610
+ :description: format for block name in script comments
1611
+ :default: "%{block} %{time}"
1612
+ :procname: val_as_str
1613
+
1540
1614
  - :opt_name: script_execution_frame_color
1541
1615
  :env_var: MDE_SCRIPT_EXECUTION_FRAME_COLOR
1542
1616
  :description: script_execution_frame_color
@@ -1687,11 +1761,42 @@
1687
1761
  - fg_bg_rgbh_cf_cf_cf_14_18_1c
1688
1762
  - fg_bg_rgbh_df_df_df_24_24_24
1689
1763
 
1764
+ - :opt_name: table_row_multi_line_delimiter
1765
+ :env_var: MDE_TABLE_ROW_MULTI_LINE_DELIMITER
1766
+ :description: Multi-line-table delimiter
1767
+ :default: '|'
1768
+ :procname: val_as_str
1769
+
1770
+ - :opt_name: table_row_multi_line_match
1771
+ :env_var: MDE_TABLE_ROW_MULTI_LINE_MATCH
1772
+ :description: Pattern for multi-line-table rows
1773
+ :default: '^(?<indent>[ \t]*)(?<line>(?<text>\|.*?)(?<trailing>[ \t]*))$'
1774
+ :procname: val_as_str
1775
+
1776
+ - :opt_name: table_row_single_line_delimiter
1777
+ :env_var: MDE_TABLE_ROW_SINGLE_LINE_DELIMITER
1778
+ :description: Single-line-table delimiter
1779
+ :default: '!'
1780
+ :procname: val_as_str
1781
+
1782
+ - :opt_name: table_row_single_line_match
1783
+ :env_var: MDE_TABLE_ROW_SINGLE_LINE_MATCH
1784
+ :description: Pattern for single-line-table rows
1785
+ :default: '^(?<indent>[ \t]*)(?<line>(?<text>!.*?)(?<trailing>[ \t]*))$'
1786
+ :procname: val_as_str
1787
+
1690
1788
  - :opt_name: table_separator_line_color
1691
1789
  :env_var: MDE_TABLE_SEPARATOR_LINE_COLOR
1692
1790
  :description: Color for table separator line
1693
1791
  :default: fg_bg_rgbh_df_df_00_14_18_1c
1694
1792
 
1793
+ - :opt_name: tables_into_columns
1794
+ :env_var: MDE_TABLES_INTO_COLUMNS
1795
+ :description: Format tables as columns
1796
+ :arg_name: BOOL
1797
+ :default: true
1798
+ :procname: val_as_bool
1799
+
1695
1800
  - :opt_name: user_must_approve
1696
1801
  :long_name: user-must-approve
1697
1802
  :short_name: q
data/lib/menu.yml CHANGED
@@ -94,6 +94,13 @@
94
94
  :env_var: MDE_BLOCK_TYPE_PORT_SET_FORMAT
95
95
  :default: ": ${%{key}:=%{value}}"
96
96
  :procname: val_as_str
97
+ - :opt_name: blocks
98
+ :arg_name: MESSAGE
99
+ :default:
100
+ :description: List the blocks displayed
101
+ :env_var: MDE_BLOCKS_LIST_MESSAGE
102
+ :long_name: blocks
103
+ :procname: val_as_str
97
104
  - :opt_name: clear_screen_for_select_block
98
105
  :env_var: MDE_CLEAR_SCREEN_FOR_SELECT_BLOCK
99
106
  :description: clear_screen_for_select_block
@@ -121,12 +128,6 @@
121
128
  :arg_name: BOOL
122
129
  :default: true
123
130
  :procname: val_as_bool
124
- - :opt_name: tables_into_columns
125
- :env_var: MDE_TABLES_INTO_COLUMNS
126
- :description: Format tables as columns
127
- :arg_name: BOOL
128
- :default: true
129
- :procname: val_as_bool
130
131
  - :long_name: debug
131
132
  :short_name: d
132
133
  :env_var: MDE_DEBUG
@@ -208,15 +209,9 @@
208
209
  :arg_name: GLOB
209
210
  :default: document_configurations/%{document_filename}_*.sh
210
211
  :procname: val_as_str
211
- - :opt_name: menu_for_saved_lines
212
- :env_var: MDE_MENU_FOR_SAVED_LINES
213
- :description: Add menu options for saved lines
214
- :arg_name: BOOL
215
- :default: true
216
- :procname: val_as_bool
217
- - :opt_name: menu_for_history
218
- :env_var: MDE_MENU_FOR_HISTORY
219
- :description: Add menu options for history
212
+ - :opt_name: document_save_make_directory
213
+ :env_var: MDE_DOCUMENT_SAVE_MAKE_DIRECTORY
214
+ :description: Make the directory if it does not exist when saving
220
215
  :arg_name: BOOL
221
216
  :default: true
222
217
  :procname: val_as_bool
@@ -488,11 +483,39 @@
488
483
  :env_var: MDE_IMPORT_PATHS
489
484
  :default:
490
485
  :procname: val_as_str
491
- - :opt_name: import_pattern
486
+ - :opt_name: import_directive_line_pattern
492
487
  :env_var: MDE_IMPORT_PATTERN
493
- :default: '^(?<indention> *)@import +(?<name>\S+)(?<params>(?: +[A-Za-z_]\w*=(?:"[^"]*"|''[^'']*''|\S+))*)
488
+ :default: '^(?<indention> *)@import +(?<name>\S+)(?<params>(?: +\w+(?::c=|:e=|:q=|:v=|=)(?:"[^"]*"|''[^'']*''|\S+))*)
494
489
  *$'
495
490
  :procname: val_as_str
491
+ - :opt_name: import_directive_parameter_scan
492
+ :env_var: MDE_IMPORT_PATTERN_SCAN
493
+ :default: (\w+)(:c=|:e=|:q=|:v=|=)(?:"([^"]*)"|'([^']*)'|(\S+))
494
+ :procname: val_as_str
495
+ - :opt_name: import_parameter_variable_assignment
496
+ :env_var: MDE_IMPORT_PARAMETER_VARIABLE_ASSIGNMENT
497
+ :default: "%{key}=%{value}"
498
+ :procname: val_as_str
499
+ - :opt_name: import_symbol_command_substitution
500
+ :env_var: MDE_IMPORT_SYMBOL_COMMAND_SUBSTITUTION
501
+ :default: ":c="
502
+ :procname: val_as_str
503
+ - :opt_name: import_symbol_evaluated_expression
504
+ :env_var: MDE_IMPORT_SYMBOL_EVALUATED_EXPRESSION
505
+ :default: ":e="
506
+ :procname: val_as_str
507
+ - :opt_name: import_symbol_raw_literal
508
+ :env_var: MDE_IMPORT_SYMBOL_RAW_LITERAL
509
+ :default: "="
510
+ :procname: val_as_str
511
+ - :opt_name: import_symbol_force_quoted_literal
512
+ :env_var: MDE_IMPORT_SYMBOL_FORCE_QUOTED_LITERAL
513
+ :default: ":q="
514
+ :procname: val_as_str
515
+ - :opt_name: import_symbol_variable_reference
516
+ :env_var: MDE_IMPORT_SYMBOL_VARIABLE_REFERENCE
517
+ :default: ":v="
518
+ :procname: val_as_str
496
519
  - :opt_name: line_decor_main
497
520
  :env_var: MDE_LINE_DECOR_MAIN
498
521
  :description: Line-oriented text decoration (Main)
@@ -585,7 +608,7 @@
585
608
  - :opt_name: local_name_pattern
586
609
  :env_var: MDE_LOCAL_NAME_PATTERN
587
610
  :description: Pattern for variables not exported in a series of evaluations
588
- :default: "^.{1,3}$"
611
+ :default: "^_\\S{0,12}$"
589
612
  :procname: val_as_str
590
613
  - :opt_name: logged_stdout_filename_prefix
591
614
  :env_var: MDE_LOGGED_STDOUT_FILENAME_PREFIX
@@ -681,6 +704,18 @@
681
704
  :description: closing demarcations for menu
682
705
  :default:
683
706
  :line: "~~~"
707
+ - :opt_name: menu_for_history
708
+ :env_var: MDE_MENU_FOR_HISTORY
709
+ :description: Add menu options for history
710
+ :arg_name: BOOL
711
+ :default: true
712
+ :procname: val_as_bool
713
+ - :opt_name: menu_for_saved_lines
714
+ :env_var: MDE_MENU_FOR_SAVED_LINES
715
+ :description: Add menu options for saved lines
716
+ :arg_name: BOOL
717
+ :default: true
718
+ :procname: val_as_bool
684
719
  - :opt_name: menu_heading1_color
685
720
  :env_var: MDE_MENU_HEADING1_COLOR
686
721
  :description: Color for heading 1 in menu
@@ -731,7 +766,7 @@
731
766
  :env_var: MDE_MENU_INCLUDE_IMPORTED_NOTES
732
767
  :description: Whether imported blocks should be included in the menu
733
768
  :arg_name: BOOL
734
- :default: false
769
+ :default: true
735
770
  :procname: val_as_bool
736
771
  - :opt_name: menu_inherited_lines_at_top
737
772
  :env_var: MDE_MENU_INHERITED_LINES_AT_TOP
@@ -867,11 +902,6 @@
867
902
  :description: Color of Save link
868
903
  :default: fg_rgbh_ff_ff_20
869
904
  :procname: val_as_str
870
- - :opt_name: menu_table_rows_match
871
- :env_var: MDE_MENU_TABLE_ROWS_MATCH
872
- :description: Pattern for table rows
873
- :default: "^(?<indent>[ \\t]*)(?<line>(?<text>\\|.*?)(?<trailing>[ \\t]*))$"
874
- :procname: val_as_str
875
905
  - :opt_name: menu_task_color
876
906
  :env_var: MDE_MENU_TASK_COLOR
877
907
  :description: Color of menu task
@@ -894,9 +924,34 @@
894
924
  :procname: val_as_str
895
925
  - :opt_name: menu_ux_color
896
926
  :env_var: MDE_MENU_UX_COLOR
897
- :description: Color of menu ux
927
+ :description: Default color of menu ux
898
928
  :default: fg_rgbh_df_c0_df
899
929
  :procname: val_as_str
930
+ - :opt_name: menu_ux_color_allow
931
+ :env_var: MDE_MENU_UX_COLOR_ALLOW
932
+ :description: Color of menu ux when it is allow
933
+ :default:
934
+ :procname: val_as_str
935
+ - :opt_name: menu_ux_color_echo
936
+ :env_var: MDE_MENU_UX_COLOR_ECHO
937
+ :description: Color of menu ux when it is echo
938
+ :default:
939
+ :procname: val_as_str
940
+ - :opt_name: menu_ux_color_edit
941
+ :env_var: MDE_MENU_UX_COLOR_EDIT
942
+ :description: Color of menu ux when it is edit
943
+ :default:
944
+ :procname: val_as_str
945
+ - :opt_name: menu_ux_color_exec
946
+ :env_var: MDE_MENU_UX_COLOR_EXEC
947
+ :description: Color of menu ux when it is exec
948
+ :default:
949
+ :procname: val_as_str
950
+ - :opt_name: menu_ux_color_readonly
951
+ :env_var: MDE_MENU_UX_COLOR_READONLY
952
+ :description: Color of menu ux when it is read-only
953
+ :default:
954
+ :procname: val_as_str
900
955
  - :opt_name: menu_ux_row_format
901
956
  :env_var: MDE_MENU_UX_ROW_FORMAT
902
957
  :description: Format for UX row
@@ -1164,13 +1219,6 @@
1164
1219
 
1165
1220
  Choose a file:
1166
1221
  :procname: val_as_str
1167
- - :opt_name: prompt_select_output
1168
- :env_var: MDE_PROMPT_SELECT_OUTPUT
1169
- :default: |2-
1170
-
1171
- Choose a file:
1172
- :description: Prompt to select a saved file
1173
- :procname: val_as_str
1174
1222
  - :opt_name: prompt_ux_enter_a_value
1175
1223
  :env_var: MDE_PROMPT_UX_ENTER_A_VALUE
1176
1224
  :description: Prompt to enter a value for UX blocks
@@ -1223,6 +1271,11 @@
1223
1271
  - :opt_name: pwd
1224
1272
  :long_name: pwd
1225
1273
  :description: Print the gem's home directory
1274
+ - :opt_name: required_lines_with_source_comments
1275
+ :env_var: MDE_REQUIRED_LINES_WITH_SOURCE_COMMENTS
1276
+ :description: Add comments about source to blocks of required lines
1277
+ :default: false
1278
+ :procname: val_as_bool
1226
1279
  - :opt_name: run_last_script
1227
1280
  :long_name: run-last-script
1228
1281
  :description: Run most recently saved script
@@ -1311,6 +1364,11 @@
1311
1364
  :description: Screen width for document and interface. 0 to use the actual dimension.
1312
1365
  :default: 0
1313
1366
  :procname: val_as_int
1367
+ - :opt_name: script_comment_block_name_format
1368
+ :env_var: MDE_SCRIPT_COMMENT_BLOCK_NAME_FORMAT
1369
+ :description: format for block name in script comments
1370
+ :default: "%{block} %{time}"
1371
+ :procname: val_as_str
1314
1372
  - :opt_name: script_execution_frame_color
1315
1373
  :env_var: MDE_SCRIPT_EXECUTION_FRAME_COLOR
1316
1374
  :description: script_execution_frame_color
@@ -1440,10 +1498,36 @@
1440
1498
  :default:
1441
1499
  - fg_bg_rgbh_cf_cf_cf_14_18_1c
1442
1500
  - fg_bg_rgbh_df_df_df_24_24_24
1501
+ - :opt_name: table_row_multi_line_delimiter
1502
+ :env_var: MDE_TABLE_ROW_MULTI_LINE_DELIMITER
1503
+ :description: Multi-line-table delimiter
1504
+ :default: "|"
1505
+ :procname: val_as_str
1506
+ - :opt_name: table_row_multi_line_match
1507
+ :env_var: MDE_TABLE_ROW_MULTI_LINE_MATCH
1508
+ :description: Pattern for multi-line-table rows
1509
+ :default: "^(?<indent>[ \\t]*)(?<line>(?<text>\\|.*?)(?<trailing>[ \\t]*))$"
1510
+ :procname: val_as_str
1511
+ - :opt_name: table_row_single_line_delimiter
1512
+ :env_var: MDE_TABLE_ROW_SINGLE_LINE_DELIMITER
1513
+ :description: Single-line-table delimiter
1514
+ :default: "!"
1515
+ :procname: val_as_str
1516
+ - :opt_name: table_row_single_line_match
1517
+ :env_var: MDE_TABLE_ROW_SINGLE_LINE_MATCH
1518
+ :description: Pattern for single-line-table rows
1519
+ :default: "^(?<indent>[ \\t]*)(?<line>(?<text>!.*?)(?<trailing>[ \\t]*))$"
1520
+ :procname: val_as_str
1443
1521
  - :opt_name: table_separator_line_color
1444
1522
  :env_var: MDE_TABLE_SEPARATOR_LINE_COLOR
1445
1523
  :description: Color for table separator line
1446
1524
  :default: fg_bg_rgbh_df_df_00_14_18_1c
1525
+ - :opt_name: tables_into_columns
1526
+ :env_var: MDE_TABLES_INTO_COLUMNS
1527
+ :description: Format tables as columns
1528
+ :arg_name: BOOL
1529
+ :default: true
1530
+ :procname: val_as_bool
1447
1531
  - :opt_name: user_must_approve
1448
1532
  :long_name: user-must-approve
1449
1533
  :short_name: q
data/lib/string_util.rb CHANGED
@@ -29,3 +29,83 @@ class String
29
29
  end
30
30
  end
31
31
  end
32
+
33
+ # String.delete_even_chars / String.delete_even_chars!
34
+ #
35
+ # Class methods that remove the 2nd, 4th, 6th, ... characters from a string.
36
+ #
37
+ # Behavior
38
+ # - Operates on Unicode grapheme clusters via /\X/ to avoid splitting emoji
39
+ # and combining sequences—“user-visible characters” are treated as units.
40
+ # - .delete_even_chars(str) returns a new string consisting of the 1st, 3rd,
41
+ # 5th, ... clusters from +str+.
42
+ # - .delete_even_chars!(str) modifies +str+ in place using #replace and
43
+ # returns it (raises FrozenError if +str+ is frozen).
44
+ #
45
+ # Examples
46
+ # String.delete_even_chars("abcdef") # => "ace"
47
+ # String.delete_even_chars("áb̂c̆") # keeps 1st, 3rd, ... clusters intact
48
+ # s = "👨‍👩‍👧‍👦🙂x"; String.delete_even_chars!(s) # modifies s
49
+ #
50
+ class String
51
+ def delete_even_chars
52
+ clusters = scan(/\X/)
53
+ return dup if clusters.length <= 1
54
+
55
+ clusters.each_with_index
56
+ .select { |_, i| i.even? } # keep 1st, 3rd, 5th... (0-based even)
57
+ .map(&:first)
58
+ .join
59
+ end
60
+
61
+ def delete_even_chars!
62
+ replace(delete_even_chars)
63
+ end
64
+ end
65
+
66
+ # String#sort_chars / String#sort_chars!
67
+ #
68
+ # Adds methods to order a string's user-visible characters (Unicode grapheme
69
+ # clusters) and return the joined result.
70
+ #
71
+ # Behavior
72
+ # - Sorts by Ruby’s default ordering of the grapheme cluster strings.
73
+ # - Preserves emoji and combining sequences by splitting on /\X/.
74
+ # - Optional case-insensitive key and reverse ordering.
75
+ # - Optional custom comparator block; if given, it takes precedence.
76
+ #
77
+ # API
78
+ # String#sort_chars(reverse: false, casefold: false) { |a, b| ... } -> String
79
+ # String#sort_chars!(reverse: false, casefold: false) { |a, b| ... } -> self
80
+ #
81
+ # Examples
82
+ # "cba".sort_chars #=> "abc"
83
+ # "Baß".sort_chars(casefold: true) #=> "aBß"
84
+ # "👩‍💻🚀a".sort_chars #=> "a👩‍💻🚀" (clusters kept intact)
85
+ # "bca".sort_chars { |a,b| b <=> a } #=> "cba" (custom comparator)
86
+ #
87
+ # Notes
88
+ # - For locale-aware collation, integrate a collator and use the block form.
89
+ #
90
+ class String
91
+ def sort_chars(reverse: false, casefold: false, &block)
92
+ clusters = scan(/\X/)
93
+ return self if clusters.length <= 1
94
+
95
+ sorted =
96
+ if block
97
+ clusters.sort(&block)
98
+ elsif casefold
99
+ clusters.sort_by(&:downcase)
100
+ else
101
+ clusters.sort
102
+ end
103
+
104
+ sorted.reverse! if reverse
105
+ sorted.join
106
+ end
107
+
108
+ def sort_chars!(reverse: false, casefold: false, &block)
109
+ replace(sort_chars(reverse: reverse, casefold: casefold, &block))
110
+ end
111
+ end