markdown_exec 2.5.0 → 2.6.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 (69) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +15 -0
  3. data/Gemfile.lock +2 -2
  4. data/Rakefile +3 -3
  5. data/bats/block-types.bats +13 -7
  6. data/bats/import.bats +6 -0
  7. data/bats/markup.bats +6 -15
  8. data/bats/options-collapse.bats +26 -0
  9. data/bats/options.bats +1 -1
  10. data/bats/table.bats +8 -0
  11. data/bats/test_helper.bash +74 -49
  12. data/bats/variable-expansion.bats +46 -0
  13. data/bin/tab_completion.sh +1 -1
  14. data/docs/dev/bats-document-configuration.md +8 -1
  15. data/docs/dev/block-type-bash.md +1 -1
  16. data/docs/dev/block-type-opts.md +1 -5
  17. data/docs/dev/block-type-vars.md +4 -0
  18. data/docs/dev/import-missing.md +2 -0
  19. data/docs/dev/menu-cli.md +1 -1
  20. data/docs/dev/options-collapse.md +47 -0
  21. data/docs/dev/requiring-blocks.md +3 -0
  22. data/docs/dev/specs.md +2 -1
  23. data/docs/dev/table-crash.md +39 -0
  24. data/docs/dev/table-indent.md +26 -0
  25. data/docs/dev/text-decoration.md +2 -5
  26. data/docs/dev/variable-expansion.md +2 -4
  27. data/examples/bash-blocks.md +1 -1
  28. data/examples/block-names.md +1 -1
  29. data/examples/block-types.md +1 -1
  30. data/examples/data-files.md +1 -1
  31. data/examples/document_options.md +2 -2
  32. data/examples/indent.md +1 -1
  33. data/examples/interrupt.md +1 -1
  34. data/examples/link-blocks-vars.md +1 -1
  35. data/examples/linked.md +1 -1
  36. data/examples/linked1.md +1 -1
  37. data/examples/nickname.md +1 -1
  38. data/examples/opts-blocks-require.md +1 -1
  39. data/examples/opts-blocks.md +1 -1
  40. data/examples/opts_output_execution.md +1 -1
  41. data/examples/pass-through-arguments.md +1 -1
  42. data/examples/pause-after-execution.md +1 -1
  43. data/examples/port-blocks.md +1 -1
  44. data/examples/save.md +1 -1
  45. data/examples/text-markup.md +1 -1
  46. data/examples/variable-expansion.md +6 -2
  47. data/examples/vars-blocks.md +1 -1
  48. data/examples/wrap.md +1 -1
  49. data/lib/block_types.rb +4 -0
  50. data/lib/cached_nested_file_reader.rb +7 -4
  51. data/lib/collapser.rb +302 -0
  52. data/lib/constants.rb +10 -0
  53. data/lib/evaluate_shell_expressions.rb +0 -3
  54. data/lib/fcb.rb +13 -17
  55. data/lib/format_table.rb +11 -7
  56. data/lib/hash_delegator.rb +461 -272
  57. data/lib/hierarchy_string.rb +5 -1
  58. data/lib/markdown_exec/version.rb +1 -1
  59. data/lib/markdown_exec.rb +16 -32
  60. data/lib/mdoc.rb +100 -35
  61. data/lib/menu.src.yml +124 -17
  62. data/lib/menu.yml +102 -16
  63. data/lib/ww.rb +75 -22
  64. metadata +12 -9
  65. data/lib/append_to_bash_history.rb +0 -303
  66. data/lib/ce_get_cost_and_usage.rb +0 -23
  67. data/lib/doh.rb +0 -190
  68. data/lib/layered_hash.rb +0 -143
  69. data/lib/poly.rb +0 -171
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0135d61b6c609e028c84831074894d55ea4af25f2d130f91b2765ce02fe7956e
4
- data.tar.gz: 543e32d24b494c4817555957136a5359b891436f3cd0b63e038d6cb2a931aaa5
3
+ metadata.gz: c8e475323e8db8b8288c18f8d97f1c52552c0a292854c42ab2780620bcdb8aa5
4
+ data.tar.gz: 254288c200e344c55f49c5fad1717d46550df1892eb526033180ed066f6c449d
5
5
  SHA512:
6
- metadata.gz: 11d0152dcf05d9483a12d0e9b8b599a3e80494f5be3a902e4a0092c79a2529746aaca5579f1b3031d55a44bf4771e7d0dd397e77afee08db01caf997b44e6a8f
7
- data.tar.gz: 1ab1545d4ceb4579287260a5e13d717677056430ee162e1ce6eb0f7b1f4528327d372381e78d48abd59f46e21739fe16ace5f3e0c249f6647f95afa4dfc55316
6
+ metadata.gz: b5a6372f45da7c45ae20b0c65058347c66fa17b7afffbacb63f0000c52ff0efd99e18a22f826e7803a1f130868a1dcf0b2f59b48279d19bb1326709a2dc3c04a
7
+ data.tar.gz: 4308b84a0591e44e5e2d317c6f0c5cd7b6d74848f91a65aaf85897058321ca041113ee80889313d2b0c1a31a587796af708879f3cd3b169a976755f6cce879c9
data/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # Changelog
2
2
 
3
+ ## [2.6.0] - 2024-11-27
4
+
5
+ ### Added
6
+
7
+ - Ability to collapse and expand sections.
8
+ - Collapsible state configurable per document and per section.
9
+ - User can collapse and expand sections in the UI.
10
+ - Live shell variable expansion in document text and block content.
11
+ - Option for name of function to manage executed scripts.
12
+
13
+ ### Changed
14
+
15
+ - Tables are indented per the source.
16
+ - BATS test helper functions.
17
+
3
18
  ## [2.5.0] - 2024-10-27
4
19
 
5
20
  ### Added
data/Gemfile.lock CHANGED
@@ -1,12 +1,12 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- markdown_exec (2.5.0)
4
+ markdown_exec (2.6.0)
5
5
  clipboard (~> 1.3.6)
6
6
  open3 (~> 0.1.1)
7
7
  optparse (~> 0.1.1)
8
8
  tty-prompt (~> 0.23.1)
9
- yaml (~> 0.2.0)
9
+ yaml (>= 0.2.0)
10
10
 
11
11
  GEM
12
12
  remote: https://rubygems.org/
data/Rakefile CHANGED
@@ -79,16 +79,16 @@ task :bats do
79
79
  FileList['bats/**/*.bats'].each do |file|
80
80
  next if %w[bats/bats.bats bats/fail.bats].include?(file)
81
81
 
82
- system "bats #{file}"
82
+ # temporary clear WW to disable debugging
83
+ # WW pollutes output expected by BATS tests
84
+ system "unset WW; bats #{file}"
83
85
  end
84
86
  end
85
87
 
86
88
  desc 'minitest'
87
89
  task :minitest do
88
90
  commands = [
89
- './lib/append_to_bash_history.rb',
90
91
  './lib/argument_processor.rb',
91
- './lib/block_label.rb',
92
92
  './lib/cached_nested_file_reader.rb',
93
93
  './lib/directory_searcher.rb',
94
94
  './lib/evaluate_shell_expressions.rb',
@@ -51,15 +51,14 @@ load 'test_helper'
51
51
 
52
52
  @test 'Opts block - before' {
53
53
  skip 'Fails because command executes after the block is processed'
54
- BATS_OUTPUT_FILTER=A
55
- spec_mde_args_expect docs/dev/block-type-opts.md --list-blocks-message dname --list-blocks-type 3 --list-blocks \
56
- 'BEFORE Species menu_note_format: "AFTER %{line}" '
54
+ spec_mde_xansi_dname_doc_blocks_expect docs/dev/block-type-opts.md \
55
+ 'BEFORE Species_menu_note_format: "AFTER %{line}" '
57
56
  }
58
57
 
59
58
  @test 'Opts block - after' {
60
- BATS_OUTPUT_FILTER=A
61
- spec_mde_args_expect docs/dev/block-type-opts.md --list-blocks-message dname --list-blocks-type 3 '[decorate-note]' --list-blocks \
62
- 'AFTER Species menu_note_format: "AFTER %{line}"'
59
+ spec_mde_xansi_dname_doc_blocks_expect docs/dev/block-type-opts.md \
60
+ '[decorate-note]' \
61
+ 'AFTER Species_menu_note_format: "AFTER %{line}"'
63
62
  }
64
63
 
65
64
  @test 'Opts block - show that menu has changed' {
@@ -85,9 +84,16 @@ load 'test_helper'
85
84
 
86
85
  # Type: Vars
87
86
 
87
+ # includes output from automatic vars block
88
+ @test 'Vars block - auto load' {
89
+ BATS_OUTPUT_FILTER=A
90
+ spec_mde_args_expect docs/dev/block-type-vars.md show \
91
+ 'Species = Not specified Species: Not specified VAULT:'
92
+ }
93
+
88
94
  # includes output from assignment and from shell block
89
95
  @test 'Vars block - set variable' {
90
96
  BATS_OUTPUT_FILTER=A
91
97
  spec_mde_args_expect docs/dev/block-type-vars.md '[set_vault_1]' show \
92
- 'VAULT = 1 VAULT: 1'
98
+ 'Species = Not specified VAULT = 1 Species: Not specified VAULT: 1'
93
99
  }
data/bats/import.bats CHANGED
@@ -8,3 +8,9 @@ load 'test_helper'
8
8
  --list-blocks-message indent --list-blocks \
9
9
  ' '
10
10
  }
11
+
12
+ @test 'Directives - import, missing' {
13
+ BATS_OUTPUT_FILTER=A
14
+ spec_mde_args_expect docs/dev/import-missing.md \
15
+ ' Error: CachedNestedFileReader.readlines -- No such file or directory - this-is-missing.md @@ '
16
+ }
data/bats/markup.bats CHANGED
@@ -5,27 +5,18 @@ load 'test_helper'
5
5
  # Text Decoration
6
6
 
7
7
  @test 'Options - list blocks - 1 plain' {
8
- BATS_OUTPUT_FILTER=A \
9
- spec_mde_args_expect \
10
- docs/dev/text-decoration.md \
11
- --list-blocks-message oname \
12
- --list-blocks-type 3 \
13
- --list-blocks \
14
- '- **_Bold-Underline_** - **Bold** - **~Bold-Italic~** - __Underline__ - _~Underline-Italic~_ - `Italic` - ~~Strikethrough~~'
8
+ spec_mde_xansi_oname_doc_blocks_expect docs/dev/text-decoration.md \
9
+ '- **_Bold-Underline_**_- **Bold**_- **~Bold-Italic~**_- __Underline___- _~Underline-Italic~__- `Italic`_- ~~Strikethrough~~'
15
10
  }
16
11
 
17
12
  @test 'Options - list blocks - 2 extracts markup' {
18
- BATS_OUTPUT_FILTER=A \
19
- spec_mde_args_expect \
20
- docs/dev/text-decoration.md \
21
- --list-blocks-message dname \
22
- --list-blocks-type 3 \
23
- --list-blocks \
24
- '- Bold-Underline - Bold - Bold-Italic - Underline - Underline-Italic - Italic - Strikethrough'
13
+ spec_mde_xansi_dname_doc_blocks_expect docs/dev/text-decoration.md \
14
+ '- Bold-Underline_- Bold_- Bold-Italic_- Underline_- Underline-Italic_- Italic_- Strikethrough'
25
15
  }
26
16
 
27
17
  @test 'Options - list blocks - 3 decorates' {
28
- spec_mde_args_expect docs/dev/text-decoration.md --list-blocks-message dname --list-blocks-type 3 --list-blocks \
18
+ spec_mde_args_expect docs/dev/text-decoration.md \
19
+ --list-blocks-message dname --list-blocks-type 3 --list-blocks \
29
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'
30
21
  }
31
22
 
@@ -0,0 +1,26 @@
1
+ #!/usr/bin/env bats
2
+
3
+ load 'test_helper'
4
+
5
+ @test 'Options - Collapsible - Document options' {
6
+ spec_mde_xansi_oname_doc_blocks_expect docs/dev/options-collapse.md \
7
+ 'H1.1_L1.1_H2.1_H1.2_H2.2_H1.3_H2.3_L2.3_h3.3_L3.3_D4.3_L4.3'
8
+ }
9
+
10
+ @test 'Options - Collapsible Heading - Expand' {
11
+ spec_mde_xansi_oname_doc_blocks_expect docs/dev/options-collapse.md \
12
+ H2.1 \
13
+ 'H1.1_L1.1_H2.1_L2.1_h3.1_L3.1_D4.1_L4.1_H1.2_L1.2_H2.2_H1.3_H2.3_L2.3_h3.3_L3.3_D4.3_L4.3'
14
+ }
15
+
16
+ @test 'Options - Collapsible Divider' {
17
+ spec_mde_xansi_oname_doc_blocks_expect docs/dev/options-collapse.md \
18
+ D4.3 \
19
+ 'H1.1_L1.1_H2.1_H1.2_H2.2_H1.3_H2.3_L2.3_h3.3_L3.3_D4.3'
20
+ }
21
+
22
+ @test 'Options - Reveal' {
23
+ spec_mde_xansi_oname_doc_blocks_expect docs/dev/options-collapse.md \
24
+ H2.2 h3.2 D4.2 \
25
+ 'H1.1_L1.1_H2.1_H1.2_H2.2_L2.2_h3.2_L3.2_D4.2_L4.2_H1.3_L1.3_H2.3_L2.3_h3.3_L3.3_D4.3_L4.3'
26
+ }
data/bats/options.bats CHANGED
@@ -91,7 +91,7 @@ load 'test_helper'
91
91
  }
92
92
 
93
93
  @test 'Options - version' {
94
- version=$(grep VERSION "$PROJECT_ROOT/lib/markdown_exec/version.rb" | cut -d "'" -f 2)
94
+ version=$(grep VERSION "lib/markdown_exec/version.rb" | cut -d "'" -f 2)
95
95
  spec_mde_args_expect --version \
96
96
  "$version"
97
97
  }
data/bats/table.bats ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bats
2
+
3
+ load 'test_helper'
4
+
5
+ @test 'Tables - indented' {
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 Discovered |_| -------------------- | ------------------------- | ------------ | ------------- | --------------- |_| Tapanuli Orangutan | Pongo tapanuliensis | Pongo | Hominidae | 2017 |_| Psychedelic Frogfish | Histiophryne psychedelica | Histiophryne | Antennariidae | 2009 |_| Ruby Seadragon | Phyllopteryx dewysea | Phyllopteryx | 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
+ }
@@ -1,7 +1,5 @@
1
1
  # facilitate execution of program, comparison of output
2
2
 
3
- export PROJECT_ROOT="/Users/fareed/Documents/dev/ruby/markdown_exec"
4
-
5
3
  date_from_history_file_name () {
6
4
  basename "$1" | sed -E 's/.*([0-9]{4}-[0-9]{2}-[0-9]{2}).*/\1/'
7
5
  }
@@ -10,6 +8,41 @@ echo_hexdump () {
10
8
  echo -en "$1" | hexdump -C
11
9
  }
12
10
 
11
+ echo_hexdump_expected_output_filter () {
12
+ local expected="$1"
13
+ local output="$2"
14
+ local filter="$3"
15
+
16
+ echo -e "- output_$(echo "$output" | wc -l)_$(echo -n "$output" | wc -c):\n$output"
17
+ if [[ $filter == A ]]; then
18
+ echo -e "- converted_$(echo "$output" | wc -l)_$(echo -n "$output" | wc -c):"
19
+ echo "$(remove_ansi_escape_sequences "$output")"
20
+ fi
21
+ echo -e "- expected_$(echo "$expected" | wc -l)_$(echo -n "$expected" | wc -c):\n$expected"
22
+
23
+ if [[ $filter == A ]]; then
24
+ echo "- output"
25
+ echo_hexdump "$output"
26
+ echo "- converted"
27
+ echo_hexdump "$(remove_ansi_escape_sequences "$output")"
28
+ echo "- expected"
29
+ echo_hexdump "$expected"
30
+ fi
31
+ }
32
+
33
+ echo_xansi_command_expected_output_filter () {
34
+ local command="$1"
35
+ local expected="$2"
36
+ local output="$3"
37
+ local filter="$4"
38
+
39
+ echo -e "- command: $command"
40
+ echo -e "- expected:\n$expected"
41
+ echo_hexdump "$expected"
42
+ echo -e "- output:\n$(text_filter_ansi "$output" "$filter")"
43
+ echo_hexdump "$output"
44
+ }
45
+
13
46
  exec_mde () {
14
47
  echo "bin/bmde "$1" "${@:2}""
15
48
  run bin/bmde "$1" ${@:2}
@@ -30,6 +63,21 @@ expect_equal_with_conversion () {
30
63
  [[ "$expected" == "$actual" ]]
31
64
  }
32
65
 
66
+ hex_dump () {
67
+ local separator=" --- "
68
+ local output=""
69
+
70
+ echo -en "$@" >&2
71
+ for arg in "$@"; do
72
+ output+="${arg}${separator}"
73
+ done
74
+
75
+ output="${output%$separator}" # Remove the trailing separator
76
+ echo "output: $output"
77
+ echo ":"
78
+ echo -en "$output" | hexdump -C >&2
79
+ }
80
+
33
81
  most_recent_history_file_name () {
34
82
  ls -f logs/*examples_save_md* | tail -n 1
35
83
  }
@@ -73,11 +121,7 @@ run_mde_specs_md_args_expect_xansi () {
73
121
 
74
122
  filter="${BATS_OUTPUT_FILTER:-A}"
75
123
  if ( ! expect_equal_with_conversion "$expected" "$output" "$filter" ); then
76
- echo -e "- command: ${@:1:$#-1}"
77
- echo -e "- expected:\n$expected"
78
- echo_hexdump "$expected"
79
- echo -e "- output:\n$(text_filter_ansi "$output" "$filter")"
80
- echo_hexdump "$output"
124
+ echo_xansi_command_expected_output_filter "${@:1:$#-1}" "$expected" "$output" "$filter"
81
125
  fi
82
126
 
83
127
  expect_equal_with_conversion "$expected" "$output" "$filter"
@@ -123,38 +167,6 @@ spec_mde_args_expect () {
123
167
  "${args[@]: -1}"
124
168
  }
125
169
 
126
- hex_dump () {
127
- local separator=" --- "
128
- local output=""
129
-
130
- echo -en "$@" >&2
131
- for arg in "$@"; do
132
- output+="${arg}${separator}"
133
- done
134
-
135
- output="${output%$separator}" # Remove the trailing separator
136
- echo "output: $output"
137
- echo ":"
138
- echo -en "$output" | hexdump -C >&2
139
- }
140
-
141
- spec_mde_args_grep_filter_expect_ok () {
142
- # Capturing arguments
143
- local remaining=("${@:1:$(($#-3))}")
144
- local pattern="${@: -3:1}"
145
- local filter="${@: -2:1}"
146
- local expected="${@: -1}"
147
- local STATUS="${BATS_STATUS:-0}"
148
- local EXE="${BATS_EXE:-silence_ww bin/bmde}"
149
-
150
- # Print the command being run for debugging
151
- echo >&2 $EXE "${remaining[@]}"
152
-
153
- # Pass the exact arguments including empty and space-containing ones
154
- run $EXE "${remaining[@]}"
155
- }
156
-
157
-
158
170
  spec_mde_args_grep_filter_expect () {
159
171
  # Capturing arguments
160
172
  local remaining=("${@:1:$(($#-3))}")
@@ -190,22 +202,35 @@ spec_mde_args_grep_filter_expect () {
190
202
  fi
191
203
 
192
204
  if ( ! expect_equal_with_conversion "$expected" "$output" "$filter"); then
193
- echo -e "- output_$(echo "$output" | wc -l)_$(echo -n "$output" | wc -c):\n$output"
194
- [[ $filter == A ]] && echo_hexdump "$output"
195
-
196
- if [[ $filter == A ]]; then
197
- echo -e "- converted_$(echo "$output" | wc -l)_$(echo -n "$output" | wc -c):"
198
- echo "$(remove_ansi_escape_sequences "$output")"
199
- echo_hexdump "$(remove_ansi_escape_sequences "$output")"
200
- fi
201
- echo -e "- expected_$(echo "$expected" | wc -l)_$(echo -n "$expected" | wc -c):\n$expected"
202
- [[ $filter == A ]] && echo_hexdump "$expected"
205
+ echo_hexdump_expected_output_filter "$expected" "$output" "$filter"
203
206
  fi
204
207
  expect_equal_with_conversion "$expected" "$output" "$filter"
205
208
  [[ -n $status ]] && echo "- status: $status"
206
209
  [[ -n $status ]]
207
210
  }
208
211
 
212
+ spec_mde_xansi_dname_doc_blocks_expect () {
213
+ BATS_OUTPUT_FILTER=A
214
+ BATS_SAFE=_
215
+ spec_mde_args_expect "$1" \
216
+ "${@:2:$(($#-2))}" \
217
+ --list-blocks-message dname \
218
+ --list-blocks-type 3 \
219
+ --list-blocks \
220
+ "${!#}"
221
+ }
222
+
223
+ spec_mde_xansi_oname_doc_blocks_expect () {
224
+ BATS_OUTPUT_FILTER=A
225
+ BATS_SAFE=_
226
+ spec_mde_args_expect "$1" \
227
+ "${@:2:$(($#-2))}" \
228
+ --list-blocks-message oname \
229
+ --list-blocks-type 3 \
230
+ --list-blocks \
231
+ "${!#}"
232
+ }
233
+
209
234
  text_filter_ansi () {
210
235
  if [[ $# -eq 2 ]]; then
211
236
  remove_ansi_escape_sequences "$1"
@@ -0,0 +1,46 @@
1
+ #!/usr/bin/env bats
2
+
3
+ load 'test_helper'
4
+
5
+ @test 'Variable expansion - default' {
6
+ spec_mde_xansi_dname_doc_blocks_expect docs/dev/variable-expansion.md \
7
+ ' EVIDENCE_ SOURCE is: ${SOURCE}_SOURCE is: ${SOURCE}_SOURCE is: ${SOURCE}_| SOURCE |_| --------- |_| ${SOURCE} |_name_with_${SOURCE}_in_name_load: file_${SOURCE}.sh_ SOURCES'
8
+ }
9
+
10
+ @test 'Variable expansion - LINK_LOAD_SOURCE' {
11
+ echo "SOURCE='Loaded file'" > temp_variable_expansion.sh
12
+ spec_mde_xansi_dname_doc_blocks_expect docs/dev/variable-expansion.md \
13
+ '(LINK_LOAD_SOURCE)' \
14
+ ' EVIDENCE_ SOURCE is: Loaded file_SOURCE is: Loaded file_SOURCE is: Loaded file_| SOURCE |_| ----------- |_| Loaded file |_name_with_${SOURCE}_in_name_load: file_Loaded file.sh_ SOURCES'
15
+ rm temp_variable_expansion.sh
16
+ }
17
+
18
+ @test 'Variable expansion - LINK_VARS_SOURCE' {
19
+ spec_mde_xansi_dname_doc_blocks_expect docs/dev/variable-expansion.md \
20
+ '(LINK_VARS_SOURCE)' \
21
+ ' EVIDENCE_ SOURCE is: Link block_SOURCE is: Link block_SOURCE is: Link block_| SOURCE |_| ---------- |_| Link block |_name_with_${SOURCE}_in_name_load: file_Link block.sh_ SOURCES'
22
+ }
23
+
24
+ @test 'Variable expansion - VARS_SOURCE' {
25
+ spec_mde_xansi_dname_doc_blocks_expect docs/dev/variable-expansion.md \
26
+ '(VARS_SOURCE)' \
27
+ ' EVIDENCE_ SOURCE is: Vars block_SOURCE is: Vars block_SOURCE is: Vars block_| SOURCE |_| ---------- |_| Vars block |_name_with_${SOURCE}_in_name_load: file_Vars block.sh_ SOURCES'
28
+ }
29
+
30
+ ### Load source
31
+
32
+ @test 'Variable expansion - in block body' {
33
+ BATS_OUTPUT_FILTER=A
34
+ spec_mde_args_expect docs/dev/variable-expansion.md \(VARS_SOURCE\) \
35
+ --list-blocks --list-blocks-type 3 \
36
+ --list-blocks-eval "block.body&.first&.start_with?(\"load: \") ? block.body : nil" \
37
+ 'load: file_Vars block.sh'
38
+ }
39
+
40
+ @test 'Variable expansion - in block dname' {
41
+ BATS_OUTPUT_FILTER=A
42
+ spec_mde_args_expect docs/dev/variable-expansion.md \(VARS_SOURCE\) \
43
+ --list-blocks --list-blocks-type 3 \
44
+ --list-blocks-eval "block.body&.first&.start_with?(\"load: \") ? block.dname : nil" \
45
+ 'load: file_Vars block.sh'
46
+ }
@@ -13,7 +13,7 @@ __filedirs_all()
13
13
  }
14
14
 
15
15
  _mde_echo_version() {
16
- echo "2.5.0"
16
+ echo "2.6.0"
17
17
  }
18
18
 
19
19
  _mde() {
@@ -1,4 +1,6 @@
1
- ```opts :(document_options)
1
+ ```opts :(document_opts)
2
+ divider4_center: false
3
+
2
4
  dump_blocks_in_file: false # Dump BlocksInFile (stage 1)
3
5
  dump_delegate_object: false # Dump @delegate_object
4
6
  dump_inherited_lines: false # Dump inherited lines
@@ -7,6 +9,11 @@ dump_selected_block: false # Dump selected block
7
9
 
8
10
  execute_in_own_window: false
9
11
 
12
+ menu_divider_format:
13
+ menu_with_back: false
14
+ menu_with_exit: false
15
+ menu_with_shell: false
16
+
10
17
  output_execution_report: false
11
18
  output_execution_summary: false
12
19
 
@@ -83,6 +83,6 @@ This block has no (shell) type. It will execute as the default shell type.
83
83
  It will not appear if `bash_only` is `true`.
84
84
 
85
85
  @import bats-document-configuration.md
86
- ```opts :(document_options)
86
+ ```opts :(document_opts)
87
87
  bash_only: false
88
88
  ```
@@ -3,13 +3,9 @@ Species
3
3
  menu_note_format: "AFTER %{line}"
4
4
  ```
5
5
  @import bats-document-configuration.md
6
- ```opts :(document_options)
7
- menu_divider_format:
6
+ ```opts :(document_opts)
8
7
  menu_final_divider:
9
8
  menu_for_saved_lines: false
10
9
  menu_initial_divider:
11
10
  menu_note_format: "BEFORE %{line}"
12
- menu_with_back: false
13
- menu_with_exit: false
14
- menu_with_shell: false
15
11
  ```
@@ -2,6 +2,10 @@
2
2
  VAULT: 1
3
3
  ```
4
4
  ```bash :show
5
+ echo "Species: $Species"
5
6
  echo "VAULT: $VAULT"
6
7
  ```
7
8
  @import bats-document-configuration.md
9
+ ```vars :(document_vars)
10
+ Species: Not specified
11
+ ```
@@ -0,0 +1,2 @@
1
+ Demonstrate a missing import file.
2
+ @import this-is-missing.md
data/docs/dev/menu-cli.md CHANGED
@@ -11,6 +11,6 @@ echo "Sh block"
11
11
  echo "Unspecified shell type"
12
12
  ```
13
13
  @import bats-document-configuration.md
14
- ```opts :(document_options)
14
+ ```opts :(document_opts)
15
15
  bash_only: false
16
16
  ```
@@ -0,0 +1,47 @@
1
+ / All are collapsible
2
+ / Only H2 is collapsed by default
3
+ # H1.1
4
+ L1.1
5
+ ## H2.1
6
+ L2.1
7
+ ### H3.1
8
+ L3.1
9
+ ::: D4.1
10
+ L4.1
11
+ / Collapse all
12
+ #+ H1.2
13
+ L1.2
14
+ ##+ H2.2
15
+ L2.2
16
+ ###+ H3.2
17
+ L3.2
18
+ :::+ D4.2
19
+ L4.2
20
+ / Expand all
21
+ #- H1.3
22
+ L1.3
23
+ ##- H2.3
24
+ L2.3
25
+ ###- H3.3
26
+ L3.3
27
+ :::- D4.3
28
+ L4.3
29
+ @import bats-document-configuration.md
30
+ ```opts :(document_opts)
31
+ divider4_center: false
32
+ divider4_collapse: false
33
+ divider4_collapsible: true
34
+ heading1_center: false
35
+ heading1_collapse: false
36
+ heading1_collapsible: false
37
+ heading2_center: false
38
+ heading2_collapse: true
39
+ heading2_collapsible: true
40
+ heading3_center: false
41
+ heading3_collapse: false
42
+ heading3_collapsible: true
43
+
44
+ heading1_match: "^#(?<line>(?!#)(?<collapse>[+-~]?)(?<indent>[ \t]*)(?<text>.*?)(?<trailing>[ \t]*))?$"
45
+ menu_collapsible_symbol_collapsed: '(+)'
46
+ menu_collapsible_symbol_expanded: '(-)'
47
+ ```
@@ -19,3 +19,6 @@ ARG1=37
19
19
  echo "ARG1: $ARG1"
20
20
  ```
21
21
  @import bats-document-configuration.md
22
+ ```opts :(document_opts)
23
+ menu_with_exit: true
24
+ ```
data/docs/dev/specs.md CHANGED
@@ -77,7 +77,8 @@ dump_menu_blocks: false
77
77
  ```
78
78
 
79
79
  @import bats-document-configuration.md
80
- ```opts :(document_options) +(disable_dump_*)
80
+ ```opts :(document_opts) +(disable_dump_*)
81
81
  menu_note_color: 'plain'
82
+ menu_with_exit: true
82
83
  menu_with_inherited_lines: false
83
84
  ```
@@ -0,0 +1,39 @@
1
+ / The lines below are an invalid table
2
+ | Region| VPC ID| VPC Name
3
+ -
4
+ # Demonstrate Tables
5
+
6
+ Table flush at left.
7
+ Centered columns.
8
+ | Common Name| Species| Genus| Family| Year Discovered
9
+ |:-:|:-:|:-:|:-:|:-:
10
+ | Tapanuli Orangutan| Pongo tapanuliensis| Pongo| Hominidae| 2017
11
+ | Psychedelic Frogfish| Histiophryne psychedelica| Histiophryne| Antennariidae| 2009
12
+ | Ruby Seadragon| Phyllopteryx dewysea| Phyllopteryx| Syngnathidae| 2015
13
+
14
+ Table indented with two spaces.
15
+ Left-justified columns.
16
+ | Common Name| Species| Genus| Family| Year Discovered
17
+ |:-|:-|:-|:-|:-
18
+ | Illacme tobini (Millipede)| Illacme tobini| Illacme| Siphonorhinidae| 2016
19
+ | Cappuccino Snake| Hydrodynastes bicinctus| Hydrodynastes| Colubridae| 2021
20
+ | Homo luzonensis| Homo luzonensis| Homo| Hominidae| 2019
21
+
22
+ Table indented with one tab.
23
+ Right-justified columns.
24
+ | Common Name| Species| Genus| Family| Year Discovered
25
+ |-:|-:|-:|-:|-:
26
+ | Spiny Dandelion| Taraxacum japonicum| Taraxacum| Asteraceae| 2022
27
+ | Mythical Monkey| Cercopithecus lomamiensis| Cercopithecus| Cercopithecidae| 2012
28
+ | Yeti Crab| Kiwa hirsuta| Kiwa| Kiwaidae| 2005
29
+
30
+ ## Non-table text is not modified
31
+ 1. |
32
+ 2. ||
33
+ |
34
+ ||
35
+
36
+ ## markup with table
37
+ | Common Name| Species| Genus| Family| Year Discovered
38
+ |:-:|:-:|:-:|:-:|:-:
39
+ | `Tapanuli Orangutan`| **Pongo tapanuliensis**| __Pongo__| Hominidae| 2017
@@ -0,0 +1,26 @@
1
+ # Demonstrate Table Indentation
2
+
3
+ Table flush at left.
4
+ Centered columns.
5
+ | Common Name| Species| Genus| Family| Year Discovered
6
+ |:-:|:-:|:-:|:-:|:-:
7
+ | Tapanuli Orangutan| Pongo tapanuliensis| Pongo| Hominidae| 2017
8
+ | Psychedelic Frogfish| Histiophryne psychedelica| Histiophryne| Antennariidae| 2009
9
+ | Ruby Seadragon| Phyllopteryx dewysea| Phyllopteryx| Syngnathidae| 2015
10
+
11
+ Table indented with two spaces.
12
+ Left-justified columns.
13
+ | Common Name| Species| Genus| Family| Year Discovered
14
+ |:-|:-|:-|:-|:-
15
+ | Illacme tobini (Millipede)| Illacme tobini| Illacme| Siphonorhinidae| 2016
16
+
17
+ Table indented with one tab.
18
+ Right-justified columns.
19
+ | Common Name| Species| Genus| Family| Year Discovered
20
+ |-:|-:|-:|-:|-:
21
+ | Spiny Dandelion| Taraxacum japonicum| Taraxacum| Asteraceae| 2022
22
+ @import bats-document-configuration.md
23
+ ```opts :(document_opts)
24
+ heading1_center: false
25
+ table_center: false
26
+ ```
@@ -5,11 +5,8 @@
5
5
  - _~Underline-Italic~_
6
6
  - `Italic`
7
7
  - ~~Strikethrough~~
8
- ```opts :(document_options)
9
- menu_final_divider:
8
+ @import bats-document-configuration.md
9
+ ```opts :(document_opts)
10
10
  menu_for_saved_lines: false
11
11
  menu_initial_divider:
12
- menu_with_back: false
13
- menu_with_exit: false
14
- menu_with_shell: false
15
12
  ```
@@ -24,7 +24,7 @@ vars:
24
24
  SOURCE: Vars block
25
25
  ```
26
26
  @import bats-document-configuration.md
27
- ```opts :(document_options)
27
+ ```opts :(document_opts)
28
28
  heading1_center: false
29
29
  heading2_center: false
30
30
  heading3_center: false
@@ -32,7 +32,5 @@ menu_final_divider:
32
32
  menu_for_saved_lines: false
33
33
  menu_initial_divider:
34
34
  menu_vars_set_format:
35
- menu_with_back: false
36
- menu_with_exit: false
37
- menu_with_shell: false
35
+ table_center: false
38
36
  ```