markdown_exec 2.8.2 → 2.8.4

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 (76) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +52 -0
  3. data/Gemfile.lock +1 -1
  4. data/Rakefile +33 -23
  5. data/bats/{block-types.bats → block-type-bash.bats} +0 -25
  6. data/bats/block-type-link.bats +9 -0
  7. data/bats/block-type-port.bats +16 -0
  8. data/bats/block-type-ux-allowed.bats +29 -0
  9. data/bats/block-type-ux-auto.bats +1 -1
  10. data/bats/block-type-ux-chained.bats +9 -0
  11. data/bats/block-type-ux-echo-hash.bats +14 -0
  12. data/bats/block-type-ux-echo.bats +20 -0
  13. data/bats/block-type-ux-exec.bats +1 -1
  14. data/bats/block-type-ux-hidden.bats +9 -0
  15. data/bats/block-type-ux-invalid.bats +8 -0
  16. data/bats/block-type-ux-preconditions.bats +8 -0
  17. data/bats/block-type-ux-readonly.bats +10 -0
  18. data/bats/block-type-ux-transform.bats +1 -1
  19. data/bats/block-type-vars.bats +3 -3
  20. data/bats/indented-block-type-vars.bats +9 -0
  21. data/bats/indented-multi-line-output.bats +9 -0
  22. data/bats/line-decor-dynamic.bats +8 -0
  23. data/bats/test_helper.bash +19 -2
  24. data/bats/variable-expansion-multiline.bats +8 -0
  25. data/bats/variable-expansion.bats +1 -1
  26. data/bin/tab_completion.sh +0 -5
  27. data/bin/tab_completion.sh.erb +0 -5
  28. data/docs/dev/block-type-ux-allowed.md +80 -0
  29. data/docs/dev/block-type-ux-chained.md +21 -0
  30. data/docs/dev/block-type-ux-echo-hash.md +72 -0
  31. data/docs/dev/block-type-ux-echo.md +21 -0
  32. data/docs/dev/block-type-ux-hidden.md +21 -0
  33. data/docs/dev/block-type-ux-invalid.md +5 -0
  34. data/docs/dev/block-type-ux-preconditions.md +9 -0
  35. data/docs/dev/block-type-ux-readonly.md +7 -0
  36. data/docs/dev/block-type-ux-require.md +8 -4
  37. data/docs/dev/indented-block-type-vars.md +6 -0
  38. data/docs/dev/indented-multi-line-output.md +11 -0
  39. data/docs/dev/line-decor-dynamic.md +10 -0
  40. data/docs/dev/variable-expansion-multiline.md +31 -0
  41. data/lib/ansi_formatter.rb +0 -1
  42. data/lib/ansi_string.rb +10 -1
  43. data/lib/array.rb +0 -1
  44. data/lib/array_util.rb +0 -1
  45. data/lib/block_label.rb +1 -1
  46. data/lib/cached_nested_file_reader.rb +1 -1
  47. data/lib/constants.rb +18 -0
  48. data/lib/directory_searcher.rb +1 -1
  49. data/lib/exceptions.rb +0 -1
  50. data/lib/fcb.rb +51 -8
  51. data/lib/filter.rb +4 -4
  52. data/lib/format_table.rb +1 -0
  53. data/lib/fout.rb +1 -1
  54. data/lib/hash.rb +0 -1
  55. data/lib/hash_delegator.rb +403 -200
  56. data/lib/link_history.rb +17 -17
  57. data/lib/logged_struct.rb +429 -0
  58. data/lib/markdown_exec/version.rb +1 -1
  59. data/lib/markdown_exec.rb +3 -3
  60. data/lib/mdoc.rb +5 -17
  61. data/lib/menu.src.yml +3 -1
  62. data/lib/menu.yml +1 -1
  63. data/lib/namer.rb +4 -5
  64. data/lib/null_result.rb +131 -0
  65. data/lib/object_present.rb +1 -1
  66. data/lib/option_value.rb +1 -1
  67. data/lib/resize_terminal.rb +1 -2
  68. data/lib/saved_assets.rb +1 -1
  69. data/lib/saved_files_matcher.rb +1 -1
  70. data/lib/shell_session.rb +439 -0
  71. data/lib/streams_out.rb +0 -1
  72. data/lib/string_util.rb +11 -1
  73. data/lib/success_result.rb +112 -0
  74. data/lib/text_analyzer.rb +1 -0
  75. data/lib/ww.rb +9 -7
  76. metadata +33 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 066c72f2f85462a89163b7834669dee6526e516ee3ebfe4be2e8b269cb4ece36
4
- data.tar.gz: 48c2bce9ac82cda2cbecca5bea4564b28013cdbab7005e249e8a856d0280afa0
3
+ metadata.gz: 7ace0bdaa8d2925a4274a4cfc039fdde5e9aaaf8bfbd761f21e0679417f71062
4
+ data.tar.gz: 0a9f38be8b322be828fe28cd19441da7a9bb032dd739aaa73ba0526456251503
5
5
  SHA512:
6
- metadata.gz: fe1270b8cf11efc8ad9e81cb43052bc75cfc217e362c7d6e30acb6981a6d0be749f290b9b15ce1a2655d6a7e157177c4cd975aa61de22a6f6bafe2a835285228
7
- data.tar.gz: 9445285db86af55fe5ba0b784a24d30dd418ac3d1dc551183a5a1b3b865df27a6b314ddc08b4a013de5e926e023439753fe08cd4ea8d6c6da0c0d9547e4a9546
6
+ metadata.gz: b0c0c4eea966bad0e29e0957e68049cfee1c61bd730fab880f63ea1501cba153dd1592ef415142a91a9aecd09802cf0bb48eac36607964b97ce372c9b249536f
7
+ data.tar.gz: d254a22305dd0d57f2048271d40f15d22b6f2473971cc3c398a6479d439fe80255f0dabb7cb94f9df8c21bc6214b2f60b5238c102e3048cbdbd3dd3dd18b693a
data/CHANGELOG.md CHANGED
@@ -1,5 +1,57 @@
1
1
  # Changelog
2
2
 
3
+ ## [2.8.4] - 2025-03-24
4
+
5
+ ### Added
6
+
7
+ - UX block default selection behavior: load as default the first item in `allowed` or the first line in the evaluated output of `echo` or `exec` parameters.
8
+ - A hidden UX block can be required.
9
+ - BATS tests validating an active UX block that requires read-only blocks.
10
+ - UX blocks evaluated automatically load their specified defaults.
11
+ - During interactive/manual evaluation, UX blocks present a menu of the list in the `allowed` parameter or the lines in the evaluated output of `echo` or `exec` parameters.
12
+ - New `SelectResponse` class tracks user's "Back" choice in interactive menus.
13
+ - `ww` calls now return the last item from the provided array, facilitating prefix usage in statements.
14
+ - Ability to set multiple variables from a single UX block using a dictionary of variable names and evaluated expressions defined in the `echo` parameter.
15
+ - BATS tests covering hidden and invalid UX blocks.
16
+ - Introduced standardized result objects for representing success and failure states, supporting custom payloads for failures.
17
+
18
+ ### Changed
19
+
20
+ - Enabled verbose mode by default for all minitests.
21
+ - Improved whitespace handling in the evaluated output of `echo`.
22
+ - Updated and expanded minitest suite.
23
+ - Update the execution of UX blocks.
24
+ - Aggregated results collected per UX block when processing input from files.
25
+ - Enhanced ANSI sequence tests with more complex formatting scenarios (e.g., bold, italicized, bright-yellow text on a light-yellow background).
26
+ - Standardized script shebangs to consistently execute Ruby minitests via `bundle exec`.
27
+ - Multi-line shell expansions create multiple lines in the menu.
28
+
29
+ ## [2.8.3] - 2025-02-27
30
+
31
+ ### Added
32
+
33
+ - "echo" support to UX blocks for evaluated shell expressions
34
+
35
+ Introduces the `echo` key to UX blocks, allowing the output of an
36
+ evaluated shell expression to be assigned to a named variable.
37
+ Implements `export_echo_with_code` to execute the expression safely
38
+ and handle invalidated outputs. Also ensures proper transformation of
39
+ export values.
40
+
41
+ - Persist allocated FCBs.
42
+
43
+ - Read-only flag to UX menu blocks
44
+
45
+ Introduces a `readonly` flag for UX menu blocks, allowing exports to
46
+ specify whether a block should be immutable. The flag is assigned from
47
+ the export definition and enforced in the menu logic.
48
+
49
+ ### Changed
50
+
51
+ - Correct indent of all lines displayed for a block.
52
+ - Retain whitespace in output from shell blocks.
53
+ - Remove a function to report the compiled version from the tab completion script. It is not used.
54
+
3
55
  ## [2.8.2] - 2025-02-19
4
56
 
5
57
  ### Added
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- markdown_exec (2.8.2)
4
+ markdown_exec (2.8.4)
5
5
  clipboard (~> 1.3.6)
6
6
  open3 (~> 0.1.1)
7
7
  optparse (~> 0.1.1)
data/Rakefile CHANGED
@@ -105,7 +105,7 @@ task :bats do
105
105
 
106
106
  # temporary clear WW to disable debugging
107
107
  # WW pollutes output expected by BATS tests
108
- "unset WW; bats #{file}"
108
+ %(unset WW; bats #{file})
109
109
  end
110
110
  end
111
111
 
@@ -117,29 +117,39 @@ end
117
117
  desc 'minitest'
118
118
  task :minitest do
119
119
  commands = [
120
- './lib/argument_processor.rb',
121
- './lib/cached_nested_file_reader.rb',
122
- './lib/collapser.rb',
123
- './lib/directory_searcher.rb',
124
- './lib/evaluate_shell_expressions.rb',
125
- './lib/fcb.rb',
126
- './lib/filter.rb',
120
+ './lib/argument_processor.rb --verbose',
121
+ './lib/block_label.rb --verbose',
122
+ './lib/cached_nested_file_reader.rb --verbose',
123
+ './lib/collapser.rb --verbose',
124
+ './lib/dev/ansi_codes.rb --verbose',
125
+ './lib/dev/append_to_bash_history.rb --verbose',
126
+ './lib/dev/generate_transition_codes.rb --verbose',
127
+ './lib/dev/hierarchy.rb --verbose',
128
+ './lib/dev/process_command.rb --verbose',
129
+ './lib/dev/process_template.rb --test --verbose',
130
+ # './lib/dev/ruby_file_processor.rb --test --verbose',
131
+ # './lib/dev/std_out_err_logger.rb', ### errs
132
+ './lib/dev/visibility-controller.rb --verbose',
133
+ './lib/directory_searcher.rb --verbose',
134
+ './lib/evaluate_shell_expressions.rb --verbose',
135
+ './lib/fcb.rb --verbose',
136
+ './lib/filter.rb --verbose',
127
137
  './lib/find_files.rb',
128
- './lib/format_table.rb',
129
- './lib/hash_delegator.rb',
130
- './lib/hierarchy_string.rb',
131
- './lib/link_history.rb',
132
- './lib/markdown_exec.rb',
133
- './lib/mdoc.rb',
134
- './lib/object_present.rb',
135
- './lib/option_value.rb',
136
- './lib/regexp.rb',
137
- './lib/resize_terminal.rb',
138
- './lib/saved_assets.rb',
139
- './lib/saved_files_matcher.rb',
140
- './lib/table_extractor.rb',
141
- './lib/text_analyzer.rb',
142
- './lib/dev/process_template.rb --test'
138
+ './lib/format_table.rb --verbose',
139
+ './lib/hash_delegator.rb --verbose',
140
+ './lib/hierarchy_string.rb --verbose',
141
+ './lib/link_history.rb --verbose',
142
+ './lib/markdown_exec.rb --verbose',
143
+ './lib/mdoc.rb --verbose',
144
+ './lib/object_present.rb --verbose',
145
+ './lib/option_value.rb --verbose',
146
+ './lib/regexp.rb --verbose',
147
+ './lib/resize_terminal.rb --verbose',
148
+ './lib/saved_assets.rb --verbose',
149
+ './lib/saved_files_matcher.rb --verbose',
150
+ # './lib/shell_session.rb --verbose',
151
+ './lib/table_extractor.rb --verbose',
152
+ './lib/text_analyzer.rb --verbose'
143
153
  ]
144
154
 
145
155
  execute_with_error_handling(commands) do |command|
@@ -2,8 +2,6 @@
2
2
 
3
3
  load 'test_helper'
4
4
 
5
- # Type: Bash
6
-
7
5
  @test 'Bash blocks - default' {
8
6
  BATS_OUTPUT_FILTER=A
9
7
  spec_mde_args_expect docs/dev/block-type-bash.md block-with-no-shell-type \
@@ -38,26 +36,3 @@ load 'test_helper'
38
36
  spec_mde_args_expect docs/dev/block-type-bash.md \[show-shell-version\] \
39
37
  ' detected_shell: bash'
40
38
  }
41
-
42
- # Type: Link
43
-
44
- @test 'Link blocks - set variable in link block; call hidden block' {
45
- # __Exit is required as last block is a Link type
46
- run_mde_specs_md_args_expect_xansi '[VARIABLE1]' __Exit ' VARIABLE1: 1'
47
- run_mde_specs_md_args_expect_xansi '[VARIABLE1]' '(echo-VARIABLE1)' ' VARIABLE1: 1 VARIABLE1: 1'
48
- }
49
-
50
- # Type: Port
51
-
52
- # includes output from assignment and from shell block
53
- @test 'Port block - export variable' {
54
- BATS_OUTPUT_FILTER=A
55
- spec_mde_args_expect docs/dev/block-type-port.md '[set_vault_1]' show \
56
- 'VAULT = 1 VAULT: 1'
57
- }
58
-
59
- @test 'Port block - export variable - not set' {
60
- BATS_OUTPUT_FILTER=A
61
- spec_mde_args_expect docs/dev/block-type-port.md VAULT-is-export show \
62
- ' VAULT: This variable has not been set.'
63
- }
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env bats
2
+
3
+ load 'test_helper'
4
+
5
+ @test 'Link blocks - set variable in link block; call hidden block' {
6
+ # __Exit is required as last block is a Link type
7
+ run_mde_specs_md_args_expect_xansi '[VARIABLE1]' __Exit ' VARIABLE1: 1'
8
+ run_mde_specs_md_args_expect_xansi '[VARIABLE1]' '(echo-VARIABLE1)' ' VARIABLE1: 1 VARIABLE1: 1'
9
+ }
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env bats
2
+
3
+ load 'test_helper'
4
+
5
+ # includes output from assignment and from shell block
6
+ @test 'Port block - export variable' {
7
+ BATS_OUTPUT_FILTER=A
8
+ spec_mde_args_expect docs/dev/block-type-port.md '[set_vault_1]' show \
9
+ 'VAULT = 1 VAULT: 1'
10
+ }
11
+
12
+ @test 'Port block - export variable - not set' {
13
+ BATS_OUTPUT_FILTER=A
14
+ spec_mde_args_expect docs/dev/block-type-port.md VAULT-is-export show \
15
+ ' VAULT: This variable has not been set.'
16
+ }
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env bats
2
+
3
+ load 'test_helper'
4
+
5
+ @test 'automatic blocks load defaults - constants or first allowed from output of echo or exec' {
6
+ spec_mde_xansi_dname_doc_blocks_expect docs/dev/block-type-ux-allowed.md \
7
+ 'SPECIES=Pongo tapanuliensis_GENUS=Pongo_FAMILY=_ORDER=Click to select..._CLASS=Click to select..._YEAR_DISCOVERED=_NAME=Tapanuli Orangutan'
8
+ }
9
+
10
+ @test 'executing a block loads the first allowed value' {
11
+ skip 'Unable to test the menu presented'
12
+ spec_mde_xansi_dname_doc_blocks_expect docs/dev/block-type-ux-allowed.md \
13
+ '[FAMILY]' \
14
+ 'SPECIES=Pongo tapanuliensis_GENUS=Pongo_FAMILY=Hominidae_ORDER=Click to select..._CLASS=Click to select..._YEAR_DISCOVERED=_NAME='
15
+ }
16
+
17
+ @test 'executing a block loads the first line in the output of exec' {
18
+ skip 'Unable to test the menu presented'
19
+ spec_mde_xansi_dname_doc_blocks_expect docs/dev/block-type-ux-allowed.md \
20
+ '[YEAR_DISCOVERED]' \
21
+ 'SPECIES=Pongo tapanuliensis_GENUS=Pongo_FAMILY=_YEAR_DISCOVERED=2017_NAME='
22
+ }
23
+
24
+ @test 'executing a block loads the first line in the output of echo' {
25
+ skip 'Unable to test the menu presented'
26
+ spec_mde_xansi_dname_doc_blocks_expect docs/dev/block-type-ux-allowed.md \
27
+ '[NAME]' \
28
+ 'SPECIES=Pongo tapanuliensis_GENUS=Pongo_FAMILY=_ORDER=Click to select..._CLASS=Click to select..._YEAR_DISCOVERED=_NAME=Tapanuli Orangutan'
29
+ }
@@ -4,5 +4,5 @@ load 'test_helper'
4
4
 
5
5
  @test 'Initial values' {
6
6
  spec_mde_xansi_dname_doc_blocks_expect docs/dev/block-type-ux-auto.md \
7
- 'v1 = _v2 = _v3 = 12_v4 = 21_v5 = markdown_exec_v6 = 31'
7
+ 'v1 = _v2 = _v3 = 12_v4 = 21_v5 = markdown_exec__v6 = 31'
8
8
  }
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env bats
2
+
3
+ load 'test_helper'
4
+
5
+ @test 'A UX block requires other read-only UX blocks that operate on the computed value.' {
6
+ spec_mde_xansi_dname_doc_blocks_expect docs/dev/block-type-ux-chained.md \
7
+ '[SPECIES]' \
8
+ 'SPECIES=Pongo tapanuliensis_NAME=Pongo tapanuliensis - Pongo'
9
+ }
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env bats
2
+
3
+ load 'test_helper'
4
+
5
+ @test 'an automatic block sets multiple variables' {
6
+ spec_mde_xansi_dname_doc_blocks_expect docs/dev/block-type-ux-echo-hash.md \
7
+ 'BASENAME=markdown_exec_DOCUMENTS=markdown_OPERATION=exec_Load Tapanuli Orangutan_Load Psychedelic Frogfish_| Variable | Value |_| -------- | ----- |_| Species | |_| Genus | |_| Family | |'
8
+ }
9
+
10
+ @test 'an activated block sets multiple variables' {
11
+ spec_mde_xansi_dname_doc_blocks_expect docs/dev/block-type-ux-echo-hash.md \
12
+ 'Load Tapanuli Orangutan' \
13
+ 'BASENAME=markdown_exec_DOCUMENTS=markdown_OPERATION=exec_Load Tapanuli Orangutan_Load Psychedelic Frogfish_| Variable | Value |_| -------- | ----------------------- |_| Species | Pongo tapanuliensis |_| Genus | Pongo |_| Family | Hominidae |'
14
+ }
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/env bats
2
+
3
+ load 'test_helper'
4
+
5
+ @test 'automatic block - default' {
6
+ spec_mde_xansi_dname_doc_blocks_expect docs/dev/block-type-ux-echo.md \
7
+ 'VAR=markdown_exec_IAB='
8
+ }
9
+
10
+ @test 'inherited lines' {
11
+ spec_mde_xansi_dname_doc_blocks_expect docs/dev/block-type-ux-echo.md \
12
+ '(menu_with_inherited_lines)' \
13
+ 'VAR=markdown_exec_VAR=markdown_exec_IAB='
14
+ }
15
+
16
+ @test 'selected block - output of wc includes whitespace' {
17
+ spec_mde_xansi_dname_doc_blocks_expect docs/dev/block-type-ux-echo.md \
18
+ '(VAR_has_count)' '[IAB_has_count]' \
19
+ 'VAR= 14_IAB= 14 14'
20
+ }
@@ -4,5 +4,5 @@ load 'test_helper'
4
4
 
5
5
  @test 'Output of executed commands as initial value' {
6
6
  spec_mde_xansi_dname_doc_blocks_expect docs/dev/block-type-ux-exec.md \
7
- "ux0=_ux1=Unknown_ux2=markdown_exec_ux3=markdown_exec_ux4=Xform: 'markdown'"
7
+ "ux0=_ux1=Unknown_ux2=markdown_exec__ux3=markdown_exec__ux4=Xform: 'markdown'"
8
8
  }
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env bats
2
+
3
+ load 'test_helper'
4
+
5
+ @test 'a UX block requires a shell block and another UX block' {
6
+ spec_mde_xansi_dname_doc_blocks_expect docs/dev/block-type-ux-hidden.md \
7
+ '[SPECIES]' \
8
+ 'SPECIES=Pongo tapanuliensis_NAME=Pongo tapanuliensis - Pongo'
9
+ }
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bats
2
+
3
+ load 'test_helper'
4
+
5
+ @test 'automatic block is invalid YAML' {
6
+ spec_mde_xansi_dname_doc_blocks_expect docs/dev/block-type-ux-invalid.md \
7
+ '_Error: HashDelegator../docs/dev/block-type-ux-invalid.md_vmlpd_bfnf_b_3 - --- !ruby/object:NullResult_message: Invalid YAML_data: invalid_ -- -- '
8
+ }
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bats
2
+
3
+ load 'test_helper'
4
+
5
+ @test 'An undefined variable is a precondition' {
6
+ spec_mde_xansi_dname_doc_blocks_expect docs/dev/block-type-ux-preconditions.md \
7
+ 'A value must exist for: MISSING_VARIABLE_SPECIES='
8
+ }
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env bats
2
+
3
+ load 'test_helper'
4
+
5
+ @test 'automatic block - disabled' {
6
+ spec_mde_args_expect \
7
+ docs/dev/block-type-ux-readonly.md \
8
+ --list-blocks-message readonly --list-blocks-type 3 --list-blocks \
9
+ true
10
+ }
@@ -4,5 +4,5 @@ load 'test_helper'
4
4
 
5
5
  @test 'Transformed output of executed commands' {
6
6
  spec_mde_xansi_dname_doc_blocks_expect docs/dev/block-type-ux-transform.md \
7
- '_Execution output has a trailing newline._Var0=markdown_exec_00000000 6d 61 72 6b 64 6f 77 6e 5f 65 78 65 63 0a |markdown_exec.|__With validate and transform, output has no newline._Var1=markdown_exec_00000000 6d 61 72 6b 64 6f 77 6e 5f 65 78 65 63 |markdown_exec|__With transform :chomp, output has no newline._Var2=markdown_exec_00000000 6d 61 72 6b 64 6f 77 6e 5f 65 78 65 63 |markdown_exec|__With transform :upcase, output is in upper case w/ newline._Var3=MARKDOWN_EXEC_00000000 4d 41 52 4b 44 4f 57 4e 5f 45 58 45 43 0a |MARKDOWN_EXEC.|'
7
+ '_Execution output has a trailing newline._Var0=markdown_exec__00000000 6d 61 72 6b 64 6f 77 6e 5f 65 78 65 63 0a |markdown_exec.|_0000000e__With validate and transform, output has no newline._Var1=markdown_exec_00000000 6d 61 72 6b 64 6f 77 6e 5f 65 78 65 63 |markdown_exec|_0000000d__With transform :chomp, output has no newline._Var2=markdown_exec_00000000 6d 61 72 6b 64 6f 77 6e 5f 65 78 65 63 |markdown_exec|_0000000d__With transform :upcase, output is in upper case w/ newline._Var3=MARKDOWN_EXEC__00000000 4d 41 52 4b 44 4f 57 4e 5f 45 58 45 43 0a |MARKDOWN_EXEC.|_0000000e'
8
8
  }
@@ -7,8 +7,8 @@ load 'test_helper'
7
7
  # includes output from automatic vars blocks
8
8
  @test 'Vars block - auto load' {
9
9
  BATS_OUTPUT_FILTER=A
10
- spec_mde_args_expect docs/dev/block-type-vars.md show \
11
- 'Species = Not specified Genus = Not specified Species: Not specified VAULT:'
10
+ spec_mde_xansi_dname_doc_blocks_expect docs/dev/block-type-vars.md show \
11
+ 'Species = Not specified_Genus = Not specified__Species: Not specified_VAULT: '
12
12
  }
13
13
 
14
14
  # includes output from assignment and from shell block
@@ -22,5 +22,5 @@ load 'test_helper'
22
22
  @test 'Vars block - invalid YAML' {
23
23
  BATS_OUTPUT_FILTER=A
24
24
  spec_mde_args_expect docs/dev/block-type-vars.md '[invalid_yaml]' show \
25
- 'Species = Not specified Genus = Not specified Species: Not specified VAULT:'
25
+ 'Species = Not specified Genus = Not specified Species: Not specified VAULT: '
26
26
  }
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env bats
2
+
3
+ load 'test_helper'
4
+
5
+ @test 'an indented block with multiple lines' {
6
+ BATS_OUTPUT_FILTER=A
7
+ spec_mde_xansi_dname_doc_blocks_expect docs/dev/indented-block-type-vars.md \
8
+ ' Species: Pongo tapanuliensis_ Genus: Pongo_'
9
+ }
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env bats
2
+
3
+ load 'test_helper'
4
+
5
+ @test 'Retain whitespace in output from shell blocks' {
6
+ spec_mde_xansi_dname_doc_blocks_expect docs/dev/indented-multi-line-output.md \
7
+ '[make-output]' \
8
+ '_Species_ Genus_ Family_Order'
9
+ }
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bats
2
+
3
+ load 'test_helper'
4
+
5
+ @test 'Line decor, dynamic - new pattern, line_decor_pre, ansi' {
6
+ spec_mde_dname_doc_blocks_expect docs/dev/line-decor-dynamic.md \
7
+ $'\e[1m\e[3m\e[38;2;200;200;33m\e[48;2;60;60;32mSpecies\e[22;23;0m'
8
+ }
@@ -27,6 +27,9 @@ echo_hexdump_expected_output_filter () {
27
27
  echo_hexdump "$(remove_ansi_escape_sequences "$output")"
28
28
  echo "- expected"
29
29
  echo_hexdump "$expected"
30
+
31
+ # print the byte offset of the first difference
32
+ #diff <(remove_ansi_escape_sequences "$output") <(echo -n "$expected") | grep "^[0-9a-f]{8} " | cut -c 1-8
30
33
  fi
31
34
  }
32
35
 
@@ -178,9 +181,13 @@ spec_mde_args_grep_filter_expect () {
178
181
  SL="${BATS_SLEEP}"
179
182
 
180
183
  if [[ -z $SL ]]; then
181
- echo >&2 $EXE "${remaining[@]}"
184
+ debug_args=()
185
+ for arg in "${remaining[@]}"; do
186
+ escaped_arg=$(printf '%q' "$arg")
187
+ debug_args+=("$escaped_arg")
188
+ done
189
+ echo >&2 $EXE "${debug_args[@]}"
182
190
 
183
- # Pass the exact arguments including empty and space-containing ones
184
191
  run $EXE "${remaining[@]}"
185
192
  else
186
193
  bash -c "
@@ -209,6 +216,16 @@ spec_mde_args_grep_filter_expect () {
209
216
  [[ -n $status ]]
210
217
  }
211
218
 
219
+ spec_mde_dname_doc_blocks_expect () {
220
+ BATS_SAFE=_
221
+ spec_mde_args_expect "$1" \
222
+ "${@:2:$(($#-2))}" \
223
+ --list-blocks-message dname \
224
+ --list-blocks-type 3 \
225
+ --list-blocks \
226
+ "${!#}"
227
+ }
228
+
212
229
  spec_mde_xansi_dname_doc_blocks_expect () {
213
230
  BATS_OUTPUT_FILTER=A
214
231
  BATS_SAFE=_
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bats
2
+
3
+ load 'test_helper'
4
+
5
+ @test '' {
6
+ spec_mde_xansi_dname_doc_blocks_expect docs/dev/variable-expansion-multiline.md \
7
+ 'Genus2 = Pongo_Pongo_UX block:_Genus2=Pongo_Pongo_Command substitution:_Genus2 hex: 00000000 50 6f 6e 67 6f 0a 50 6f 6e 67 6f |Pongo.Pongo|_0000000b_Command substitution:_Genus2 text: Pongo_Pongo_Command substitution:_Gemfile_Gemfile.lock_Variable expansion:_Genus2 text: Pongo_Pongo'
8
+ }
@@ -4,7 +4,7 @@ load 'test_helper'
4
4
 
5
5
  @test 'Variable expansion - default' {
6
6
  spec_mde_xansi_dname_doc_blocks_expect docs/dev/variable-expansion.md \
7
- 'EVIDENCE_SOURCE is:_SOURCE is:_SOURCE is:_| SOURCE |_| ------ |__name_with_${SOURCE}_in_name_load: file_.sh_SOURCES'
7
+ 'EVIDENCE_SOURCE is:_SOURCE is:_SOURCE is: _| SOURCE |_| ------ |__name_with_${SOURCE}_in_name_load: file_.sh_SOURCES'
8
8
  }
9
9
 
10
10
  @test 'Variable expansion - LINK_LOAD_SOURCE' {
@@ -12,10 +12,6 @@ __filedirs_all()
12
12
  COMPREPLY='.'
13
13
  }
14
14
 
15
- _mde_echo_version() {
16
- echo "2.8.2"
17
- }
18
-
19
15
  _mde() {
20
16
  local cur prev opts
21
17
  cur="${COMP_WORDS[COMP_CWORD]}"
@@ -213,4 +209,3 @@ _mde() {
213
209
  }
214
210
 
215
211
  complete -o filenames -o nospace -F _mde mde
216
- # _mde_echo_version
@@ -12,10 +12,6 @@ __filedirs_all()
12
12
  COMPREPLY='.'
13
13
  }
14
14
 
15
- _mde_echo_version() {
16
- echo "<%= MarkdownExec::VERSION %>"
17
- }
18
-
19
15
  _mde() {
20
16
  local cur prev opts
21
17
  cur="${COMP_WORDS[COMP_CWORD]}"
@@ -104,4 +100,3 @@ _mde() {
104
100
  }
105
101
 
106
102
  complete -o filenames -o nospace -F _mde mde
107
- # _mde_echo_version
@@ -0,0 +1,80 @@
1
+ / automatic block loads first allowed
2
+ ```ux :[document_ux_SPECIES]
3
+ allowed:
4
+ - Pongo tapanuliensis
5
+ - Histiophryne psychedelica
6
+ default: :allowed
7
+ name: SPECIES
8
+ ```
9
+ / automatic block loads first line in output of exec
10
+ ```ux :[document_ux_GENUS]
11
+ allowed: :exec
12
+ default: :allowed
13
+ exec: echo "Pongo\nHistiophryne psychedelica"
14
+ name: GENUS
15
+ ```
16
+ / executed block presents a menu of the allowed list
17
+ ```ux :[FAMILY]
18
+ allowed:
19
+ - Hominidae
20
+ - Antennariidae
21
+ name: FAMILY
22
+ ```
23
+ / automatic block loads default value that is not in allowed list
24
+ ```ux :[document_ux_ORDER]
25
+ allowed:
26
+ - Primates
27
+ - Lophiiformes
28
+ default: Click to select...
29
+ name: ORDER
30
+ ```
31
+ / automatic block loads default value, not in allowed list from echo
32
+ ```ux :[document_ux_CLASS]
33
+ allowed: :echo
34
+ default: Click to select...
35
+ echo: |
36
+ Mammalia
37
+ Actinopterygii
38
+ name: CLASS
39
+ ```
40
+ / executed block presents a menu of the lines in the output of exec
41
+ ```ux :[YEAR_DISCOVERED]
42
+ allowed: :exec
43
+ exec: echo "2017\n2009"
44
+ name: YEAR_DISCOVERED
45
+ ```
46
+ / automatic block presents a menu of the lines in the output of echo
47
+ ```ux :[document_ux_NAME]
48
+ allowed: :echo
49
+ default: :allowed
50
+ echo: |
51
+ Tapanuli Orangutan
52
+ Psychedelic Frogfish
53
+ name: NAME
54
+ ```
55
+ /
56
+ /1. Tapanuli Orangutan
57
+ /
58
+ /* Species: Pongo tapanuliensis
59
+ /* Genus: Pongo
60
+ /* Family: Hominidae
61
+ /* Order: Primates
62
+ /* Class: Mammalia
63
+ /* Phylum: Chordata
64
+ /* Kingdom: Animalia
65
+ /* Domain: Eukaryota
66
+ /* Year: 2017
67
+ /
68
+ /2. Psychedelic Frogfish
69
+ /
70
+ /* Species: Histiophryne psychedelica
71
+ /* Genus: Histiophryne
72
+ /* Family: Antennariidae
73
+ /* Order: Lophiiformes
74
+ /* Class: Actinopterygii
75
+ /* Phylum: Chordata
76
+ /* Kingdom: Animalia
77
+ /* Domain: Eukaryota
78
+ /* Year: 2009
79
+ /
80
+ @import bats-document-configuration.md
@@ -0,0 +1,21 @@
1
+ / a UX block that requires a shell block and another UX block
2
+ ``` :(shell)
3
+ ENTITY='Pongo tapanuliensis,Pongo'
4
+ ```
5
+ ```ux :[SPECIES] +(shell) +(GENUS)
6
+ echo: "${ENTITY%%,*}"
7
+ name: SPECIES
8
+ ```
9
+ / required ux block requires another
10
+ ```ux :(GENUS) +[NAME]
11
+ echo: "${ENTITY##*,}"
12
+ name: GENUS
13
+ readonly: true
14
+ ```
15
+ / executed in context of prior ux blocks, uses their values
16
+ ```ux :[NAME]
17
+ echo: "$SPECIES - $GENUS"
18
+ name: NAME
19
+ readonly: true
20
+ ```
21
+ @import bats-document-configuration.md