markdown_exec 3.1.1 → 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 +46 -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 +3 -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 +123 -19
  42. data/lib/format_table.rb +56 -23
  43. data/lib/fout.rb +5 -0
  44. data/lib/hash_delegator.rb +1196 -337
  45. data/lib/markdown_exec/version.rb +2 -1
  46. data/lib/markdown_exec.rb +2 -0
  47. data/lib/mdoc.rb +12 -6
  48. data/lib/menu.src.yml +150 -33
  49. data/lib/menu.yml +126 -31
  50. data/lib/string_util.rb +80 -0
  51. data/lib/table_extractor.rb +170 -64
  52. data/lib/ww.rb +328 -30
  53. metadata +18 -2
@@ -1,3 +1,4 @@
1
+
1
2
  # frozen_string_literal: true
2
3
 
3
4
  # :reek:TooManyConstants
@@ -7,5 +8,5 @@ module MarkdownExec
7
8
  BIN_NAME = 'mde'
8
9
  GEM_NAME = 'markdown_exec'
9
10
  TAP_DEBUG = 'MDE_DEBUG'
10
- VERSION = '3.1.1'
11
+ VERSION = '3.3.0'
11
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
@@ -120,19 +120,21 @@ module MarkdownExec
120
120
  end
121
121
 
122
122
  nickname = name_block.pub_name
123
+ ref = name_block.id
124
+ dependencies = collect_dependencies(pubname: ref)
125
+ wwt :dependencies, 'dependencies.count:', dependencies.count
123
126
 
124
- dependencies = collect_dependencies(pubname: nickname)
125
- # !!t dependencies.count
126
127
  all_dependency_names =
127
- collect_unique_names(dependencies).push(nickname).uniq
128
- # !!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
129
131
 
130
132
  # select blocks in order of appearance in source documents
131
133
  #
132
134
  blocks = table_not_split.select do |fcb|
133
135
  fcb.is_dependency_of?(all_dependency_names)
134
136
  end
135
- # !!t blocks.count
137
+ wwt :blocks, 'blocks.count:', blocks.count
136
138
 
137
139
  ## add cann key to blocks, calc unmet_dependencies
138
140
  #
@@ -147,12 +149,16 @@ module MarkdownExec
147
149
  []
148
150
  end + [fcb]
149
151
  end.flatten(1)
150
- # !!t unmet_dependencies.count
152
+ wwt :unmet_dependencies, 'unmet_dependencies.count:',
153
+ unmet_dependencies.count
154
+ wwt :dependencies, 'dependencies.keys:', dependencies.keys
151
155
 
152
156
  { all_dependency_names: all_dependency_names,
153
157
  blocks: blocks,
154
158
  dependencies: dependencies,
155
159
  unmet_dependencies: unmet_dependencies }
160
+ rescue StandardError
161
+ wwe $!
156
162
  end
157
163
 
158
164
  # Collects recursively required code blocks and returns them as an array of strings.
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
@@ -688,6 +718,12 @@
688
718
  :default: ''
689
719
  :procname: val_as_str
690
720
 
721
+ - :opt_name: local_name_pattern
722
+ :env_var: MDE_LOCAL_NAME_PATTERN
723
+ :description: Pattern for variables not exported in a series of evaluations
724
+ :default: '^_\S{0,12}$'
725
+ :procname: val_as_str
726
+
691
727
  - :opt_name: logged_stdout_filename_prefix
692
728
  :env_var: MDE_LOGGED_STDOUT_FILENAME_PREFIX
693
729
  :description: Name prefix for stdout files
@@ -799,6 +835,20 @@
799
835
  :default:
800
836
  :line: "~~~"
801
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
+
802
852
  - :opt_name: menu_heading1_color
803
853
  :env_var: MDE_MENU_HEADING1_COLOR
804
854
  :description: Color for heading 1 in menu
@@ -858,7 +908,7 @@
858
908
  :env_var: MDE_MENU_INCLUDE_IMPORTED_NOTES
859
909
  :description: Whether imported blocks should be included in the menu
860
910
  :arg_name: BOOL
861
- :default: false
911
+ :default: true
862
912
  :procname: val_as_bool
863
913
 
864
914
  - :opt_name: menu_inherited_lines_at_top
@@ -1025,12 +1075,6 @@
1025
1075
  # :default: fg_rgbh_e0_e0_20
1026
1076
  :procname: val_as_str
1027
1077
 
1028
- - :opt_name: menu_table_rows_match
1029
- :env_var: MDE_MENU_TABLE_ROWS_MATCH
1030
- :description: Pattern for table rows
1031
- :default: '^(?<indent>[ \t]*)(?<line>(?<text>\|.*?)(?<trailing>[ \t]*))$'
1032
- :procname: val_as_str
1033
-
1034
1078
  - :opt_name: menu_task_color
1035
1079
  :env_var: MDE_MENU_TASK_COLOR
1036
1080
  :description: Color of menu task
@@ -1057,10 +1101,40 @@
1057
1101
 
1058
1102
  - :opt_name: menu_ux_color
1059
1103
  :env_var: MDE_MENU_UX_COLOR
1060
- :description: Color of menu ux
1104
+ :description: Default color of menu ux
1061
1105
  :default: fg_rgbh_df_c0_df
1062
1106
  :procname: val_as_str
1063
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
+
1064
1138
  - :opt_name: menu_ux_row_format
1065
1139
  :env_var: MDE_MENU_UX_ROW_FORMAT
1066
1140
  :description: Format for UX row
@@ -1362,12 +1436,6 @@
1362
1436
  :default: "\nChoose a file:"
1363
1437
  :procname: val_as_str
1364
1438
 
1365
- - :opt_name: prompt_select_output
1366
- :env_var: MDE_PROMPT_SELECT_OUTPUT
1367
- :default: "\nChoose a file:"
1368
- :description: Prompt to select a saved file
1369
- :procname: val_as_str
1370
-
1371
1439
  - :opt_name: prompt_ux_enter_a_value
1372
1440
  :env_var: MDE_PROMPT_UX_ENTER_A_VALUE
1373
1441
  :description: Prompt to enter a value for UX blocks
@@ -1428,6 +1496,12 @@
1428
1496
  :long_name: pwd
1429
1497
  :description: Print the gem's home directory
1430
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
+
1431
1505
  - :opt_name: run_last_script
1432
1506
  :long_name: run-last-script
1433
1507
  :description: Run most recently saved script
@@ -1531,6 +1605,12 @@
1531
1605
  :default: 0
1532
1606
  :procname: val_as_int
1533
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
+
1534
1614
  - :opt_name: script_execution_frame_color
1535
1615
  :env_var: MDE_SCRIPT_EXECUTION_FRAME_COLOR
1536
1616
  :description: script_execution_frame_color
@@ -1594,6 +1674,12 @@
1594
1674
  :default: 0
1595
1675
  :procname: val_as_int
1596
1676
 
1677
+ - :opt_name: select_page_ratio
1678
+ :env_var: MDE_SELECT_PAGE_RATIO
1679
+ :description: Number of lines of inactive text that require a scroll point, as a ratio of the page height.
1680
+ :default: 2
1681
+ :procname: val_as_int
1682
+
1597
1683
  - :opt_name: shebang
1598
1684
  :env_var: MDE_SHEBANG
1599
1685
  :description: Shebang for saved scripts
@@ -1675,11 +1761,42 @@
1675
1761
  - fg_bg_rgbh_cf_cf_cf_14_18_1c
1676
1762
  - fg_bg_rgbh_df_df_df_24_24_24
1677
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
+
1678
1788
  - :opt_name: table_separator_line_color
1679
1789
  :env_var: MDE_TABLE_SEPARATOR_LINE_COLOR
1680
1790
  :description: Color for table separator line
1681
1791
  :default: fg_bg_rgbh_df_df_00_14_18_1c
1682
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
+
1683
1800
  - :opt_name: user_must_approve
1684
1801
  :long_name: user-must-approve
1685
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)
@@ -582,6 +605,11 @@
582
605
  :arg_name: PATH
583
606
  :default: ''
584
607
  :procname: val_as_str
608
+ - :opt_name: local_name_pattern
609
+ :env_var: MDE_LOCAL_NAME_PATTERN
610
+ :description: Pattern for variables not exported in a series of evaluations
611
+ :default: "^_\\S{0,12}$"
612
+ :procname: val_as_str
585
613
  - :opt_name: logged_stdout_filename_prefix
586
614
  :env_var: MDE_LOGGED_STDOUT_FILENAME_PREFIX
587
615
  :description: Name prefix for stdout files
@@ -676,6 +704,18 @@
676
704
  :description: closing demarcations for menu
677
705
  :default:
678
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
679
719
  - :opt_name: menu_heading1_color
680
720
  :env_var: MDE_MENU_HEADING1_COLOR
681
721
  :description: Color for heading 1 in menu
@@ -726,7 +766,7 @@
726
766
  :env_var: MDE_MENU_INCLUDE_IMPORTED_NOTES
727
767
  :description: Whether imported blocks should be included in the menu
728
768
  :arg_name: BOOL
729
- :default: false
769
+ :default: true
730
770
  :procname: val_as_bool
731
771
  - :opt_name: menu_inherited_lines_at_top
732
772
  :env_var: MDE_MENU_INHERITED_LINES_AT_TOP
@@ -862,11 +902,6 @@
862
902
  :description: Color of Save link
863
903
  :default: fg_rgbh_ff_ff_20
864
904
  :procname: val_as_str
865
- - :opt_name: menu_table_rows_match
866
- :env_var: MDE_MENU_TABLE_ROWS_MATCH
867
- :description: Pattern for table rows
868
- :default: "^(?<indent>[ \\t]*)(?<line>(?<text>\\|.*?)(?<trailing>[ \\t]*))$"
869
- :procname: val_as_str
870
905
  - :opt_name: menu_task_color
871
906
  :env_var: MDE_MENU_TASK_COLOR
872
907
  :description: Color of menu task
@@ -889,9 +924,34 @@
889
924
  :procname: val_as_str
890
925
  - :opt_name: menu_ux_color
891
926
  :env_var: MDE_MENU_UX_COLOR
892
- :description: Color of menu ux
927
+ :description: Default color of menu ux
893
928
  :default: fg_rgbh_df_c0_df
894
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
895
955
  - :opt_name: menu_ux_row_format
896
956
  :env_var: MDE_MENU_UX_ROW_FORMAT
897
957
  :description: Format for UX row
@@ -1159,13 +1219,6 @@
1159
1219
 
1160
1220
  Choose a file:
1161
1221
  :procname: val_as_str
1162
- - :opt_name: prompt_select_output
1163
- :env_var: MDE_PROMPT_SELECT_OUTPUT
1164
- :default: |2-
1165
-
1166
- Choose a file:
1167
- :description: Prompt to select a saved file
1168
- :procname: val_as_str
1169
1222
  - :opt_name: prompt_ux_enter_a_value
1170
1223
  :env_var: MDE_PROMPT_UX_ENTER_A_VALUE
1171
1224
  :description: Prompt to enter a value for UX blocks
@@ -1218,6 +1271,11 @@
1218
1271
  - :opt_name: pwd
1219
1272
  :long_name: pwd
1220
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
1221
1279
  - :opt_name: run_last_script
1222
1280
  :long_name: run-last-script
1223
1281
  :description: Run most recently saved script
@@ -1306,6 +1364,11 @@
1306
1364
  :description: Screen width for document and interface. 0 to use the actual dimension.
1307
1365
  :default: 0
1308
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
1309
1372
  - :opt_name: script_execution_frame_color
1310
1373
  :env_var: MDE_SCRIPT_EXECUTION_FRAME_COLOR
1311
1374
  :description: script_execution_frame_color
@@ -1362,6 +1425,12 @@
1362
1425
  :description: 'Maximum # of rows in select list. Detects current limit if not specified.'
1363
1426
  :default: 0
1364
1427
  :procname: val_as_int
1428
+ - :opt_name: select_page_ratio
1429
+ :env_var: MDE_SELECT_PAGE_RATIO
1430
+ :description: Number of lines of inactive text that require a scroll point, as a
1431
+ ratio of the page height.
1432
+ :default: 2
1433
+ :procname: val_as_int
1365
1434
  - :opt_name: shebang
1366
1435
  :env_var: MDE_SHEBANG
1367
1436
  :description: Shebang for saved scripts
@@ -1429,10 +1498,36 @@
1429
1498
  :default:
1430
1499
  - fg_bg_rgbh_cf_cf_cf_14_18_1c
1431
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
1432
1521
  - :opt_name: table_separator_line_color
1433
1522
  :env_var: MDE_TABLE_SEPARATOR_LINE_COLOR
1434
1523
  :description: Color for table separator line
1435
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
1436
1531
  - :opt_name: user_must_approve
1437
1532
  :long_name: user-must-approve
1438
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