markdown_exec 3.2.0 → 3.4.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 (59) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +40 -0
  3. data/Gemfile.lock +1 -1
  4. data/Rakefile +5 -4
  5. data/bats/block-type-ux-echo-hash-transform.bats +1 -1
  6. data/bats/block-type-ux-exec-hash-transform.bats +8 -0
  7. data/bats/block-type-ux-exec-hash.bats +15 -0
  8. data/bats/block-type-ux-force.bats +9 -0
  9. data/bats/block-type-ux-formats.bats +8 -0
  10. data/bats/block-type-ux-no-name.bats +8 -0
  11. data/bats/block-type-ux-readonly.bats +1 -1
  12. data/bats/block-type-ux-row-format.bats +1 -1
  13. data/bats/command-substitution-options.bats +2 -2
  14. data/bats/import-directive-line-continuation.bats +9 -0
  15. data/bats/import-directive-parameter-symbols.bats +9 -0
  16. data/bats/import-duplicates.bats +4 -2
  17. data/bats/import-parameter-symbols.bats +8 -0
  18. data/bats/markup.bats +1 -1
  19. data/bats/option-expansion.bats +1 -1
  20. data/bats/options.bats +1 -1
  21. data/bats/table-column-truncate.bats +1 -1
  22. data/bats/table.bats +1 -1
  23. data/bats/test_helper.bash +4 -3
  24. data/bin/tab_completion.sh +5 -1
  25. data/docs/dev/block-type-ux-echo-hash-transform.md +14 -12
  26. data/docs/dev/block-type-ux-exec-hash-transform.md +37 -0
  27. data/docs/dev/block-type-ux-exec-hash.md +93 -0
  28. data/docs/dev/block-type-ux-force.md +20 -0
  29. data/docs/dev/block-type-ux-formats.md +58 -0
  30. data/docs/dev/block-type-ux-no-name.md +17 -0
  31. data/docs/dev/block-type-ux-row-format.md +1 -1
  32. data/docs/dev/hexdump_format.md +267 -0
  33. data/docs/dev/import/parameter-symbols.md +6 -0
  34. data/docs/dev/import-directive-line-continuation.md +6 -0
  35. data/docs/dev/import-directive-parameter-symbols.md +9 -0
  36. data/docs/dev/import-parameter-symbols-template.md +24 -0
  37. data/docs/dev/import-parameter-symbols.md +6 -0
  38. data/docs/dev/load-vars-state-demo.md +35 -0
  39. data/docs/dev/table-column-truncate.md +1 -1
  40. data/docs/ux-blocks-examples.md +2 -3
  41. data/examples/import_with_substitution_demo.md +130 -26
  42. data/examples/imports/organism_template.md +86 -29
  43. data/lib/cached_nested_file_reader.rb +279 -29
  44. data/lib/constants.rb +8 -1
  45. data/lib/env_interface.rb +13 -7
  46. data/lib/evaluate_shell_expressions.rb +1 -0
  47. data/lib/fcb.rb +133 -33
  48. data/lib/format_table.rb +77 -29
  49. data/lib/fout.rb +5 -0
  50. data/lib/hash_delegator.rb +1159 -348
  51. data/lib/markdown_exec/version.rb +1 -1
  52. data/lib/markdown_exec.rb +2 -0
  53. data/lib/mdoc.rb +13 -11
  54. data/lib/menu.src.yml +166 -62
  55. data/lib/menu.yml +143 -59
  56. data/lib/string_util.rb +80 -0
  57. data/lib/table_extractor.rb +170 -64
  58. data/lib/ww.rb +810 -36
  59. metadata +22 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8c39aff829d6b7a3d4eb05134922cdb6fed1d54192fab72ba244d7d7ff73183e
4
- data.tar.gz: f2bbfa6b9be857c718ba23c1bbc071b91ffe7ba027626c9a27b1d06c8bfce5a9
3
+ metadata.gz: ec9a613148346890f4db46f3f5bdcade05b8e2221e92402c431fa9a359556e1e
4
+ data.tar.gz: 05d16eaf1ac5d433c8da62513da88159313e3b2898d36d7dfa0d71061c83a97b
5
5
  SHA512:
6
- metadata.gz: 1b97c91ff7b91da388ff9d3aed19ee5e15fd25bd4d6e8f3591a8997614736e27e1c12fb3682a3395bae5853131578b924cbf55284ffda2beb9b89843c8b7c2b7
7
- data.tar.gz: 3056e41d512fa097204cae511a057b193c5ad3c70e406dee3da1df369bb0bed4f517137cf55e86ac6fcdc1308b70d604c75e9c2c2ee8c9b30edf0d5f574c006e
6
+ metadata.gz: 9dcec89e521fc194eb329b36dc83068a11215186c5e3e5447485000a40c8e75f8bdabd10824af34b9ff90fee3f0899d5bb0f82f76f4ffa3a0a950d213585e6a5
7
+ data.tar.gz: 06b8fb5443b026e628fd60962bd9c7abbccd78824ea0d0b001f27b4608cc0cb147fff6fa00eac5de3712ed97f76d50296b35368675478992e06b28db06b29dfc
data/CHANGELOG.md CHANGED
@@ -1,5 +1,45 @@
1
1
  # Changelog
2
2
 
3
+ ## [3.4.0] - 2025-09-16
4
+
5
+ ### Added
6
+
7
+ - Accept line continuation for an import directive.
8
+ - Debug methods for block form and direct evaluation
9
+ - Color families indicate related functionality.
10
+
11
+ ### Changed
12
+
13
+ - Size table columns to fit.
14
+ - Name key is not required for all UX blocks. Display the formatted string if specified. Display the last key in the echo or exec hash otherwise.
15
+
16
+ ## [3.3.0] - 2025-09-02
17
+
18
+ ### Added
19
+
20
+ - Process Shell, Vars, and UX blocks in sequence.
21
+ - A personal exclude file that is not checked in.
22
+ - Option to annotate required lines.
23
+ - Option to make the directory if it does not exist when saving inherited code.
24
+ - Support for single-line tables.
25
+ - Options to decorate UX blocks per its activation.
26
+ - Special value '0' for environment variable 'WW' silences it. Otherwise, 'WW' outputs that it's testing new algorithm when the app is started.
27
+ - Apply text substitutions for each parameter according to a symbol.
28
+
29
+ ### Changed
30
+
31
+ - Trigger a selected block by it ID instead of its name. Stops co-triggering of blocks with and without names.
32
+ - Imported documents are skipped if duplicate. Importing a document with alternate parameters makes it unique.
33
+ - Set multiple variables in a UX block:
34
+ - UX blocks set multiple variables from echo expansions or exec evaluations
35
+ - Automatic allowed value based on echo or exec is the first line of the first variable set by the block
36
+ - Debug output improvements:
37
+ - Debug output indicates the depth of the call stack in each line.
38
+ - Add a function to alert and abort
39
+ - Add an environment variable to the log file name to document variations.
40
+ - Remove an unused option.
41
+ - Improve handling of interrupt at prompt.
42
+
3
43
  ## [3.2.0] - 2025-07-24
4
44
 
5
45
  ### Added
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- markdown_exec (3.2.0)
4
+ markdown_exec (3.4.0)
5
5
  clipboard (~> 1.3.6)
6
6
  open3 (~> 0.1.1)
7
7
  optparse (~> 0.1.1)
data/Rakefile CHANGED
@@ -103,9 +103,9 @@ task :bats do
103
103
  execute_with_error_handling(FileList['bats/**/*.bats']) do |file|
104
104
  next nil if %w[bats/bats.bats bats/fail.bats].include?(file)
105
105
 
106
- # temporary clear WW to disable debugging
107
- # WW pollutes output expected by BATS tests
108
- %(unset WW; bats #{file})
106
+ # If enabled, WW pollutes stderr processed by BATS tests
107
+ # silence with WW=0
108
+ %(export WW=0; bats #{file})
109
109
  end
110
110
  end
111
111
 
@@ -146,7 +146,8 @@ task :minitest do
146
146
  './lib/saved_assets.rb --verbose',
147
147
  './lib/saved_files_matcher.rb --verbose',
148
148
  './lib/table_extractor.rb --verbose',
149
- './lib/text_analyzer.rb --verbose'
149
+ './lib/text_analyzer.rb --verbose',
150
+ './lib/ww.rb --verbose'
150
151
  ]
151
152
 
152
153
  execute_with_error_handling(commands) do |command|
@@ -4,5 +4,5 @@ load 'test_helper'
4
4
 
5
5
  @test 'Each key in the echo hash is processed.' {
6
6
  spec_mde_xansi_dname_doc_blocks_expect docs/dev/block-type-ux-echo-hash-transform.md \
7
- 'Tapanuli Orangutan_Species: PONGO TAPANULIENSIS_Genus: PONGO_Tapanuli Orangutan_Family: H:Hominidae_Order: P:Primates'
7
+ 'Tapanuli Orangutan_Species: PONGO TAPANULIENSIS_Genus: PONGO_Tapanuli Orangutan_Family: H:Hominidae_Order: P:Primates_Psychedelic Frogfish_Species2: Haccdeeehhiiilnopprsstyy_Genus2: Hehiinoprsty_Family2: Aaadeeiinnnrt'
8
8
  }
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bats
2
+
3
+ load 'test_helper'
4
+
5
+ @test 'Each key in the exec hash is processed.' {
6
+ spec_mde_xansi_dname_doc_blocks_expect docs/dev/block-type-ux-exec-hash-transform.md \
7
+ 'Cappuccino Snake_Species_ H Y D R O D Y N A S T E S B I_ 48 59 44 52 4F 44 59 4E 41 53 54 45 53 20 42 49_ C I N C T U S _ _ 43 49 4E 43 54 55 53 0A_Genus_ H Y D R O D Y N A S T E S _ _ 48 59 44 52 4F 44 59 4E 41 53 54 45 53 0A_Family_ C O L U B R I D A E_ 43 4F 4C 55 42 52 49 44 41 45_Order_ S u m t _ _ 53 75 6D 74 0A_Class_ R p i i_ 52 70 69 69_Phylum_ C o d t_ 43 6F 64 74'
8
+ }
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env bats
2
+
3
+ load 'test_helper'
4
+
5
+ @test 'automatic' {
6
+ spec_mde_xansi_dname_doc_blocks_expect docs/dev/block-type-ux-exec-hash.md \
7
+ 'A single named variable is set automatically as the_output of the exec string._Common_Name=Yeti Crab__Common_Name=Yeti Crab_ Y e t i C r a b _ _ 59 65 74 69 20 43 72 61 62 0A__Multiple variables are set automatically as the_output of each exec string._One variable is temporary/not stored to inherited lines_but available for calculations within the block._Domain=ukaryota_____D=_Domain=ukaryota_ u k a r y o t a _ _ _ 75 6B 61 72 79 6F 74 61 0A 0A__A single named variable is set interactively as the_output of the exec string._Year_Discovered=_Year_Discovered=_$(hexdump_format "$Year_Discovered")__Multiple variables are set interactively as the_output of the exec string._Genus=_Species=_$(hexdump_format "$Species")_Genus=_$(hexdump_format "$Genus")__A single named variable is set automatically as the_first line of the output of the first element in the echo_hash._Kingdom=Animalia_Kingdom=Animalia_ A n i m a l i a_ 41 6E 69 6D 61 6C 69 61__A single named variable is set automatically as the_first line of the output of the first element in the exec_hash._Class=Malacostraca_Class=Malacostraca_ M a l a c o s t r a c a_ 4D 61 6C 61 63 6F 73 74 72 61 63 61'
8
+ }
9
+
10
+ @test 'interactive' {
11
+ spec_mde_xansi_dname_doc_blocks_expect docs/dev/block-type-ux-exec-hash.md \
12
+ '[Year_Discovered]' \
13
+ '[Genus]' \
14
+ 'A single named variable is set automatically as the_output of the exec string._Common_Name=Yeti Crab__Common_Name=Yeti Crab_ Y e t i C r a b _ _ 59 65 74 69 20 43 72 61 62 0A__Multiple variables are set automatically as the_output of each exec string._One variable is temporary/not stored to inherited lines_but available for calculations within the block._Domain=ukaryota_____D=_Domain=ukaryota_ u k a r y o t a _ _ _ 75 6B 61 72 79 6F 74 61 0A 0A__A single named variable is set interactively as the_output of the exec string._Year_Discovered=2005__Year_Discovered=2005_ 2 0 0 5 _ _ 32 30 30 35 0A__Multiple variables are set interactively as the_output of the exec string._Genus=Kiwa___Species=Kiwa hirsuta_ K i w a h i r s u t a _ _ 4B 69 77 61 20 68 69 72 73 75 74 61 0A_Genus=Kiwa_ K i w a _ _ _ 4B 69 77 61 0A 0A__A single named variable is set automatically as the_first line of the output of the first element in the echo_hash._Kingdom=Animalia_Kingdom=Animalia_ A n i m a l i a_ 41 6E 69 6D 61 6C 69 61__A single named variable is set automatically as the_first line of the output of the first element in the exec_hash._Class=Malacostraca_Class=Malacostraca_ M a l a c o s t r a c a_ 4D 61 6C 61 63 6F 73 74 72 61 63 61'
15
+ }
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env bats
2
+
3
+ load 'test_helper'
4
+
5
+ # UX before VARS although VARS appears first
6
+ @test 'automatic' {
7
+ spec_mde_xansi_dname_doc_blocks_expect docs/dev/block-type-ux-force.md \
8
+ 'Common_Name = Tapanuli Orangutan_ inherited_lines_ - : Common_Name="Tapanuli Orangutan"_ - : Common_Name=Ruby\ Seadragon_Common_Name=Ruby Seadragon_| Common_Name | Ruby Seadragon |'
9
+ }
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bats
2
+
3
+ load 'test_helper'
4
+
5
+ @test 'UX block appearance' {
6
+ spec_mde_xansi_dname_doc_blocks_expect docs/dev/block-type-ux-formats.md \
7
+ 'Demonstrate UX block appearance according to its state.__A simple variable declaration._EDIT VAR1 = value1__A selection from predefined options._ALLOW VAR2 = value2__A computed value using command substitution._ECHO VAR3 = Gemfile__An editable computed value._EDIT VAR4 = Gemfile__A command execution with formatted output._EXEC VAR5 = Gemfile___A read-only value._READONLY VAR6 = Gemfile_'
8
+ }
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bats
2
+
3
+ load 'test_helper'
4
+
5
+ @test 'displays last key in hash' {
6
+ spec_mde_xansi_dname_doc_blocks_expect docs/dev/block-type-ux-no-name.md \
7
+ 'OPERATION1=exec_OPERATION2=exec__'
8
+ }
@@ -5,6 +5,6 @@ load 'test_helper'
5
5
  @test 'automatic block - disabled' {
6
6
  spec_mde_args_expect \
7
7
  docs/dev/block-type-ux-readonly.md \
8
- --list-blocks-message readonly --list-blocks-type 3 --list-blocks \
8
+ --blocks readonly \
9
9
  true
10
10
  }
@@ -4,5 +4,5 @@ load 'test_helper'
4
4
 
5
5
  @test 'Row format merges with prior table' {
6
6
  spec_mde_xansi_dname_doc_blocks_expect docs/dev/block-type-ux-row-format.md \
7
- " | Variable | Value | Prompt |_ | ---------- | -------------------- | --------------------- |_ | Species | Pongo tapanuliensis | New species? |_ | Name: Genu | Value: Xform: 'Pongo | Prompt: New genus? |_ | Family | Hominidae | Enter a value: |"
7
+ " | Variable | Value | Prompt |_ | ----------- | --------------------- | ---------------------- |_ | Species | Pongo tapanuliensis | New species? |_ | Name: Genus | Value: Xform: 'Pongo' | Prompt: New genus? |_ | Family | Hominidae | Enter a value: |"
8
8
  }
@@ -5,10 +5,10 @@ load 'test_helper'
5
5
  @test 'Operator $' {
6
6
  spec_mde_xansi_dname_doc_blocks_expect docs/dev/command-substitution-options.md \
7
7
  'operator_$' \
8
- 'Command substitution__The current value of environment variable Common_Name_is displayed using two different operators._The command echo $SHLVL is executed via command_substitution, using two different operators.__| Operato | Variable Expansio | Command Substitutio |_| ------- | ----------------- | ------------------- |_| $ | Tapanuli Oranguta | Pongo tapanuliensis |_| @ | @{Common_Name} | @(echo $Species) |__Toggle between operators.__operator_$__operator_@'
8
+ 'Command substitution__The current value of environment variable Common_Name_is displayed using two different operators._The command echo $SHLVL is executed via command_substitution, using two different operators.__| Operator | Variable Expansion | Command Substitution |_| -------- | ------------------ | -------------------- |_| $ | Tapanuli Orangutan | Pongo tapanuliensis |_| @ | @{Common_Name} | @(echo $Species) |__Toggle between operators.__operator_$__operator_@'
9
9
  }
10
10
 
11
11
  @test 'Operator @' {
12
12
  spec_mde_xansi_dname_doc_blocks_expect docs/dev/command-substitution-options.md \
13
- 'Command substitution__The current value of environment variable Common_Name_is displayed using two different operators._The command echo $SHLVL is executed via command_substitution, using two different operators.__| Operato | Variable Expansio | Command Substitutio |_| ------- | ----------------- | ------------------- |_| $ | ${Common_Name} | $(echo $Species) |_| @ | Tapanuli Oranguta | Pongo tapanuliensis |__Toggle between operators.__operator_$__operator_@'
13
+ 'Command substitution__The current value of environment variable Common_Name_is displayed using two different operators._The command echo $SHLVL is executed via command_substitution, using two different operators.__| Operator | Variable Expansion | Command Substitution |_| -------- | ------------------ | -------------------- |_| $ | ${Common_Name} | $(echo $Species) |_| @ | Tapanuli Orangutan | Pongo tapanuliensis |__Toggle between operators.__operator_$__operator_@'
14
14
  }
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env bats
2
+
3
+ load 'test_helper'
4
+
5
+ @test '' {
6
+ spec_mde_xansi_dname_doc_blocks_expect docs/dev/import-directive-line-continuation.md \
7
+ --blocks dname \
8
+ 'Stem: U1_Species: Illacme tobini_Genus: Illacme'
9
+ }
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env bats
2
+
3
+ load 'test_helper'
4
+
5
+ @test '' {
6
+ spec_mde_xansi_dname_doc_blocks_expect docs/dev/import-directive-parameter-symbols.md \
7
+ --blocks dname \
8
+ 'Stem: U1_Species: Illacme tobini_Genus: Illacme_Stem: U2_Species: Hydrodynastes bicinctus_Genus: Hydrodynastes'
9
+ }
@@ -20,20 +20,22 @@ load 'test_helper'
20
20
  '_d1.1_d0.1_u0.1'
21
21
  }
22
22
 
23
+ # a name in the CLI that matches multiple blocks only loads the first
23
24
  @test 'Import and require blocks with duplicate names - duplicate 0' {
24
25
  BATS_OUTPUT_FILTER=A
25
26
  BATS_SAFE=_
26
27
  spec_mde_args_expect docs/dev/import-duplicates-0.md \
27
28
  'd0' \
28
- '_d1.0_d1.1_d0.0_d0.1'
29
+ '_d1.0_d1.1_d0.1'
29
30
  }
30
31
 
32
+ # a name in the CLI that matches multiple blocks only loads the first
31
33
  @test 'Import and require blocks with duplicate names - duplicate 1' {
32
34
  BATS_OUTPUT_FILTER=A
33
35
  BATS_SAFE=_
34
36
  spec_mde_args_expect docs/dev/import-duplicates-0.md \
35
37
  'd1' \
36
- '_d1.1_d0.1'
38
+ '_d1.1'
37
39
  }
38
40
 
39
41
  @test 'Import and require blocks with duplicate names - unique in import 0' {
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bats
2
+
3
+ load 'test_helper'
4
+
5
+ @test 'Initial values' {
6
+ spec_mde_xansi_dname_doc_blocks_expect docs/dev/import-parameter-symbols.md \
7
+ 'COMMON_NAME=Tapanuli Orangutan_Command substitution: Tapanuli Orangutan_echo "Command substitution: ${NAMEC}"__Evaluated expression: Tapanuli Orangutan_echo "Evaluated expression: ${NAMEE}"__Raw literal: Tapanuli Orangutan_echo "Raw literal: Tapanuli Orangutan"__Force-quoted literal: Tapanuli Orangutan_echo "Force-quoted literal: ${NAMEQ}"__Variable reference: Tapanuli Orangutan_echo "Variable reference: ${COMMON_NAME}"'
8
+ }
data/bats/markup.bats CHANGED
@@ -16,7 +16,7 @@ load 'test_helper'
16
16
 
17
17
  @test 'Options - list blocks - 3 decorates' {
18
18
  spec_mde_args_expect docs/dev/text-decoration.md \
19
- --list-blocks-message dname --list-blocks-type 3 --list-blocks \
19
+ --blocks dname \
20
20
  $'\x1b\x5b\x33\x38\x3b\x32\x3b\x31\x39\x32\x3b\x31\x39\x32\x3b\x31\x39\x32\x6d\x2d\x20\x1b\x5b\x30\x6d\x1b\x5b\x31\x6d\x1b\x5b\x34\x6d\x42\x6f\x6c\x64\x2d\x55\x6e\x64\x65\x72\x6c\x69\x6e\x65\x1b\x5b\x32\x32\x6d\x1b\x5b\x32\x34\x6d\x0a\x1b\x5b\x33\x38\x3b\x32\x3b\x31\x39\x32\x3b\x31\x39\x32\x3b\x31\x39\x32\x6d\x2d\x20\x1b\x5b\x30\x6d\x1b\x5b\x31\x6d\x42\x6f\x6c\x64\x1b\x5b\x32\x32\x6d\x0a\x1b\x5b\x33\x38\x3b\x32\x3b\x31\x39\x32\x3b\x31\x39\x32\x3b\x31\x39\x32\x6d\x2d\x20\x1b\x5b\x30\x6d\x1b\x5b\x31\x6d\x1b\x5b\x33\x6d\x42\x6f\x6c\x64\x2d\x49\x74\x61\x6c\x69\x63\x1b\x5b\x32\x32\x6d\x1b\x5b\x32\x33\x6d\x0a\x1b\x5b\x33\x38\x3b\x32\x3b\x31\x39\x32\x3b\x31\x39\x32\x3b\x31\x39\x32\x6d\x2d\x20\x1b\x5b\x30\x6d\x1b\x5b\x34\x6d\x55\x6e\x64\x65\x72\x6c\x69\x6e\x65\x1b\x5b\x32\x34\x6d\x0a\x1b\x5b\x33\x38\x3b\x32\x3b\x31\x39\x32\x3b\x31\x39\x32\x3b\x31\x39\x32\x6d\x2d\x20\x1b\x5b\x30\x6d\x1b\x5b\x34\x6d\x1b\x5b\x33\x6d\x55\x6e\x64\x65\x72\x6c\x69\x6e\x65\x2d\x49\x74\x61\x6c\x69\x63\x1b\x5b\x32\x33\x6d\x1b\x5b\x32\x34\x6d\x0a\x1b\x5b\x33\x38\x3b\x32\x3b\x31\x39\x32\x3b\x31\x39\x32\x3b\x31\x39\x32\x6d\x2d\x20\x1b\x5b\x30\x6d\x1b\x5b\x33\x6d\x49\x74\x61\x6c\x69\x63\x1b\x5b\x32\x33\x6d\x0a\x1b\x5b\x33\x38\x3b\x32\x3b\x31\x39\x32\x3b\x31\x39\x32\x3b\x31\x39\x32\x6d\x2d\x20\x1b\x5b\x30\x6d\x1b\x5b\x39\x6d\x53\x74\x72\x69\x6b\x65\x74\x68\x72\x6f\x75\x67\x68\x1b\x5b\x32\x39\x6d'
21
21
  }
22
22
 
@@ -4,5 +4,5 @@ load 'test_helper'
4
4
 
5
5
  @test '' {
6
6
  spec_mde_xansi_dname_doc_blocks_expect docs/dev/option-expansion.md \
7
- '_| Optio | Description | Value | Va | Def |_| ----- | -------------------------------- | ----- | -- | --- |_| scree | Screen width for document and in | 2 | 64 | 0 |_| table | | 5 | fa | tru |'
7
+ '_| Opti | Description | Valu | Va | Defau |_| ---- | ---------------------------- | ---- | -- | ----- |_| scre | Screen width for document an | 2 | 64 | 0 |_| tabl | | 5 | fa | true |'
8
8
  }
data/bats/options.bats CHANGED
@@ -74,7 +74,7 @@ load 'test_helper'
74
74
  @test 'Options - load-code' {
75
75
  spec_mde_xansi_dname_doc_blocks_expect docs/dev/load_code.md \
76
76
  --load-code docs/dev/load1.sh \
77
- --list-blocks-message dname --list-blocks-type 3 --list-blocks \
77
+ --blocks dname \
78
78
  'Demonstrate loading inherited code via the command line.__Run this command to display the inherited code._mde --load-code docs/dev/load1.sh docs/dev/load_code.md__| Variable | Value |_| -------- | ----- |_| var1 | line2 |_| var2 | line4 |'
79
79
  }
80
80
 
@@ -4,5 +4,5 @@ load 'test_helper'
4
4
 
5
5
  @test 'Tables - truncate columns' {
6
6
  spec_mde_xansi_dname_doc_blocks_expect docs/dev/table-column-truncate.md \
7
- 'DEMONSTRATE TRUNCATION OF TEXT IN TABLE CELLS__| Common Name | Species | Genus | Family | Year Di |_| ------------ | ------------ | ----- | ------- | ------- |_| Tapanuli Ora | Pongo tapanu | Pongo | Hominid | 2017 |_| Psychedelic | Histiophryne | Histi | Antenna | 2009 |_| Ruby Seadrag | Phyllopteryx | Phyll | Syngnat | 2015 |_| Illacme tobi | Illacme tobi | Illac | Siphono | 2016 |_| Spiny Dandel | Taraxacum ja | Tarax | Asterac | 2022 |_'
7
+ 'DEMONSTRATE TRUNCATION OF TEXT IN TABLE CELLS__| Common Name | Species | Genus | Family | Year Discover |_| ------------------- | ------------------ | -------- | ----------- | ------------- |_| Tapanuli Orangutan | Pongo tapanuliensi | Pongo | Hominidae | 2017 |_| Psychedelic Frogfis | Histiophryne psych | Histioph | Antennariid | 2009 |_| Ruby Seadragon | Phyllopteryx dewys | Phyllopt | Syngnathida | 2015 |_| Illacme tobini (Mil | Illacme tobini | Illacme | Siphonorhin | 2016 |_| Spiny Dandelion | Taraxacum japonicu | Taraxacu | Asteraceae | 2022 |_'
8
8
  }
data/bats/table.bats CHANGED
@@ -4,7 +4,7 @@ load 'test_helper'
4
4
 
5
5
  @test 'Tables - indented' {
6
6
  spec_mde_xansi_dname_doc_blocks_expect docs/dev/table-indent.md \
7
- 'DEMONSTRATE TABLE INDENTATION__Table flush at left._Centered columns._| Common Name | Species | Genus | Family | Year Discover |_| ------------------ | ---------------------- | ---------- | ----------- | ------------- |_| Tapanuli Orangutan | Pongo tapanuliensis | Pongo | Hominidae | 2017 |_| Psychedelic Frogfi | Histiophryne psychedel | Histiophry | Antennariid | 2009 |_| Ruby Seadragon | Phyllopteryx dewysea | Phyllopter | Syngnathida | 2015 |__ Table indented with two spaces._ Left-justified columns._ | Common Name | Species | Genus | Family | Year Discovere |_ | ------------------------- | ------------- | ------ | -------------- | -------------- |_ | Illacme tobini (Millipede | Illacme tobin | Illacm | Siphonorhinida | 2016 |__ Table indented with one tab._ Right-justified columns._ | Common Name | Species | Genus | Family | Year Discovered |_ | --------------- | ------------------- | --------- | ---------- | --------------- |_ | Spiny Dandelion | Taraxacum japonicum | Taraxacum | Asteraceae | 2022 |'
7
+ 'DEMONSTRATE TABLE INDENTATION__Table flush at left._Centered columns._| Common Name | Species | Genus | Family | Year Discovered |_| ------------------ | ----------------------- | ----------- | ------------ | --------------- |_| Tapanuli Orangutan | Pongo tapanuliensis | Pongo | Hominidae | 2017 |_| Psychedelic Frogfi | Histiophryne psychedeli | Histiophryn | Antennariida | 2009 |_| Ruby Seadragon | Phyllopteryx dewysea | Phylloptery | Syngnathidae | 2015 |__ Table indented with two spaces._ Left-justified columns._ | Common Name | Species | Genus | Family | Year Discovered |_ | -------------------------- | -------------- | ------- | --------------- | --------------- |_ | Illacme tobini (Millipede) | Illacme tobini | Illacme | Siphonorhinidae | 2016 |__ Table indented with one tab._ Right-justified columns._ | Common Name | Species | Genus | Family | Year Discovered |_ | --------------- | ------------------- | --------- | ---------- | --------------- |_ | Spiny Dandelion | Taraxacum japonicum | Taraxacum | Asteraceae | 2022 |'
8
8
  }
9
9
 
10
10
  @test 'Tables - invalid' {
@@ -7,6 +7,7 @@ EXIT_MENU=__Exit # name of menu Exit option
7
7
  # • expected byte (0xHEX) and printable character (or “.”)
8
8
  # • actual byte (0xHEX) and printable character (or “.”)
9
9
  compare_bytes () {
10
+ readonly line_count=16
10
11
  set +e
11
12
  local mode="$1"; shift
12
13
  if [[ "$mode" == "--file" ]]; then
@@ -19,13 +20,13 @@ compare_bytes () {
19
20
  # feed the two strings into cmp via process-substitution
20
21
  cmp --verbose <(printf '%s' "$live") <(printf '%s' "$expect")
21
22
  fi |
22
- head -n 3 |
23
+ head -n $line_count |
23
24
  gawk '{
24
25
  live = strtonum(0 $2)
25
26
  expect = strtonum(0 $3)
26
27
  offset = $1 - 1
27
- printf "Offset 0x%X (%4d): output \"%c\" 0x%02X (%3d) vs expect \"%c\" 0x%02X (%3d)\n", \
28
- offset, offset, live, live, live, expect, expect, expect
28
+ printf "Offset 0x%X (%4d): expect \"%c\" 0x%02X (%3d) vs output \"%c\" 0x%02X (%3d)\n", \
29
+ offset, offset, expect, expect, expect, live, live, live
29
30
  }'
30
31
  set -e
31
32
  }
@@ -26,6 +26,8 @@ _mde() {
26
26
  if [[ ${prev} == -* ]] ; then
27
27
  case $prev in
28
28
 
29
+ --blocks) COMPREPLY="''"; return 0 ;;
30
+
29
31
  --config) COMPREPLY="."; return 0 ;;
30
32
 
31
33
  --debug) COMPREPLY="f"; return 0 ;;
@@ -108,7 +110,7 @@ _mde() {
108
110
  # present matching option names
109
111
  #
110
112
  if [[ ${cur} == -* ]] ; then
111
- opts=("--block-name" "--config" "--debug" "--dig" "--dump-blocks-in-file" "--dump-delegate-object" "--dump-dependencies" "--dump-inherited-block-names" "--dump-inherited-dependencies" "--dump-inherited-lines" "--dump-menu-blocks" "--dump-selected-block" "--execute-in-own-window" "--exit" "--filename" "--find" "--find-path" "--help" "--history" "--how" "--list-blocks" "--list-blocks-eval" "--list-blocks-message" "--list-blocks-type" "--list-count" "--list-default-env" "--list-default-yaml" "--list-docs" "--format" "--list-recent-output" "--list-recent-scripts" "--load-code" "--mine" "--open" "--output-script" "--output-stdout" "--path" "--pause-after-script-execution" "--probe" "--publish-document-file-mode" "--publish-document-file-name" "--pwd" "--run-last-script" "--sift" "--tab-completions" "--user-must-approve" "--version" "--display-level")
113
+ opts=("--block-name" "--blocks" "--config" "--debug" "--dig" "--dump-blocks-in-file" "--dump-delegate-object" "--dump-dependencies" "--dump-inherited-block-names" "--dump-inherited-dependencies" "--dump-inherited-lines" "--dump-menu-blocks" "--dump-selected-block" "--execute-in-own-window" "--exit" "--filename" "--find" "--find-path" "--help" "--history" "--how" "--list-blocks" "--list-blocks-eval" "--list-blocks-message" "--list-blocks-type" "--list-count" "--list-default-env" "--list-default-yaml" "--list-docs" "--format" "--list-recent-output" "--list-recent-scripts" "--load-code" "--mine" "--open" "--output-script" "--output-stdout" "--path" "--pause-after-script-execution" "--probe" "--publish-document-file-mode" "--publish-document-file-name" "--pwd" "--run-last-script" "--sift" "--tab-completions" "--user-must-approve" "--version" "--display-level")
112
114
  COMPREPLY=( $(compgen -W "$(printf "'%s' " "${opts[@]}")" -- "${cur}") )
113
115
 
114
116
  return 0
@@ -125,6 +127,8 @@ _mde() {
125
127
 
126
128
  -b) COMPREPLY=".NAME."; return 0 ;;
127
129
 
130
+ --blocks) COMPREPLY=".MESSAGE."; return 0 ;;
131
+
128
132
  --config) COMPREPLY=".PATH."; return 0 ;;
129
133
 
130
134
  --debug) COMPREPLY=".BOOL."; return 0 ;;
@@ -25,16 +25,18 @@ validate: >
25
25
  ```
26
26
  Family: ${Family}
27
27
  Order: ${Order}
28
- //
29
- // Each key in the exec hash is processed.
30
- /```ux
31
- /exec:
32
- / Species2: printf %s 'Histiophryne psychedelica'
33
- / Genus2: printf %s 'Histiophryne'
34
- /format: Psychedelic Frogfish
35
- /name: Species2
36
- /transform: :downcase
37
- /```
38
- /Species2: ${Species2}
39
- /Genus2: ${Genus2}
28
+ /
29
+ / Each key in the echo hash is processed.
30
+ ```ux
31
+ echo:
32
+ Species2: Histiophryne psychedelica
33
+ Genus2: Histiophryne
34
+ Family2: Antennariidae
35
+ format: Psychedelic Frogfish
36
+ name: Common2
37
+ transform: :sort_chars
38
+ ```
39
+ Species2: ${Species2}
40
+ Genus2: ${Genus2}
41
+ Family2: ${Family2}
40
42
  @import bats-document-configuration.md
@@ -0,0 +1,37 @@
1
+ / Each key in the exec hash is processed.
2
+ ```ux
3
+ exec:
4
+ Species: echo 'Hydrodynastes bicinctus'
5
+ Genus: echo Hydrodynastes
6
+ Family: printf %s Colubridae
7
+ format: Cappuccino Snake
8
+ name: Common
9
+ transform: :upcase
10
+ ```
11
+ __Species__
12
+ $(hexdump_format "$Species")
13
+ __Genus__
14
+ $(hexdump_format "$Genus")
15
+ __Family__
16
+ $(hexdump_format "$Family")
17
+ /
18
+ ```ux :()
19
+ exec:
20
+ Order: echo Squamata
21
+ Class: printf %s Reptilia
22
+ Phylum: printf %s Chordata
23
+ name: Common
24
+ transform: :delete_even_chars
25
+ ```
26
+ __Order__
27
+ $(hexdump_format "$Order")
28
+ __Class__
29
+ $(hexdump_format "$Class")
30
+ __Phylum__
31
+ $(hexdump_format "$Phylum")
32
+ /
33
+ @import hexdump_format.md
34
+ @import bats-document-configuration.md
35
+ ```opts :(document_opts)
36
+ screen_width: 64
37
+ ```
@@ -0,0 +1,93 @@
1
+ A single named variable is set **automatically** as the output of the exec string.
2
+ ```ux
3
+ exec: echo 'Yeti Crab'
4
+ name: Common_Name
5
+ ```
6
+ Common_Name=${Common_Name}
7
+ $(hexdump_format "$Common_Name")
8
+
9
+
10
+
11
+ Multiple variables are set **automatically** as the output of each exec string.
12
+ One variable is temporary/not stored to inherited lines but available for calculations within the block.
13
+ / Substring Extraction using POSIX parameter expansion.
14
+ ```ux
15
+ exec:
16
+ __D: >-
17
+ echo 'Domain: Eukaryota'
18
+ Domain: >-
19
+ echo "${__D:7,9}"
20
+ name: Domain
21
+ ```
22
+ __D=${__D}
23
+ Domain=${Domain}
24
+ $(hexdump_format "$Domain")
25
+
26
+
27
+
28
+ A single named variable is set **interactively** as the output of the exec string.
29
+ ```ux :[Year_Discovered]
30
+ exec: echo 2005
31
+ init: false
32
+ name: Year_Discovered
33
+ ```
34
+ Year_Discovered=${Year_Discovered}
35
+ $(hexdump_format "$Year_Discovered")
36
+
37
+
38
+
39
+ Multiple variables are set **interactively** as the output of the exec string.
40
+ / String Replacement
41
+ ```ux :[Genus]
42
+ exec:
43
+ Species: echo 'Kiwa hirsuta'
44
+ Genus: echo "${Species/ hirsuta/}"
45
+ init: false
46
+ name: Genus
47
+ ```
48
+ Species=${Species}
49
+ $(hexdump_format "$Species")
50
+ Genus=${Genus}
51
+ $(hexdump_format "$Genus")
52
+
53
+
54
+
55
+ A single named variable is set **automatically** as the first line of the output of the first element in the echo hash.
56
+ ```ux
57
+ allow: :echo
58
+ echo:
59
+ __K: |
60
+ Animalia
61
+ Animalia2
62
+ __P: |
63
+ Arthropoda
64
+ Arthropoda2
65
+ name: Kingdom
66
+ ```
67
+ Kingdom=${Kingdom}
68
+ $(hexdump_format "$Kingdom")
69
+
70
+
71
+
72
+ **A single named variable is set automatically** as the first line of the output of the first element in the exec hash.
73
+ ```ux
74
+ allow: :exec
75
+ exec:
76
+ __C: |
77
+ echo Malacostraca
78
+ echo Malacostraca2
79
+ __P: |
80
+ echo Arthropoda
81
+ echo Arthropoda2
82
+ name: Class
83
+ ```
84
+ Class=${Class}
85
+ $(hexdump_format "$Class")
86
+
87
+
88
+
89
+ @import hexdump_format.md
90
+ @import bats-document-configuration.md
91
+ ```opts :(document_opts)
92
+ screen_width: 64
93
+ ```
@@ -0,0 +1,20 @@
1
+ / The variable is defined mulitple times.
2
+ / Blocks are evaluated in order from top to bottom.
3
+ / The VARS assignment is output.
4
+ / Inherited lines are output.
5
+ / This VARS block creates the first assignment.
6
+ ```vars :(document_vars)
7
+ Common_Name: Tapanuli Orangutan
8
+ ```
9
+ / This UX block forces the value in a second assignment.
10
+ ```ux :[2]
11
+ init: Ruby Seadragon
12
+ force: true
13
+ name: Common_Name
14
+ ```
15
+ ! Common_Name! ${Common_Name}
16
+ @import bats-document-configuration.md
17
+ ```opts :(document_opts)
18
+ dump_inherited_lines: true
19
+ table_center: false
20
+ ```
@@ -0,0 +1,58 @@
1
+ Demonstrate UX block appearance according to its state.
2
+
3
+ A simple variable declaration.
4
+ ```ux
5
+ init: value1
6
+ name: VAR1
7
+ ```
8
+
9
+ A selection from predefined options.
10
+ ```ux
11
+ act: :allow
12
+ allow:
13
+ - value2
14
+ name: VAR2
15
+ ```
16
+
17
+ A computed value using command substitution.
18
+ ```ux
19
+ act: :echo
20
+ echo: '`ls Gemfile`'
21
+ name: VAR3
22
+ ```
23
+
24
+ An editable computed value.
25
+ ```ux
26
+ act: :edit
27
+ echo: '`ls Gemfile`'
28
+ name: VAR4
29
+ ```
30
+
31
+ A command execution with formatted output.
32
+ ```ux
33
+ act: :exec
34
+ exec: ls Gemfile
35
+ name: VAR5
36
+ ```
37
+
38
+ A read-only value.
39
+ ```ux
40
+ exec: ls Gemfile
41
+ name: VAR6
42
+ readonly: true
43
+ ```
44
+ @import bats-document-configuration.md
45
+ ```opts :(document_opts)
46
+ menu_ux_row_format: 'DEFAULT %{name} = ${%{name}}'
47
+ menu_ux_row_format_allow: 'ALLOW %{name} = ${%{name}}'
48
+ menu_ux_row_format_echo: 'ECHO %{name} = ${%{name}}'
49
+ menu_ux_row_format_edit: 'EDIT %{name} = ${%{name}}'
50
+ menu_ux_row_format_exec: 'EXEC %{name} = ${%{name}}'
51
+ menu_ux_row_format_readonly: 'READONLY %{name} = ${%{name}}'
52
+ # menu_ux_color_readonly: fg_bg_rgbh_df_df_00_14_18_1c
53
+ menu_ux_color_allow: fg_rgbh_6f_00_7f
54
+ menu_ux_color_echo: fg_rgbh_3f_00_7f
55
+ menu_ux_color_edit: fg_rgbh_1f_00_7f
56
+ menu_ux_color_exec: fg_rgbh_1f_40_7f
57
+ menu_ux_color_readonly: fg_rgbh_1f_00_9f
58
+ ```
@@ -0,0 +1,17 @@
1
+ / This automatic block sets multiple variables and displays the first variable.
2
+ ```ux
3
+ echo:
4
+ BASENAME1: "$(basename `pwd`)"
5
+ DOCUMENTS1: "${BASENAME1%%_*}"
6
+ OPERATION1: "${BASENAME1##*_}"
7
+ ```
8
+ ```ux
9
+ exec:
10
+ BASENAME2: >-
11
+ basename `pwd`
12
+ DOCUMENTS2: >-
13
+ echo "${BASENAME2%%_*}"
14
+ OPERATION2: >-
15
+ echo "${BASENAME2##*_}"
16
+ ```
17
+ @import bats-document-configuration.md
@@ -40,7 +40,7 @@ name: Family
40
40
  @import bats-document-configuration.md
41
41
  ```opts :(document_opts)
42
42
  menu_ux_row_format: '| %{name}| ${%{name}}| %{prompt}'
43
- screen_width: 72
43
+ screen_width: 76
44
44
  table_center: true
45
45
  ux_auto_load_force_default: true
46
46
  ```