markdown_exec 3.0.9 → 3.1.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +37 -0
- data/Gemfile.lock +1 -1
- data/bats/block-type-ux-require-chained.bats +9 -0
- data/bats/block-type-ux-require.bats +6 -0
- data/bats/block-type-ux-required-variables.bats +0 -12
- data/bats/block-type-ux-sources.bats +0 -8
- data/bats/import-with-text-substitution.bats +9 -0
- data/bats/load-vars-state-demo.bats +26 -0
- data/bats/options.bats +1 -1
- data/docs/dev/block-type-ux-require-chained.md +33 -0
- data/docs/dev/block-type-ux-require.md +8 -0
- data/docs/dev/import-substitution-basic.md +5 -0
- data/docs/dev/import-substitution-compare.md +12 -0
- data/docs/dev/import-substitution-export.md +18 -0
- data/docs/dev/import-substitution-long.md +12 -0
- data/docs/dev/import-substitution-mixed.md +9 -0
- data/docs/dev/import-substitution-plant.md +11 -0
- data/docs/dev/import-substitution-quotes.md +7 -0
- data/docs/dev/import-substitution-research.md +11 -0
- data/docs/dev/import-substitution-simple.md +5 -0
- data/docs/dev/import-substitution-special.md +10 -0
- data/docs/dev/import-substitution-taxonomy.md +14 -0
- data/docs/dev/import-with-text-substitution.md +57 -0
- data/docs/dev/load-mode-demo.md +163 -0
- data/examples/import_with_substitution_demo.md +48 -0
- data/examples/imports/mixed_template.md +33 -0
- data/examples/imports/organism_template.md +42 -0
- data/examples/imports/template_mustache.md +22 -0
- data/examples/imports/template_vars.md +22 -0
- data/examples/raw_replacement_demo.md +42 -0
- data/examples/recent_discoveries_demo.md +43 -0
- data/examples/template_syntax_demo.md +24 -0
- data/lib/cached_nested_file_reader.rb +176 -28
- data/lib/command_result.rb +3 -2
- data/lib/constants.rb +5 -0
- data/lib/env_interface.rb +2 -2
- data/lib/exceptions.rb +10 -2
- data/lib/fcb.rb +2 -3
- data/lib/hash_delegator.rb +134 -78
- data/lib/markdown_exec/version.rb +1 -1
- data/lib/menu.src.yml +2 -1
- data/lib/menu.yml +2 -1
- data/lib/ww.rb +28 -1
- metadata +27 -2
data/lib/hash_delegator.rb
CHANGED
|
@@ -978,8 +978,8 @@ module MarkdownExec
|
|
|
978
978
|
end
|
|
979
979
|
OpenStruct.new(blocks: blocks, results: results)
|
|
980
980
|
rescue StandardError
|
|
981
|
-
|
|
982
|
-
|
|
981
|
+
wwe 'link_state:', link_state, 'source_id:', source_id, 'btype:', btype,
|
|
982
|
+
'fcb:', fcb
|
|
983
983
|
end
|
|
984
984
|
|
|
985
985
|
def build_menu_options(exit_option, display_mode_option,
|
|
@@ -1110,6 +1110,7 @@ module MarkdownExec
|
|
|
1110
1110
|
selected, mdoc, inherited_code: nil, force: true, only_default: false,
|
|
1111
1111
|
silent:
|
|
1112
1112
|
)
|
|
1113
|
+
wwt :fcb, 'selected:', selected
|
|
1113
1114
|
ret_command_result = nil
|
|
1114
1115
|
exit_prompt = @delegate_object[:prompt_filespec_back]
|
|
1115
1116
|
|
|
@@ -1119,13 +1120,16 @@ module MarkdownExec
|
|
|
1119
1120
|
label_format_below: @delegate_object[:shell_code_label_format_below],
|
|
1120
1121
|
block_source: block_source
|
|
1121
1122
|
)
|
|
1123
|
+
wwt :required, required
|
|
1122
1124
|
|
|
1123
1125
|
# process each ux block in sequence, setting ENV and collecting lines
|
|
1124
1126
|
required_lines = []
|
|
1125
1127
|
required[:blocks].each do |block|
|
|
1126
1128
|
next unless block.type == BlockType::UX
|
|
1127
1129
|
|
|
1128
|
-
|
|
1130
|
+
wwt :fcb, 'a required block', block
|
|
1131
|
+
|
|
1132
|
+
case data = safe_yaml_load(block.body.join("\n"))
|
|
1129
1133
|
when Hash
|
|
1130
1134
|
export = parse_yaml_of_ux_block(
|
|
1131
1135
|
data,
|
|
@@ -1165,20 +1169,24 @@ module MarkdownExec
|
|
|
1165
1169
|
end
|
|
1166
1170
|
return command_result_w_e_t_nl if command_result_w_e_t_nl.failure?
|
|
1167
1171
|
|
|
1172
|
+
# update the required lines for this and subsequent blocks
|
|
1168
1173
|
command_result_w_e_t_nl.new_lines =
|
|
1169
1174
|
process_command_result_lines(command_result_w_e_t_nl, export,
|
|
1170
1175
|
required_lines)
|
|
1171
1176
|
required_lines.concat(command_result_w_e_t_nl.new_lines)
|
|
1177
|
+
command_result_w_e_t_nl.new_lines = required_lines
|
|
1172
1178
|
ret_command_result = command_result_w_e_t_nl
|
|
1173
1179
|
else
|
|
1174
1180
|
raise "Invalid data type: #{data.inspect}"
|
|
1175
1181
|
end
|
|
1176
1182
|
end
|
|
1177
1183
|
|
|
1178
|
-
ret_command_result || CommandResult.new(stdout: required_lines)
|
|
1184
|
+
(ret_command_result || CommandResult.new(stdout: required_lines)).tap do |ret|
|
|
1185
|
+
wwt :cr, ret
|
|
1186
|
+
end
|
|
1179
1187
|
rescue StandardError
|
|
1180
|
-
|
|
1181
|
-
|
|
1188
|
+
wwe 'selected:', selected, 'required:', required, 'block:', block,
|
|
1189
|
+
'data:', data
|
|
1182
1190
|
end
|
|
1183
1191
|
|
|
1184
1192
|
# sets ENV
|
|
@@ -1199,9 +1207,14 @@ module MarkdownExec
|
|
|
1199
1207
|
end
|
|
1200
1208
|
end
|
|
1201
1209
|
code_lines
|
|
1210
|
+
rescue StandardError
|
|
1211
|
+
wwe 'selected:', selected, 'data:', data, 'key:', key, 'value:', value,
|
|
1212
|
+
'code_lines:', code_lines, 'formatted_string:', formatted_string
|
|
1202
1213
|
end
|
|
1203
1214
|
|
|
1204
|
-
|
|
1215
|
+
# make a single line of shell code to assign an escaped value to a variable
|
|
1216
|
+
# force/default
|
|
1217
|
+
def code_line_to_assign_a_variable(name, value, force:)
|
|
1205
1218
|
if force
|
|
1206
1219
|
"#{name}=#{Shellwords.escape(value)}"
|
|
1207
1220
|
else
|
|
@@ -1213,11 +1226,15 @@ module MarkdownExec
|
|
|
1213
1226
|
extract_patterns = lambda do |key|
|
|
1214
1227
|
return [] unless delegate_object[key].present?
|
|
1215
1228
|
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1229
|
+
begin
|
|
1230
|
+
(value = HashDelegator.safeval(delegate_object[key])).map do |pc|
|
|
1231
|
+
{
|
|
1232
|
+
color_method: pc[:color_method].to_sym,
|
|
1233
|
+
pattern: Regexp.new(pc[:pattern])
|
|
1234
|
+
}
|
|
1235
|
+
end
|
|
1236
|
+
rescue StandardError
|
|
1237
|
+
wwe({ error: $!, callback: $@[0], key: key, value: value })
|
|
1221
1238
|
end
|
|
1222
1239
|
end
|
|
1223
1240
|
|
|
@@ -1958,8 +1975,9 @@ module MarkdownExec
|
|
|
1958
1975
|
|
|
1959
1976
|
elsif selected.type == BlockType::LOAD
|
|
1960
1977
|
debounce_reset
|
|
1961
|
-
|
|
1962
|
-
next_state_append_code(selected, link_state,
|
|
1978
|
+
load_result = execute_block_type_load_code_lines(selected)
|
|
1979
|
+
next_state_append_code(selected, link_state, load_result.code,
|
|
1980
|
+
mode: load_result.mode)
|
|
1963
1981
|
|
|
1964
1982
|
elsif selected.type == BlockType::SAVE
|
|
1965
1983
|
debounce_reset
|
|
@@ -2246,38 +2264,54 @@ module MarkdownExec
|
|
|
2246
2264
|
)
|
|
2247
2265
|
dirs.sort_by! { |f| File.mtime(f) }.reverse!
|
|
2248
2266
|
|
|
2249
|
-
if !contains_glob?(block_data['directory']) &&
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2267
|
+
code = if !contains_glob?(block_data['directory']) &&
|
|
2268
|
+
!contains_glob?(block_data['glob'])
|
|
2269
|
+
if dirs[0]
|
|
2270
|
+
File.readlines(dirs[0], chomp: true)
|
|
2271
|
+
else
|
|
2272
|
+
warn 'No matching file found.'
|
|
2273
|
+
end
|
|
2274
|
+
elsif (selected_option = select_option_with_metadata(
|
|
2275
|
+
prompt_title,
|
|
2276
|
+
[exit_prompt] + dirs.map do |file| # tty_menu_items
|
|
2277
|
+
{ name:
|
|
2278
|
+
format(
|
|
2279
|
+
block_data['view'] || view,
|
|
2280
|
+
NamedCaptureExtractor.extract_named_group_match_data(
|
|
2281
|
+
file.match(
|
|
2282
|
+
Regexp.new(block_data['filename_pattern'] || filename_pattern)
|
|
2283
|
+
)
|
|
2284
|
+
)
|
|
2285
|
+
),
|
|
2286
|
+
oname: file }
|
|
2287
|
+
end,
|
|
2288
|
+
menu_options.merge(
|
|
2289
|
+
cycle: true,
|
|
2290
|
+
match_dml: false
|
|
2291
|
+
)
|
|
2292
|
+
))
|
|
2293
|
+
if selected_option.dname != exit_prompt
|
|
2294
|
+
File.readlines(selected_option.oname, chomp: true)
|
|
2295
|
+
end
|
|
2296
|
+
else
|
|
2297
|
+
warn 'No matching files found.'
|
|
2298
|
+
end
|
|
2299
|
+
|
|
2300
|
+
if (mode = block_data['mode']&.to_sym)
|
|
2301
|
+
reason = 'specified Load mode'
|
|
2302
|
+
unless [LoadMode::APPEND, LoadMode::REPLACE].include? mode
|
|
2303
|
+
wwe 'Invalid mode', 'block_data:', block_data
|
|
2277
2304
|
end
|
|
2278
2305
|
else
|
|
2279
|
-
|
|
2306
|
+
reason = 'default Load mode'
|
|
2307
|
+
mode = LoadMode::APPEND
|
|
2280
2308
|
end
|
|
2309
|
+
|
|
2310
|
+
OpenStruct.new(
|
|
2311
|
+
code: code,
|
|
2312
|
+
mode: mode,
|
|
2313
|
+
reason: reason
|
|
2314
|
+
)
|
|
2281
2315
|
end
|
|
2282
2316
|
|
|
2283
2317
|
# Collects required code lines based on the selected block and
|
|
@@ -2521,6 +2555,7 @@ module MarkdownExec
|
|
|
2521
2555
|
end
|
|
2522
2556
|
|
|
2523
2557
|
def expand_references!(fcb, link_state)
|
|
2558
|
+
# options expansions
|
|
2524
2559
|
expand_variable_references!(
|
|
2525
2560
|
blocks: [fcb],
|
|
2526
2561
|
echo_formatter: method(:format_echo_command),
|
|
@@ -2591,17 +2626,20 @@ module MarkdownExec
|
|
|
2591
2626
|
def export_echo_with_code(
|
|
2592
2627
|
bash_script_lines, export, force:, silent:, string: nil
|
|
2593
2628
|
)
|
|
2629
|
+
wwp
|
|
2594
2630
|
exportable = true
|
|
2595
2631
|
command_result = nil
|
|
2596
2632
|
new_lines = []
|
|
2597
2633
|
export_string = string.nil? ? export.echo : string
|
|
2598
2634
|
case export_string
|
|
2599
2635
|
when String, Integer, Float, TrueClass, FalseClass
|
|
2600
|
-
command_result, exportable,
|
|
2636
|
+
command_result, exportable, = output_from_adhoc_bash_script_file(
|
|
2601
2637
|
join_array_of_arrays(
|
|
2602
2638
|
bash_script_lines,
|
|
2603
2639
|
%(printf '%s' "#{export_string}")
|
|
2604
|
-
)
|
|
2640
|
+
),
|
|
2641
|
+
export,
|
|
2642
|
+
force: force
|
|
2605
2643
|
)
|
|
2606
2644
|
if command_result.exit_status == EXIT_STATUS_REQUIRED_EMPTY
|
|
2607
2645
|
exportable = false
|
|
@@ -2619,7 +2657,9 @@ module MarkdownExec
|
|
|
2619
2657
|
join_array_of_arrays(
|
|
2620
2658
|
bash_script_lines,
|
|
2621
2659
|
%(printf '%s' "#{expression}")
|
|
2622
|
-
)
|
|
2660
|
+
),
|
|
2661
|
+
export,
|
|
2662
|
+
force: force
|
|
2623
2663
|
)
|
|
2624
2664
|
if command_result.exit_status == EXIT_STATUS_REQUIRED_EMPTY
|
|
2625
2665
|
command_result.warning = warning_required_empty(export) unless silent
|
|
@@ -3524,12 +3564,13 @@ module MarkdownExec
|
|
|
3524
3564
|
list[(index + 1) % list.size] # Get the next item, wrap around if at the end
|
|
3525
3565
|
end
|
|
3526
3566
|
|
|
3527
|
-
def next_state_append_code(selected, link_state, code_lines
|
|
3567
|
+
def next_state_append_code(selected, link_state, code_lines,
|
|
3568
|
+
mode: LoadMode::APPEND)
|
|
3528
3569
|
next_state_set_code(
|
|
3529
3570
|
selected,
|
|
3530
3571
|
link_state,
|
|
3531
3572
|
HashDelegator.flatten_and_compact_arrays(
|
|
3532
|
-
link_state&.inherited_lines,
|
|
3573
|
+
mode == LoadMode::APPEND ? link_state&.inherited_lines : [],
|
|
3533
3574
|
code_lines.is_a?(Array) ? code_lines : [] # no code for :ux_exec_prohibited
|
|
3534
3575
|
)
|
|
3535
3576
|
)
|
|
@@ -3591,7 +3632,8 @@ module MarkdownExec
|
|
|
3591
3632
|
|
|
3592
3633
|
def output_from_adhoc_bash_script_file(
|
|
3593
3634
|
bash_script_lines,
|
|
3594
|
-
export = nil
|
|
3635
|
+
export = nil,
|
|
3636
|
+
force:
|
|
3595
3637
|
)
|
|
3596
3638
|
Tempfile.create('script_exec') do |temp_file|
|
|
3597
3639
|
temp_file.write(
|
|
@@ -3612,26 +3654,22 @@ module MarkdownExec
|
|
|
3612
3654
|
|
|
3613
3655
|
output = `#{shell} #{temp_file.path}`
|
|
3614
3656
|
|
|
3615
|
-
exportable =
|
|
3657
|
+
exportable = if export&.exportable.nil?
|
|
3658
|
+
true
|
|
3659
|
+
else
|
|
3660
|
+
(export ? export.exportable : false)
|
|
3661
|
+
end
|
|
3616
3662
|
new_lines = []
|
|
3617
3663
|
# new_lines << { comment: 'output_from_adhoc_bash_script_file' }
|
|
3618
|
-
if export
|
|
3619
|
-
new_lines << "#{export.name}="
|
|
3620
|
-
export_value = output
|
|
3621
|
-
### transform?
|
|
3622
3664
|
|
|
3623
|
-
|
|
3624
|
-
|
|
3625
|
-
|
|
3626
|
-
|
|
3627
|
-
|
|
3628
|
-
|
|
3629
|
-
|
|
3630
|
-
|
|
3631
|
-
command_result = CommandResult.new(
|
|
3632
|
-
stdout: output,
|
|
3633
|
-
exit_status: $?.exitstatus
|
|
3634
|
-
)
|
|
3665
|
+
command_result = CommandResult.new(
|
|
3666
|
+
stdout: output,
|
|
3667
|
+
exit_status: $?.exitstatus
|
|
3668
|
+
)
|
|
3669
|
+
exportable &&= command_result.success?
|
|
3670
|
+
if exportable
|
|
3671
|
+
new_lines << { name: export.name, force: force,
|
|
3672
|
+
text: command_result.stdout }
|
|
3635
3673
|
end
|
|
3636
3674
|
|
|
3637
3675
|
[
|
|
@@ -3641,6 +3679,7 @@ module MarkdownExec
|
|
|
3641
3679
|
]
|
|
3642
3680
|
end
|
|
3643
3681
|
rescue StandardError => err
|
|
3682
|
+
# wwe 'bash_script_lines:', bash_script_lines, 'export:', export
|
|
3644
3683
|
warn "Error executing script: #{err.message}"
|
|
3645
3684
|
nil
|
|
3646
3685
|
end
|
|
@@ -3792,7 +3831,9 @@ module MarkdownExec
|
|
|
3792
3831
|
command_result_w_e_t_nl.new_lines.map do |name_force|
|
|
3793
3832
|
comment = name_force.fetch(:comment, '')
|
|
3794
3833
|
name = name_force.fetch(:name, '')
|
|
3795
|
-
if
|
|
3834
|
+
if name.empty?
|
|
3835
|
+
"# #{comment}" unless comment.empty?
|
|
3836
|
+
else
|
|
3796
3837
|
transformed = if command_result_w_e_t_nl.transformable
|
|
3797
3838
|
transform_export_value(name_force[:text], export)
|
|
3798
3839
|
else
|
|
@@ -3802,13 +3843,11 @@ module MarkdownExec
|
|
|
3802
3843
|
# store the transformed value in ENV
|
|
3803
3844
|
EnvInterface.set(name, transformed)
|
|
3804
3845
|
|
|
3805
|
-
set =
|
|
3846
|
+
set = code_line_to_assign_a_variable(
|
|
3806
3847
|
name, transformed, force: name_force[:force]
|
|
3807
3848
|
)
|
|
3808
3849
|
|
|
3809
3850
|
comment.empty? ? set : "#{set} # #{comment}"
|
|
3810
|
-
else
|
|
3811
|
-
"# #{comment}" if comment.empty?
|
|
3812
3851
|
end
|
|
3813
3852
|
end
|
|
3814
3853
|
rescue StandardError
|
|
@@ -4584,7 +4623,6 @@ module MarkdownExec
|
|
|
4584
4623
|
return value unless export.transform.present?
|
|
4585
4624
|
|
|
4586
4625
|
if export.transform.is_a? Symbol
|
|
4587
|
-
### TBD validate for symbol
|
|
4588
4626
|
value.send(export.transform)
|
|
4589
4627
|
else
|
|
4590
4628
|
format(
|
|
@@ -4722,7 +4760,9 @@ module MarkdownExec
|
|
|
4722
4760
|
|
|
4723
4761
|
when :exec, UxActSource::EXEC
|
|
4724
4762
|
command_result, = output_from_adhoc_bash_script_file(
|
|
4725
|
-
join_array_of_arrays(bash_script_lines, export.exec)
|
|
4763
|
+
join_array_of_arrays(bash_script_lines, export.exec),
|
|
4764
|
+
export,
|
|
4765
|
+
force: force
|
|
4726
4766
|
)
|
|
4727
4767
|
|
|
4728
4768
|
if command_result.exit_status == EXIT_STATUS_REQUIRED_EMPTY
|
|
@@ -4748,6 +4788,7 @@ module MarkdownExec
|
|
|
4748
4788
|
end
|
|
4749
4789
|
|
|
4750
4790
|
when :echo, UxActSource::ECHO
|
|
4791
|
+
wwp
|
|
4751
4792
|
command_result, exportable, new_lines = export_echo_with_code(
|
|
4752
4793
|
bash_script_lines,
|
|
4753
4794
|
export,
|
|
@@ -4756,7 +4797,7 @@ module MarkdownExec
|
|
|
4756
4797
|
)
|
|
4757
4798
|
|
|
4758
4799
|
when :edit, UxActSource::EDIT
|
|
4759
|
-
output =
|
|
4800
|
+
output = ''
|
|
4760
4801
|
begin
|
|
4761
4802
|
loop do
|
|
4762
4803
|
print "#{export.prompt} [#{export.default}]: "
|
|
@@ -4777,13 +4818,14 @@ module MarkdownExec
|
|
|
4777
4818
|
EnvInterface.set(export.name, output)
|
|
4778
4819
|
new_lines << { name: export.name, force: force,
|
|
4779
4820
|
text: output }
|
|
4780
|
-
command_result = CommandResult.new(stdout: output)
|
|
4781
4821
|
end
|
|
4822
|
+
command_result = CommandResult.new(stdout: output)
|
|
4782
4823
|
|
|
4783
4824
|
when :exec, UxActSource::EXEC
|
|
4784
4825
|
command_result, exportable, new_lines = output_from_adhoc_bash_script_file(
|
|
4785
4826
|
join_array_of_arrays(bash_script_lines, export.exec),
|
|
4786
|
-
export
|
|
4827
|
+
export,
|
|
4828
|
+
force: force
|
|
4787
4829
|
)
|
|
4788
4830
|
|
|
4789
4831
|
else
|
|
@@ -4829,7 +4871,8 @@ module MarkdownExec
|
|
|
4829
4871
|
bash_script_lines,
|
|
4830
4872
|
%(printf '%s' "#{export.echo}")
|
|
4831
4873
|
),
|
|
4832
|
-
export
|
|
4874
|
+
export,
|
|
4875
|
+
force: force
|
|
4833
4876
|
)
|
|
4834
4877
|
export_init = cr_echo.stdout.split("\n").first
|
|
4835
4878
|
command_result, exportable, new_lines = export_echo_with_code(
|
|
@@ -4844,7 +4887,8 @@ module MarkdownExec
|
|
|
4844
4887
|
# extract first line from 'exec' output
|
|
4845
4888
|
command_result, exportable, new_lines = output_from_adhoc_bash_script_file(
|
|
4846
4889
|
join_array_of_arrays(bash_script_lines, export.exec),
|
|
4847
|
-
export
|
|
4890
|
+
export,
|
|
4891
|
+
force: force
|
|
4848
4892
|
)
|
|
4849
4893
|
unless command_result.failure?
|
|
4850
4894
|
export_init = command_result.stdout.split("\n").first
|
|
@@ -4883,12 +4927,14 @@ module MarkdownExec
|
|
|
4883
4927
|
force: force,
|
|
4884
4928
|
silent: silent
|
|
4885
4929
|
)
|
|
4930
|
+
|
|
4886
4931
|
when :exec, UxActSource::EXEC
|
|
4887
4932
|
raise unless export.exec.present?
|
|
4888
4933
|
|
|
4889
4934
|
command_result, exportable, new_lines = output_from_adhoc_bash_script_file(
|
|
4890
4935
|
join_array_of_arrays(bash_script_lines, export.exec),
|
|
4891
|
-
export
|
|
4936
|
+
export,
|
|
4937
|
+
force: force
|
|
4892
4938
|
)
|
|
4893
4939
|
|
|
4894
4940
|
else
|
|
@@ -5554,6 +5600,16 @@ module MarkdownExec
|
|
|
5554
5600
|
link_block_data[LinkKeys::FILE] || @delegate_object[:filename]
|
|
5555
5601
|
end
|
|
5556
5602
|
end
|
|
5603
|
+
|
|
5604
|
+
def safe_yaml_load(body)
|
|
5605
|
+
return {} unless body&.present?
|
|
5606
|
+
|
|
5607
|
+
YAML.load(body.to_s)
|
|
5608
|
+
rescue Psych::SyntaxError => err
|
|
5609
|
+
wwe 'YAML parsing error', { body: body, error: err.message }
|
|
5610
|
+
rescue StandardError => err
|
|
5611
|
+
wwe 'YAML loading error', { body: body, error: err.message }
|
|
5612
|
+
end
|
|
5557
5613
|
end
|
|
5558
5614
|
|
|
5559
5615
|
class HashDelegator < HashDelegatorParent
|
data/lib/menu.src.yml
CHANGED
|
@@ -580,7 +580,8 @@
|
|
|
580
580
|
|
|
581
581
|
- :opt_name: import_pattern
|
|
582
582
|
:env_var: MDE_IMPORT_PATTERN
|
|
583
|
-
:default:
|
|
583
|
+
:default: >-
|
|
584
|
+
^(?<indention> *)@import +(?<name>\S+)(?<params>(?: +[A-Za-z_]\w*=(?:"[^"]*"|'[^']*'|\S+))*) *$
|
|
584
585
|
:procname: val_as_str
|
|
585
586
|
|
|
586
587
|
- :opt_name: line_decor_main
|
data/lib/menu.yml
CHANGED
|
@@ -490,7 +490,8 @@
|
|
|
490
490
|
:procname: val_as_str
|
|
491
491
|
- :opt_name: import_pattern
|
|
492
492
|
:env_var: MDE_IMPORT_PATTERN
|
|
493
|
-
:default:
|
|
493
|
+
:default: '^(?<indention> *)@import +(?<name>\S+)(?<params>(?: +[A-Za-z_]\w*=(?:"[^"]*"|''[^'']*''|\S+))*)
|
|
494
|
+
*$'
|
|
494
495
|
:procname: val_as_str
|
|
495
496
|
- :opt_name: line_decor_main
|
|
496
497
|
:env_var: MDE_LINE_DECOR_MAIN
|
data/lib/ww.rb
CHANGED
|
@@ -19,7 +19,34 @@ def ww(*objs, **kwargs)
|
|
|
19
19
|
# return the last item in the list, as the label is usually first
|
|
20
20
|
return objs.last unless $debug
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
locations = kwargs[:locations] || caller_locations
|
|
23
|
+
ww0(*objs, **kwargs.merge(locations: locations))
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# select enabled, for exceptions
|
|
27
|
+
# print a data object for the error, and the failing line
|
|
28
|
+
def wwe(*objs, **kwargs)
|
|
29
|
+
ww0(*objs, **kwargs.merge(locations: caller_locations[0..0]))
|
|
30
|
+
|
|
31
|
+
raise StandardError, objs.first[:error]
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# selectively enabled, for process tracking
|
|
35
|
+
# print the failing line
|
|
36
|
+
def wwp(*objs, **kwargs)
|
|
37
|
+
return objs.last unless $debug
|
|
38
|
+
|
|
39
|
+
ww(*objs, **kwargs.merge(locations: caller_locations[0..0]))
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
# selectively enabled, for tagged
|
|
43
|
+
# print the failing line
|
|
44
|
+
# eg wwt :line, 'data:', data
|
|
45
|
+
def wwt(*objs, **kwargs)
|
|
46
|
+
return objs.last if !$debug || %i[env].include?(objs.first)
|
|
47
|
+
|
|
48
|
+
formatted = ['Tagged', objs.first] + objs[1..]
|
|
49
|
+
ww(*formatted, **kwargs.merge(locations: caller_locations[0..0]))
|
|
23
50
|
end
|
|
24
51
|
|
|
25
52
|
def ww0(*objs,
|
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.1.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-06-
|
|
11
|
+
date: 2025-06-28 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: clipboard
|
|
@@ -124,6 +124,7 @@ files:
|
|
|
124
124
|
- bats/block-type-ux-hidden.bats
|
|
125
125
|
- bats/block-type-ux-invalid.bats
|
|
126
126
|
- bats/block-type-ux-readonly.bats
|
|
127
|
+
- bats/block-type-ux-require-chained.bats
|
|
127
128
|
- bats/block-type-ux-require.bats
|
|
128
129
|
- bats/block-type-ux-required-variables.bats
|
|
129
130
|
- bats/block-type-ux-row-format.bats
|
|
@@ -139,11 +140,13 @@ files:
|
|
|
139
140
|
- bats/history.bats
|
|
140
141
|
- bats/import-conflict.bats
|
|
141
142
|
- bats/import-duplicates.bats
|
|
143
|
+
- bats/import-with-text-substitution.bats
|
|
142
144
|
- bats/import.bats
|
|
143
145
|
- bats/indented-block-type-vars.bats
|
|
144
146
|
- bats/indented-multi-line-output.bats
|
|
145
147
|
- bats/line-decor-dynamic.bats
|
|
146
148
|
- bats/line-wrapping.bats
|
|
149
|
+
- bats/load-vars-state-demo.bats
|
|
147
150
|
- bats/markup.bats
|
|
148
151
|
- bats/mde.bats
|
|
149
152
|
- bats/option-expansion.bats
|
|
@@ -180,6 +183,7 @@ files:
|
|
|
180
183
|
- docs/dev/block-type-ux-hidden.md
|
|
181
184
|
- docs/dev/block-type-ux-invalid.md
|
|
182
185
|
- docs/dev/block-type-ux-readonly.md
|
|
186
|
+
- docs/dev/block-type-ux-require-chained.md
|
|
183
187
|
- docs/dev/block-type-ux-require.md
|
|
184
188
|
- docs/dev/block-type-ux-required-variables.md
|
|
185
189
|
- docs/dev/block-type-ux-row-format.md
|
|
@@ -197,12 +201,25 @@ files:
|
|
|
197
201
|
- docs/dev/import-duplicates-0.md
|
|
198
202
|
- docs/dev/import-duplicates-1.md
|
|
199
203
|
- docs/dev/import-missing.md
|
|
204
|
+
- docs/dev/import-substitution-basic.md
|
|
205
|
+
- docs/dev/import-substitution-compare.md
|
|
206
|
+
- docs/dev/import-substitution-export.md
|
|
207
|
+
- docs/dev/import-substitution-long.md
|
|
208
|
+
- docs/dev/import-substitution-mixed.md
|
|
209
|
+
- docs/dev/import-substitution-plant.md
|
|
210
|
+
- docs/dev/import-substitution-quotes.md
|
|
211
|
+
- docs/dev/import-substitution-research.md
|
|
212
|
+
- docs/dev/import-substitution-simple.md
|
|
213
|
+
- docs/dev/import-substitution-special.md
|
|
214
|
+
- docs/dev/import-substitution-taxonomy.md
|
|
215
|
+
- docs/dev/import-with-text-substitution.md
|
|
200
216
|
- docs/dev/import.md
|
|
201
217
|
- docs/dev/indented-block-type-vars.md
|
|
202
218
|
- docs/dev/indented-multi-line-output.md
|
|
203
219
|
- docs/dev/line-decor-dynamic.md
|
|
204
220
|
- docs/dev/line-wrapping.md
|
|
205
221
|
- docs/dev/linked-file.md
|
|
222
|
+
- docs/dev/load-mode-demo.md
|
|
206
223
|
- docs/dev/load1.sh
|
|
207
224
|
- docs/dev/load_code.md
|
|
208
225
|
- docs/dev/manage-saved-documents.md
|
|
@@ -236,6 +253,11 @@ files:
|
|
|
236
253
|
- examples/example-document-opts.md
|
|
237
254
|
- examples/import0.md
|
|
238
255
|
- examples/import1.md
|
|
256
|
+
- examples/import_with_substitution_demo.md
|
|
257
|
+
- examples/imports/mixed_template.md
|
|
258
|
+
- examples/imports/organism_template.md
|
|
259
|
+
- examples/imports/template_mustache.md
|
|
260
|
+
- examples/imports/template_vars.md
|
|
239
261
|
- examples/include.md
|
|
240
262
|
- examples/indent.md
|
|
241
263
|
- examples/index.md
|
|
@@ -259,9 +281,12 @@ files:
|
|
|
259
281
|
- examples/pause-after-execution.md
|
|
260
282
|
- examples/plant.md
|
|
261
283
|
- examples/port-blocks.md
|
|
284
|
+
- examples/raw_replacement_demo.md
|
|
285
|
+
- examples/recent_discoveries_demo.md
|
|
262
286
|
- examples/save.md
|
|
263
287
|
- examples/search.md
|
|
264
288
|
- examples/table-markup.md
|
|
289
|
+
- examples/template_syntax_demo.md
|
|
265
290
|
- examples/text-markup.md
|
|
266
291
|
- examples/title.md
|
|
267
292
|
- examples/variable-expansion-save-block.md
|