markdown_exec 2.7.5 → 2.8.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.
data/lib/mdoc.rb CHANGED
@@ -85,14 +85,17 @@ module MarkdownExec
85
85
 
86
86
  dependencies = collect_dependencies(nickname)
87
87
  # !!t dependencies.count
88
- all_dependency_names = collect_unique_names(dependencies).push(nickname).uniq
88
+ all_dependency_names =
89
+ collect_unique_names(dependencies).push(nickname).uniq
89
90
  # !!t all_dependency_names.count
90
91
 
91
92
  # select blocks in order of appearance in source documents
92
93
  #
93
94
  blocks = @table.select do |fcb|
94
95
  # 2024-08-04 match nickname
95
- all_dependency_names.include?(fcb.pub_name) || all_dependency_names.include?(fcb.nickname) || all_dependency_names.include?(fcb.oname)
96
+ all_dependency_names.include?(fcb.pub_name) ||
97
+ all_dependency_names.include?(fcb.nickname) ||
98
+ all_dependency_names.include?(fcb.oname)
96
99
  end
97
100
  # !!t blocks.count
98
101
 
@@ -102,7 +105,10 @@ module MarkdownExec
102
105
  blocks = blocks.map do |fcb|
103
106
  # 2024-08-04 match oname for long block names
104
107
  # 2024-08-04 match nickname
105
- unmet_dependencies.delete(fcb.pub_name) || unmet_dependencies.delete(fcb.nickname) || unmet_dependencies.delete(fcb.oname) # may not exist if block name is duplicated
108
+ # may not exist if block name is duplicated
109
+ unmet_dependencies.delete(fcb.pub_name) ||
110
+ unmet_dependencies.delete(fcb.nickname) ||
111
+ unmet_dependencies.delete(fcb.oname)
106
112
  if (call = fcb.call)
107
113
  fcb1 = get_block_by_anyname("[#{call.match(/^%\((\S+) |\)/)[1]}]")
108
114
  fcb1.cann = call
@@ -124,8 +130,10 @@ module MarkdownExec
124
130
  # @param name [String] The name of the code block to start the collection from.
125
131
  # @return [Array<String>] An array of strings containing the collected code blocks.
126
132
  #
127
- def collect_recursively_required_code(anyname:, block_source:, label_body: true, label_format_above: nil,
128
- label_format_below: nil)
133
+ def collect_recursively_required_code(
134
+ anyname:, block_source:,
135
+ label_body: true, label_format_above: nil, label_format_below: nil
136
+ )
129
137
  block_search = collect_block_dependencies(anyname: anyname)
130
138
  if block_search[:blocks]
131
139
  blocks = collect_wrapped_blocks(block_search[:blocks])
@@ -142,6 +150,7 @@ module MarkdownExec
142
150
  fcb.body # entire body is returned to requesing block
143
151
  elsif [BlockType::LINK,
144
152
  BlockType::LOAD,
153
+ BlockType::UX,
145
154
  BlockType::VARS].include? fcb.type
146
155
  nil
147
156
  elsif fcb[:chrome] # for Link blocks like History
@@ -149,8 +158,10 @@ module MarkdownExec
149
158
  elsif fcb.type == BlockType::PORT
150
159
  generate_env_variable_shell_commands(fcb)
151
160
  elsif label_body
152
- generate_label_body_code(fcb, block_source, label_format_above,
153
- label_format_below)
161
+ generate_label_body_code(
162
+ fcb, block_source,
163
+ label_format_above, label_format_below
164
+ )
154
165
  else # raw body
155
166
  fcb.body
156
167
  end
@@ -229,9 +240,14 @@ module MarkdownExec
229
240
  initialize: opts[:compressed_ids].nil?
230
241
  ) do |fcb, _hide, _collapsed_level|
231
242
  # update fcb per state
232
- if fcb.collapsible
233
- fcb.s1decorated = fcb.s1decorated + ' ' + (fcb.collapse ? opts[:menu_collapsible_symbol_collapsed] : opts[:menu_collapsible_symbol_expanded])
234
- end
243
+ next unless fcb.collapsible
244
+
245
+ fcb.s1decorated = fcb.s1decorated + ' ' +
246
+ (if fcb.collapse
247
+ opts[:menu_collapsible_symbol_collapsed]
248
+ else
249
+ opts[:menu_collapsible_symbol_expanded]
250
+ end)
235
251
  end
236
252
  opts[:compressed_ids] = collapser.compress_ids
237
253
  opts[:expanded_ids] = collapser.expand_ids
@@ -239,7 +255,9 @@ module MarkdownExec
239
255
  # remove
240
256
  # . empty chrome between code; edges are same as blanks
241
257
  #
242
- select_elements_with_neighbor_conditions(selrows) do |prev_element, current, next_element|
258
+ select_elements_with_neighbor_conditions(selrows) do |prev_element,
259
+ current,
260
+ next_element|
243
261
  !(current[:chrome] && !current.oname.present?) ||
244
262
  !(!prev_element.nil? &&
245
263
  prev_element.shell.present? &&
@@ -290,13 +308,17 @@ module MarkdownExec
290
308
 
291
309
  label_above = if label_format_above.present?
292
310
  format(label_format_above,
293
- block_source.merge({ block_name: block_name_for_bash_comment }))
311
+ block_source.merge(
312
+ { block_name: block_name_for_bash_comment }
313
+ ))
294
314
  else
295
315
  nil
296
316
  end
297
317
  label_below = if label_format_below.present?
298
318
  format(label_format_below,
299
- block_source.merge({ block_name: block_name_for_bash_comment }))
319
+ block_source.merge(
320
+ { block_name: block_name_for_bash_comment }
321
+ ))
300
322
  else
301
323
  nil
302
324
  end
@@ -414,8 +436,11 @@ module MarkdownExec
414
436
  memo
415
437
  end
416
438
 
417
- def select_elements_with_neighbor_conditions(array,
418
- last_selected_placeholder = nil, next_selected_placeholder = nil)
439
+ def select_elements_with_neighbor_conditions(
440
+ array,
441
+ last_selected_placeholder = nil,
442
+ next_selected_placeholder = nil
443
+ )
419
444
  selected_elements = []
420
445
  last_selected = last_selected_placeholder
421
446
 
@@ -462,8 +487,10 @@ if $PROGRAM_NAME == __FILE__
462
487
  end if false
463
488
 
464
489
  def test_collect_dependencies_with_valid_source
465
- @mdoc.stubs(:get_block_by_anyname).with('source1').returns(OpenStruct.new(reqs: ['source2']))
466
- @mdoc.stubs(:get_block_by_anyname).with('source2').returns(OpenStruct.new(reqs: []))
490
+ @mdoc.stubs(:get_block_by_anyname)
491
+ .with('source1').returns(OpenStruct.new(reqs: ['source2']))
492
+ @mdoc.stubs(:get_block_by_anyname)
493
+ .with('source2').returns(OpenStruct.new(reqs: []))
467
494
 
468
495
  expected = { 'source1' => ['source2'], 'source2' => [] }
469
496
  assert_equal expected, @mdoc.collect_dependencies('source1')
@@ -534,14 +561,17 @@ if $PROGRAM_NAME == __FILE__
534
561
  end
535
562
 
536
563
  def test_fcbs_per_options
537
- opts = { hide_blocks_by_name: true, block_name_hidden_match: 'block1' }
564
+ opts = { hide_blocks_by_name: true,
565
+ block_name_hidden_match: 'block1' }
538
566
  result = @doc.fcbs_per_options(opts)
539
567
  assert_equal [@table[1], @table[2]], result
540
568
  end if false ### broken test
541
569
 
542
570
  def test_recursively_required
543
571
  result = @doc.recursively_required_hash('block3')
544
- assert_equal ({ 'block3' => ['block1'], 'block1' => ['block2'], 'block2' => nil }),
572
+ assert_equal ({ 'block3' => ['block1'],
573
+ 'block1' => ['block2'],
574
+ 'block2' => nil }),
545
575
  result
546
576
 
547
577
  result_no_reqs = @doc.recursively_required_hash(nil)
@@ -584,8 +614,9 @@ if $PROGRAM_NAME == __FILE__
584
614
  # Test case 3: blocks with missing wraps
585
615
  assert_equal(
586
616
  %w[block4],
587
- @mdoc.collect_wrapped_blocks([OpenStruct.new(oname: 'block4',
588
- wraps: ['wrap4'])]).map(&:oname)
617
+ @mdoc.collect_wrapped_blocks(
618
+ [OpenStruct.new(oname: 'block4', wraps: ['wrap4'])]
619
+ ).map(&:oname)
589
620
  )
590
621
  end
591
622
  end
data/lib/menu.src.yml CHANGED
@@ -206,6 +206,12 @@
206
206
  :default: "(document_shell)"
207
207
  :procname: val_as_str
208
208
 
209
+ - :opt_name: document_load_ux_block_name
210
+ :env_var: MDE_DOCUMENT_LOAD_UX_BLOCK_NAME
211
+ :description: Name of UX block to load with the document
212
+ :default: "\\[.*document_ux.*\\]"
213
+ :procname: val_as_str
214
+
209
215
  - :opt_name: document_load_vars_block_name
210
216
  :env_var: MDE_DOCUMENT_LOAD_VARS_BLOCK_NAME
211
217
  :description: Name of Vars block to load with the document
@@ -1026,6 +1032,18 @@
1026
1032
  :default: ">"
1027
1033
  :procname: val_as_str
1028
1034
 
1035
+ - :opt_name: menu_ux_color
1036
+ :env_var: MDE_MENU_UX_COLOR
1037
+ :description: Color of menu ux
1038
+ :default: fg_rgbh_df_c0_df
1039
+ :procname: val_as_str
1040
+
1041
+ - :opt_name: menu_ux_row_format
1042
+ :env_var: MDE_MENU_UX_ROW_FORMAT
1043
+ :description: Format for UX row
1044
+ :default: '%{name}=${%{name}}'
1045
+ :procname: val_as_str
1046
+
1029
1047
  - :opt_name: menu_vars_color
1030
1048
  :env_var: MDE_MENU_VARS_COLOR
1031
1049
  :description: Color of menu vars
@@ -1315,6 +1333,12 @@
1315
1333
  :description: Prompt to select a saved file
1316
1334
  :procname: val_as_str
1317
1335
 
1336
+ - :opt_name: prompt_ux_enter_a_value
1337
+ :env_var: MDE_PROMPT_UX_ENTER_A_VALUE
1338
+ :description: Prompt to enter a value for UX blocks
1339
+ :default: "\nEnter a value:"
1340
+ :procname: val_as_str
1341
+
1318
1342
  - :opt_name: prompt_show_expr_format
1319
1343
  :env_var: MDE_PROMPT_SHOW_EXPR_FORMAT
1320
1344
  :description: prompt_show_expr_format
@@ -1630,6 +1654,12 @@
1630
1654
  :default: false
1631
1655
  :procname: val_as_bool
1632
1656
 
1657
+ - :opt_name: ux_auto_load_force_default
1658
+ :env_var: MDE_UX_AUTO_LOAD_FORCE_DEFAULT
1659
+ :arg_name: BOOL
1660
+ :default: true
1661
+ :procname: val_as_bool
1662
+
1633
1663
  - :opt_name: variable_expression_regexp
1634
1664
  :env_var: MDE_VARIABLE_EXPRESSION_REGEXP
1635
1665
  :description: variable_expression_regexp
data/lib/menu.yml CHANGED
@@ -171,6 +171,11 @@
171
171
  :description: Name of shell block to load with the document
172
172
  :default: "(document_shell)"
173
173
  :procname: val_as_str
174
+ - :opt_name: document_load_ux_block_name
175
+ :env_var: MDE_DOCUMENT_LOAD_UX_BLOCK_NAME
176
+ :description: Name of UX block to load with the document
177
+ :default: "\\[.*document_ux.*\\]"
178
+ :procname: val_as_str
174
179
  - :opt_name: document_load_vars_block_name
175
180
  :env_var: MDE_DOCUMENT_LOAD_VARS_BLOCK_NAME
176
181
  :description: Name of Vars block to load with the document
@@ -864,6 +869,16 @@
864
869
  :description: Symbol before each task
865
870
  :default: ">"
866
871
  :procname: val_as_str
872
+ - :opt_name: menu_ux_color
873
+ :env_var: MDE_MENU_UX_COLOR
874
+ :description: Color of menu ux
875
+ :default: fg_rgbh_df_c0_df
876
+ :procname: val_as_str
877
+ - :opt_name: menu_ux_row_format
878
+ :env_var: MDE_MENU_UX_ROW_FORMAT
879
+ :description: Format for UX row
880
+ :default: "%{name}=${%{name}}"
881
+ :procname: val_as_str
867
882
  - :opt_name: menu_vars_color
868
883
  :env_var: MDE_MENU_VARS_COLOR
869
884
  :description: Color of menu vars
@@ -1123,6 +1138,13 @@
1123
1138
  Choose a file:
1124
1139
  :description: Prompt to select a saved file
1125
1140
  :procname: val_as_str
1141
+ - :opt_name: prompt_ux_enter_a_value
1142
+ :env_var: MDE_PROMPT_UX_ENTER_A_VALUE
1143
+ :description: Prompt to enter a value for UX blocks
1144
+ :default: |2-
1145
+
1146
+ Enter a value:
1147
+ :procname: val_as_str
1126
1148
  - :opt_name: prompt_show_expr_format
1127
1149
  :env_var: MDE_PROMPT_SHOW_EXPR_FORMAT
1128
1150
  :description: prompt_show_expr_format
@@ -1391,6 +1413,11 @@
1391
1413
  :arg_name: BOOL
1392
1414
  :default: false
1393
1415
  :procname: val_as_bool
1416
+ - :opt_name: ux_auto_load_force_default
1417
+ :env_var: MDE_UX_AUTO_LOAD_FORCE_DEFAULT
1418
+ :arg_name: BOOL
1419
+ :default: true
1420
+ :procname: val_as_bool
1394
1421
  - :opt_name: variable_expression_regexp
1395
1422
  :env_var: MDE_VARIABLE_EXPRESSION_REGEXP
1396
1423
  :description: variable_expression_regexp
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: 2.7.5
4
+ version: 2.8.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-02-02 00:00:00.000000000 Z
11
+ date: 2025-02-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: clipboard
@@ -108,6 +108,10 @@ files:
108
108
  - assets/select_a_file.png
109
109
  - bats/bats.bats
110
110
  - bats/block-type-opts.bats
111
+ - bats/block-type-ux-auto.bats
112
+ - bats/block-type-ux-exec.bats
113
+ - bats/block-type-ux-row-format.bats
114
+ - bats/block-type-ux-transform.bats
111
115
  - bats/block-type-vars.bats
112
116
  - bats/block-types.bats
113
117
  - bats/border.bats
@@ -124,6 +128,7 @@ files:
124
128
  - bats/options.bats
125
129
  - bats/plain.bats
126
130
  - bats/publish.bats
131
+ - bats/table-column-truncate.bats
127
132
  - bats/table.bats
128
133
  - bats/test_helper.bash
129
134
  - bats/variable-expansion.bats
@@ -138,6 +143,10 @@ files:
138
143
  - docs/dev/block-type-bash.md
139
144
  - docs/dev/block-type-opts.md
140
145
  - docs/dev/block-type-port.md
146
+ - docs/dev/block-type-ux-auto.md
147
+ - docs/dev/block-type-ux-exec.md
148
+ - docs/dev/block-type-ux-row-format.md
149
+ - docs/dev/block-type-ux-transform.md
141
150
  - docs/dev/block-type-vars.md
142
151
  - docs/dev/border.md
143
152
  - docs/dev/command-substitution.md
@@ -159,6 +168,7 @@ files:
159
168
  - docs/dev/screen-width.md
160
169
  - docs/dev/specs-import.md
161
170
  - docs/dev/specs.md
171
+ - docs/dev/table-column-truncate.md
162
172
  - docs/dev/table-indent.md
163
173
  - docs/dev/table-invalid.md
164
174
  - docs/dev/text-decoration.md