markdown_exec 2.6.0 → 2.7.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +18 -2
  3. data/Gemfile.lock +2 -2
  4. data/Rakefile +36 -0
  5. data/bats/command-substitution.bats +8 -0
  6. data/bats/options.bats +4 -4
  7. data/bats/plain.bats +8 -0
  8. data/bats/table.bats +6 -1
  9. data/bats/variable-expansion.bats +4 -4
  10. data/bin/bmde +46 -2
  11. data/bin/tab_completion.sh +1 -1
  12. data/docs/dev/command-substitution.md +24 -0
  13. data/docs/dev/load_code.md +14 -0
  14. data/docs/dev/no-active-elements.md +6 -0
  15. data/docs/dev/screen-width.md +21 -0
  16. data/docs/dev/table-invalid.md +20 -0
  17. data/examples/bash-blocks.md +2 -1
  18. data/examples/block-names.md +2 -1
  19. data/examples/block-types.md +2 -1
  20. data/examples/data-files.md +1 -0
  21. data/examples/document_options.md +1 -0
  22. data/examples/example-document-opts.md +6 -0
  23. data/examples/index.md +1 -1
  24. data/examples/interrupt.md +1 -0
  25. data/examples/link-blocks-load-save.md +8 -10
  26. data/examples/link-blocks-vars.md +12 -9
  27. data/examples/linked.md +9 -12
  28. data/examples/linked1.md +7 -6
  29. data/examples/linked2.md +6 -7
  30. data/examples/linked3.md +6 -5
  31. data/examples/linked_show.md +5 -4
  32. data/examples/nickname.md +1 -0
  33. data/examples/opts-blocks-require.md +1 -0
  34. data/examples/opts-blocks.md +1 -0
  35. data/examples/opts_output_execution.md +1 -0
  36. data/examples/pass-through-arguments.md +1 -0
  37. data/examples/pause-after-execution.md +1 -0
  38. data/examples/port-blocks.md +14 -10
  39. data/examples/save.md +1 -0
  40. data/examples/text-markup.md +2 -1
  41. data/examples/variable-expansion-save-block.md +48 -0
  42. data/examples/variable-expansion.md +3 -1
  43. data/examples/vars-blocks.md +14 -24
  44. data/examples/wrap.md +2 -1
  45. data/lib/collapser.rb +83 -47
  46. data/lib/evaluate_shell_expressions.rb +3 -2
  47. data/lib/fcb.rb +8 -2
  48. data/lib/hash_delegator.rb +214 -118
  49. data/lib/input_sequencer.rb +0 -7
  50. data/lib/markdown_exec/version.rb +1 -1
  51. data/lib/markdown_exec.rb +6 -1
  52. data/lib/menu.src.yml +22 -9
  53. data/lib/menu.yml +22 -7
  54. data/lib/ww.rb +1 -1
  55. metadata +16 -9
  56. data/docs/dev/table-crash.md +0 -39
  57. data/examples/load_code.md +0 -10
  58. /data/{examples → docs/dev}/load1.sh +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c8e475323e8db8b8288c18f8d97f1c52552c0a292854c42ab2780620bcdb8aa5
4
- data.tar.gz: 254288c200e344c55f49c5fad1717d46550df1892eb526033180ed066f6c449d
3
+ metadata.gz: 2777165b185482931d9fe8e519921490e8e252dcb93d141abf52fc6e53b95ba7
4
+ data.tar.gz: c5925bd62f6853ad701946a2ecca3bf57c8b967b7f65c9990f72c17748591398
5
5
  SHA512:
6
- metadata.gz: b5a6372f45da7c45ae20b0c65058347c66fa17b7afffbacb63f0000c52ff0efd99e18a22f826e7803a1f130868a1dcf0b2f59b48279d19bb1326709a2dc3c04a
7
- data.tar.gz: 4308b84a0591e44e5e2d317c6f0c5cd7b6d74848f91a65aaf85897058321ca041113ee80889313d2b0c1a31a587796af708879f3cd3b169a976755f6cce879c9
6
+ metadata.gz: 0f534d77704be9418666e804a2bf1ecfd6c41ae4cee8b0c7f3c7753f2967b88b257e1962f3f8dc9565af09a697f75fb823054f062bffea9a7aabef9d9bae885e
7
+ data.tar.gz: 18bcdb411c4655bb3f99c8e7557adf7d872c0562fcfeef18700134578dcc9c8e8ecf9992c43c82521eb773aad6d97a95e7f6859d90a36ded25a2ac88e3a2babc
data/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # Changelog
2
2
 
3
+ ## [2.7.0] - 2024-12-09
4
+
5
+ ### Added
6
+
7
+ - Collapse or expand sections defined by heading and dividers per options, section definitions, and user interaction.
8
+ - Command substitution to displayed menu items.
9
+ - Margin on menu to highlight selections.
10
+ - Cycling to file selection menu.
11
+ - Print entire document if there are no active elements.
12
+ - Option to set a screen width. The document and interface are formatted to fit this dimension. The default is 0, which causes to read and use the console width.
13
+
14
+ ### Changed
15
+
16
+ - Highlight prior selection in menu.
17
+ - Display live environment variable values in examples.
18
+
3
19
  ## [2.6.0] - 2024-11-27
4
20
 
5
21
  ### Added
@@ -7,7 +23,7 @@
7
23
  - Ability to collapse and expand sections.
8
24
  - Collapsible state configurable per document and per section.
9
25
  - User can collapse and expand sections in the UI.
10
- - Live shell variable expansion in document text and block content.
26
+ - Live shell variable expansion in text and various non-shell blocks.
11
27
  - Option for name of function to manage executed scripts.
12
28
 
13
29
  ### Changed
@@ -156,7 +172,7 @@
156
172
  ### Changed
157
173
 
158
174
  - Fix block name processing for blocks with no name.
159
- Demo in examples/block_names.md loads content of examples/load1.sh.
175
+ Demo in examples/block_names.md loads content of docs/dev/load1.sh.
160
176
 
161
177
  ## [2.0.5] - 2024-04-24
162
178
 
data/Gemfile.lock CHANGED
@@ -1,12 +1,12 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- markdown_exec (2.6.0)
4
+ markdown_exec (2.7.1)
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)
10
10
 
11
11
  GEM
12
12
  remote: https://rubygems.org/
data/Rakefile CHANGED
@@ -85,11 +85,17 @@ task :bats do
85
85
  end
86
86
  end
87
87
 
88
+ desc 'list Ruby files with tests'
89
+ task :listtests do
90
+ puts `find lib -name '*.rb' -type f | xargs grep '< Minitest::Test' -l | sort`
91
+ end
92
+
88
93
  desc 'minitest'
89
94
  task :minitest do
90
95
  commands = [
91
96
  './lib/argument_processor.rb',
92
97
  './lib/cached_nested_file_reader.rb',
98
+ './lib/collapser.rb',
93
99
  './lib/directory_searcher.rb',
94
100
  './lib/evaluate_shell_expressions.rb',
95
101
  './lib/fcb.rb',
@@ -203,3 +209,33 @@ def words_list(words)
203
209
  %("#{word}")
204
210
  end.join ' '
205
211
  end
212
+
213
+ desc 'Build the Docker image for MarkdownExec'
214
+ task :docker_build do
215
+ dockerfile = 'Dockerfile.ruby-3.3'
216
+ image_tag = "mde-#{MarkdownExec::VERSION}.gem"
217
+
218
+ command = [
219
+ "docker build",
220
+ "--build-arg VERSION=#{MarkdownExec::VERSION}",
221
+ "-f #{dockerfile}",
222
+ "-t #{image_tag}",
223
+ "."
224
+ ].join(' ')
225
+
226
+ puts "Building Docker image: #{image_tag} using #{dockerfile}..."
227
+ puts system(command) || abort("Docker build failed. Please check the output for details.")
228
+ end
229
+
230
+ desc 'Launch an interactive Docker Bash shell'
231
+ task :docker_exec do
232
+ exec "docker exec -it mde-#{MarkdownExec::VERSION}.gem bash"
233
+ end
234
+
235
+ desc 'Run the mde binary inside a Docker container. eg `docker_run -- args`'
236
+ task :docker_run, [:args] do
237
+ args = ARGV.dup
238
+ args.shift
239
+ args.shift if args[0] == '--'
240
+ exec "docker run -it mde-#{MarkdownExec::VERSION}.gem mde #{args.join(' ')}"
241
+ end
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bats
2
+
3
+ load 'test_helper'
4
+
5
+ @test 'Command substitution' {
6
+ spec_mde_xansi_dname_doc_blocks_expect docs/dev/command-substitution.md \
7
+ 'CURRENT BASE NAME IS: MARKDOWN_EXEC_current base name is: markdown_exec_current base name is: markdown_exec_| current base name |_| ----------------- |_| markdown_exec |_: notice the string is not expanded in Shell block types (names or body)._ echo "current base name is now $(basename `pwd`)"__load: file_markdown_exec.sh'
8
+ }
data/bats/options.bats CHANGED
@@ -72,10 +72,10 @@ load 'test_helper'
72
72
  # }
73
73
 
74
74
  @test 'Options - load-code' {
75
- BATS_OUTPUT_FILTER=A
76
- BATS_OUTPUT_GREP=var1
77
- spec_mde_args_expect examples/load_code.md --load-code examples/load1.sh display_variables \
78
- 'var1: line2'
75
+ spec_mde_xansi_dname_doc_blocks_expect docs/dev/load_code.md \
76
+ --load-code docs/dev/load1.sh \
77
+ --list-blocks-message dname --list-blocks-type 3 --list-blocks \
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
 
81
81
  @test 'Options - pwd' {
data/bats/plain.bats ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bats
2
+
3
+ load 'test_helper'
4
+
5
+ @test 'no-active-elements' {
6
+ spec_mde_xansi_dname_doc_blocks_expect docs/dev/no-active-elements.md \
7
+ 'DEMONSTRATE A DOCUMENT WITH NO ACTIVE ELEMENTS_A document with no active elements.'
8
+ }
data/bats/table.bats CHANGED
@@ -4,5 +4,10 @@ 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 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 |'
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
+ }
9
+
10
+ @test 'Tables - invalid' {
11
+ spec_mde_xansi_dname_doc_blocks_expect docs/dev/table-invalid.md \
12
+ 'Missing column names__| ------------------- | - |_| Pongo tapanuliensis | |__Missing dividers__| Species_| Pongo tapanuliensis__Missing table rows__| Species |_| ------- |'
8
13
  }
@@ -4,27 +4,27 @@ 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}_SOURCE is: ${SOURCE}_SOURCE is: ${SOURCE}_| SOURCE |_| --------- |_| ${SOURCE} |_name_with_${SOURCE}_in_name_load: file_${SOURCE}.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' {
11
11
  echo "SOURCE='Loaded file'" > temp_variable_expansion.sh
12
12
  spec_mde_xansi_dname_doc_blocks_expect docs/dev/variable-expansion.md \
13
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'
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
15
  rm temp_variable_expansion.sh
16
16
  }
17
17
 
18
18
  @test 'Variable expansion - LINK_VARS_SOURCE' {
19
19
  spec_mde_xansi_dname_doc_blocks_expect docs/dev/variable-expansion.md \
20
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'
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
22
  }
23
23
 
24
24
  @test 'Variable expansion - VARS_SOURCE' {
25
25
  spec_mde_xansi_dname_doc_blocks_expect docs/dev/variable-expansion.md \
26
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'
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
28
  }
29
29
 
30
30
  ### Load source
data/bin/bmde CHANGED
@@ -2,10 +2,54 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  # encoding=utf-8
5
-
6
5
  require 'bundler/setup'
7
6
  Bundler.require(:default)
8
7
 
9
8
  require_relative '../lib/markdown_exec'
10
9
 
11
- MarkdownExec::MarkParse.new.run
10
+ trace_enabled = false
11
+
12
+ if ENV['MDE_TRACE_POINT']
13
+ trace_output = if ENV['MDE_TRACE_POINT_FILE']
14
+ File.open(ENV['MDE_TRACE_POINT_FILE'], 'a')
15
+ else
16
+ $stderr
17
+ end
18
+
19
+ trace = TracePoint.new(:line) do |tp|
20
+ next unless trace_enabled
21
+
22
+ method_name = tp.method_id || 'unknown_method'
23
+ next if method_name == :method_missing
24
+
25
+ next if tp.path.match?(%r{(/\.bundle/|/\.rbenv/|internal:|lib/colorize|lib/object_present|lib/resize_terminal)})
26
+
27
+ message = "#{'.' * Thread.current.backtrace_locations.size} #{tp.path.sub(Dir.pwd, '')} [#{method_name}] #{tp.lineno + 1}"
28
+
29
+ if trace_output.is_a?(File)
30
+ trace_output.puts(message)
31
+ else
32
+ warn message
33
+ $stderr.flush
34
+ end
35
+ end
36
+
37
+ def tpbreak
38
+ trace_enabled = false
39
+ binding.irb
40
+ end
41
+
42
+ def tpgo
43
+ trace_enabled = true
44
+ end
45
+
46
+ trace.enable
47
+ trace_enabled = true
48
+ end
49
+
50
+ begin
51
+ MarkdownExec::MarkParse.new.run
52
+ ensure
53
+ trace&.disable
54
+ trace_output&.close if trace_output.is_a?(File)
55
+ end
@@ -13,7 +13,7 @@ __filedirs_all()
13
13
  }
14
14
 
15
15
  _mde_echo_version() {
16
- echo "2.6.0"
16
+ echo "2.7.1"
17
17
  }
18
18
 
19
19
  _mde() {
@@ -0,0 +1,24 @@
1
+ # current base name is: $(basename `pwd`)
2
+ :::: current base name is: $(basename `pwd`)
3
+ current base name is: $(basename `pwd`)
4
+ | current base name
5
+ | -
6
+ | $(basename `pwd`)
7
+ ```bash
8
+ : notice the string is not expanded in Shell block types (names or body).
9
+ echo "current base name is now $(basename `pwd`)"
10
+ ```
11
+ ```link
12
+ load: file_$(basename `pwd`).sh
13
+ ```
14
+ @import bats-document-configuration.md
15
+ ```opts :(document_opts)
16
+ heading1_center: false
17
+ heading2_center: false
18
+ heading3_center: false
19
+ menu_final_divider:
20
+ menu_for_saved_lines: false
21
+ menu_initial_divider:
22
+ menu_vars_set_format:
23
+ table_center: false
24
+ ```
@@ -0,0 +1,14 @@
1
+ Demonstrate loading inherited code via the command line.
2
+
3
+ Run this command to display the inherited code.
4
+ `mde --load-code docs/dev/load1.sh docs/dev/load_code.md`
5
+
6
+ | Variable| Value
7
+ | -| -
8
+ | var1| ${var1}
9
+ | var2| ${var2}
10
+ @import bats-document-configuration.md
11
+ ```opts :(document_opts)
12
+ menu_for_saved_lines: false
13
+ table_center: false
14
+ ```
@@ -0,0 +1,6 @@
1
+ # Demonstrate a document with no active elements
2
+ A **document** with no active elements.
3
+ @import bats-document-configuration.md
4
+ ```opts :(document_opts)
5
+ heading1_center: false
6
+ ```
@@ -0,0 +1,21 @@
1
+ The text from "1" to "16" is 38 digits, spaces.
2
+ ::: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
3
+ The text from "17" to "23" is 20 digits, spaces.
4
+ ::: 17 18 19 20 21 22 23
5
+ ```opts
6
+ screen_width: 80
7
+ ```
8
+ ```opts
9
+ screen_width: 60
10
+ ```
11
+ ```opts
12
+ screen_width: 40
13
+ ```
14
+ ```opts
15
+ screen_width: 20
16
+ ```
17
+ @import bats-document-configuration.md
18
+ ```opts :(document_opts)
19
+ divider4_center: true
20
+ divider4_collapsible: false
21
+ ```
@@ -0,0 +1,20 @@
1
+ ::: Missing column names
2
+
3
+ | -| -
4
+ | Pongo tapanuliensis
5
+
6
+
7
+ ::: Missing dividers
8
+
9
+ | Species
10
+ | Pongo tapanuliensis
11
+
12
+ ::: Missing table rows
13
+
14
+ | Species
15
+ | -
16
+
17
+ @import bats-document-configuration.md
18
+ ```opts :(document_opts)
19
+ table_center: false
20
+ ```
@@ -50,9 +50,10 @@ The hidden block "(taxonomy)" prints "taxonomy".
50
50
  echo "taxonomy"
51
51
  ```
52
52
 
53
+ @import example-document-opts.md
53
54
  ```opts :(document_opts)
54
55
  execute_in_own_window: false
55
56
  output_execution_report: false
56
57
  output_execution_summary: false
57
58
  pause_after_script_execution: true
58
- ```
59
+ ```
@@ -54,9 +54,10 @@ The hidden block "(success)" is required above. It prints "Success".
54
54
  echo "Success"
55
55
  ```
56
56
 
57
+ @import example-document-opts.md
57
58
  ```opts :(document_opts)
58
59
  execute_in_own_window: false
59
60
  output_execution_report: false
60
61
  output_execution_summary: false
61
62
  pause_after_script_execution: true
62
- ```
63
+ ```
@@ -16,10 +16,11 @@ Specified block types.
16
16
  a: 1
17
17
  ```
18
18
 
19
+ @import example-document-opts.md
19
20
  ```opts :(document_opts)
20
21
  bash_only: false
21
22
  execute_in_own_window: false
22
23
  output_execution_report: false
23
24
  output_execution_summary: false
24
25
  pause_after_script_execution: true
25
- ```
26
+ ```
@@ -1,5 +1,6 @@
1
1
  # Demonstrate data blocks
2
2
 
3
+ @import example-document-opts.md
3
4
  ```opts :(document_opts)
4
5
  pause_after_script_execution: true
5
6
  ```
@@ -1,5 +1,6 @@
1
1
  This document demonstrates the automatic loading of options in a block with a reserved name.
2
2
 
3
+ @import example-document-opts.md
3
4
  ```opts :(document_opts)
4
5
  menu_divider_format: "=> %{line} == %{line} <="
5
6
  ```
@@ -0,0 +1,6 @@
1
+ ```opts :(document_opts)
2
+ heading1_collapsible: false
3
+ heading2_collapsible: false
4
+ heading3_collapsible: false
5
+ divider4_collapsible: false
6
+ ```
data/examples/index.md CHANGED
@@ -37,7 +37,7 @@ file: examples/linked3.md
37
37
  file: examples/llm.md
38
38
  ```
39
39
  ```link
40
- file: examples/load1.sh
40
+ file: docs/dev/load1.sh
41
41
  ```
42
42
  ```link
43
43
  file: examples/load2.sh
@@ -1,3 +1,4 @@
1
+ @import example-document-opts.md
1
2
  ```opts :(document_opts)
2
3
  pause_after_script_execution: false
3
4
  ```
@@ -1,7 +1,7 @@
1
1
  ::: Load file into inherited lines
2
2
  Load (do not evaluate) and append to inherited lines.
3
3
  ```link :load1
4
- load: examples/load1.sh
4
+ load: docs/dev/load1.sh
5
5
  ```
6
6
  Load, evaluate, and append output to inherited lines.
7
7
  ```link :load2_eval
@@ -12,9 +12,8 @@ eval: true
12
12
  ::: Load file into inherited lines and switch document
13
13
  Load (do not evaluate) and append to inherited lines and switch document.
14
14
  ```link :load_from_file_link_and_show
15
- block: show_vars
16
15
  file: examples/linked_show.md
17
- load: examples/load1.sh
16
+ load: docs/dev/load1.sh
18
17
  ```
19
18
 
20
19
  ::: Save and Load
@@ -23,17 +22,16 @@ Save inherited lines to a file.
23
22
  save: tmp/save1.sh
24
23
  ```
25
24
  Load inherited lines from a file.
26
- Subsequently, run the `display_variables` block.
27
25
  ```link :load_saved
28
26
  load: tmp/save1.sh
29
- block: display_variables
30
- ```
31
- Display variables ALPHA, var1, var2
32
- ```bash :display_variables
33
- source bin/colorize_env_vars.sh
34
- colorize_env_vars '' ALPHA var1 var2
35
27
  ```
36
28
 
29
+ | Variable| Value
30
+ | -| -
31
+ | ALPHA| ${ALPHA}
32
+ | var1| ${var1}
33
+ | var2| ${var2}
34
+
37
35
  ::: Load file matching glob pattern into inherited lines
38
36
  Load (do not evaluate) and append to inherited lines.
39
37
  ```link :load_glob_load1*
@@ -1,4 +1,5 @@
1
1
  # Demonstrate link blocks set variables
2
+ @import example-document-opts.md
2
3
  ```opts :(document_opts)
3
4
  execute_in_own_window: false
4
5
  menu_with_inherited_lines: true
@@ -9,15 +10,14 @@ pause_after_script_execution: true
9
10
 
10
11
  ## Demonstrate a link block that sets a variable
11
12
  ::: Select below to trigger. If it prints "VARIABLE1: 1", the Link block was processed.
12
- The hidden block "(print-VARIABLE1)" is required below. It prints variable "VARIABLE1".
13
- ```bash :(print-VARIABLE1)
14
- source bin/colorize_env_vars.sh
15
- colorize_env_vars '' VARIABLE1
16
- ```
17
- The block sets VARIABLE1 and requires hidden block "(print-VARIABLE1)".
13
+
14
+ | Variable| Value
15
+ | -| -
16
+ | VARIABLE1| ${VARIABLE1}
17
+
18
+ The block sets VARIABLE1.
18
19
  For each environment variable in `vars`, append an inherited line that assigns the variable the specified value.
19
20
  ```link
20
- block: (print-VARIABLE1)
21
21
  vars:
22
22
  VARIABLE1: 1
23
23
  ```
@@ -50,7 +50,10 @@ These blocks require the *output* of the execution of the code in the named shel
50
50
  eval: true
51
51
  next_block: "(display_variable_ALPHA)"
52
52
  ```
53
+
54
+ | Variable| Value
55
+ | -| -
56
+ | ALPHA| ${ALPHA}
57
+
53
58
  ```bash :(display_variable_ALPHA)
54
- source bin/colorize_env_vars.sh
55
- colorize_env_vars '' ALPHA
56
59
  ```
data/examples/linked.md CHANGED
@@ -1,5 +1,6 @@
1
1
  Demonstrate setting variable values interactively for use in generated scripts.
2
2
 
3
+ @import example-document-opts.md
3
4
  ```opts :(document_opts)
4
5
  menu_with_inherited_lines: true
5
6
  pause_after_script_execution: false
@@ -14,7 +15,6 @@ ALPHA: 1
14
15
  ```
15
16
 
16
17
  Make the code in the required block `(bash_set_to_3)` into inherited lines.
17
- Subsequently, run the `display_variable_ALPHA` block.
18
18
  ```bash :(bash_set_to_3)
19
19
  ALPHA=3
20
20
  ```
@@ -24,7 +24,6 @@ block: display_variable_ALPHA
24
24
 
25
25
  Evaluate the code in the required block `(bash_eval_set_to_4)` and
26
26
  save (transformed) output into inherited lines.
27
- Subsequently, run the `display_variable_ALPHA` block.
28
27
  ```link :[set_ALPHA_to_4_via_evaluated_required_block_and_display] +(bash_eval_set_to_4)
29
28
  eval: true
30
29
  next_block: display_variable_ALPHA
@@ -33,16 +32,15 @@ next_block: display_variable_ALPHA
33
32
  echo 'ALPHA="4"'
34
33
  ```
35
34
 
36
- ::: Display value of ALPHA
35
+ /::: Display value of ALPHA
37
36
  ```bash :display_variable_ALPHA
38
- source bin/colorize_env_vars.sh
39
- echo The current value of environment variable ALPHA is now:
40
- colorize_env_vars '' ALPHA
41
37
  ```
38
+ | Variable| Value
39
+ | -| -
40
+ | ALPHA| ${ALPHA}
42
41
 
43
42
  Execute a script requiring input from the user.
44
43
  Save the output setting TIMESTAMP into inherited lines.
45
- Subsequently, run the `display_TIMESTAMP` block.
46
44
  ```bash :(input_timestamp)
47
45
  if [[ -z $TIMESTAMP ]]; then
48
46
  default="$(date -u +%y%m%d)"
@@ -56,13 +54,12 @@ echo "TIMESTAMP=\"$TIMESTAMP\""
56
54
  ```
57
55
  ```link :set_timestamp +(input_timestamp) +(inherit_timestamp)
58
56
  exec: true
59
- block: display_TIMESTAMP
60
- ```
61
- ```bash :display_TIMESTAMP
62
- source bin/colorize_env_vars.sh
63
- colorize_env_vars '' TIMESTAMP
64
57
  ```
65
58
 
59
+ | Variable| Value
60
+ | -| -
61
+ | TIMESTAMP| ${TIMESTAMP}
62
+
66
63
  ## Values
67
64
  Spaces in variable value are unchanged.
68
65
  ```link :link_with_vars_with_spaces
data/examples/linked1.md CHANGED
@@ -1,5 +1,6 @@
1
1
  # Demo document linking
2
2
 
3
+ @import example-document-opts.md
3
4
  ```opts :(document_opts)
4
5
  dump_inherited_lines: true
5
6
  pause_after_script_execution: false
@@ -11,11 +12,12 @@ user_must_approve: false
11
12
 
12
13
  ::: This Bash block displays the value of variables "page1_var_via_environment" and "page2_var_via_environment"
13
14
 
14
- ```bash :show_vars
15
- source bin/colorize_env_vars.sh
16
- colorize_env_vars 'vars for page2' PAGE2_VAR_VIA_INHERIT page2_var_via_environment
17
- colorize_env_vars 'vars for page3' PAGE3_VAR_VIA_INHERIT page3_var_via_environment
18
- ```
15
+ | Variable| Value
16
+ | -| -
17
+ | PAGE2_VAR_VIA_INHERIT| ${PAGE2_VAR_VIA_INHERIT}
18
+ | page2_var_via_environment| ${page2_var_via_environment}
19
+ | PAGE3_VAR_VIA_INHERIT| ${PAGE3_VAR_VIA_INHERIT}
20
+ | page3_var_via_environment| ${page3_var_via_environment}
19
21
 
20
22
  ```bash :(vars2)
21
23
  PAGE2_VAR_VIA_INHERIT=for_page2_from_page1_via_inherited_code_blocks
@@ -37,7 +39,6 @@ file: examples/linked2.md
37
39
 
38
40
  ```link :linked2_import_vars +(vars2)
39
41
  file: examples/linked2.md
40
- block: show_vars
41
42
  vars:
42
43
  page2_var_via_environment: for_page2_from_page1_via_current_environment
43
44
  ```
data/examples/linked2.md CHANGED
@@ -5,16 +5,16 @@
5
5
 
6
6
  ::: This Bash block displays the value of variables "page1_var_via_environment" and "page2_var_via_environment"
7
7
 
8
- ```bash :show_vars
9
- source bin/colorize_env_vars.sh
10
- colorize_env_vars 'vars for page2' PAGE2_VAR_VIA_INHERIT page2_var_via_environment
11
- colorize_env_vars 'vars for page3' PAGE3_VAR_VIA_INHERIT page3_var_via_environment
12
- ```
8
+ | Variable| Value
9
+ | -| -
10
+ | PAGE2_VAR_VIA_INHERIT| ${PAGE2_VAR_VIA_INHERIT}
11
+ | page2_var_via_environment| ${page2_var_via_environment}
12
+ | PAGE3_VAR_VIA_INHERIT| ${PAGE3_VAR_VIA_INHERIT}
13
+ | page3_var_via_environment| ${page3_var_via_environment}
13
14
 
14
15
  ::: This Link block requires a block that
15
16
  ::: 1. sets environment variable PAGE3_VAR_VIA_INHERIT,
16
17
  ::: 2. navigates to document 3, and
17
- ::: 3. executes block "show_vars" to display the imported PAGE3_VAR_VIA_INHERIT.
18
18
 
19
19
  ```bash :(vars3)
20
20
  PAGE3_VAR_VIA_INHERIT=for_page3_from_page2_via_inherited_code_blocks
@@ -30,7 +30,6 @@ file: examples/linked3.md
30
30
 
31
31
  ```link :linked3_import_vars +(vars3)
32
32
  file: examples/linked3.md
33
- block: show_vars
34
33
  vars:
35
34
  page3_var_via_environment: for_page3_from_page2_via_current_environment
36
35
  ```