markdown_exec 2.1.0 → 2.3.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.
- checksums.yaml +4 -4
- data/.rubocop.yml +5 -1
- data/CHANGELOG.md +23 -1
- data/Gemfile +3 -3
- data/Gemfile.lock +134 -92
- data/README.md +13 -13
- data/bin/tab_completion.sh +14 -3
- data/bin/tab_completion.sh.erb +0 -1
- data/examples/bash-blocks.md +58 -0
- data/examples/block-names.md +62 -0
- data/examples/indent.md +43 -2
- data/examples/link-blocks-block.md +5 -0
- data/examples/link-blocks-load-save.md +59 -0
- data/examples/link-blocks-vars.md +56 -0
- data/examples/linked.md +6 -101
- data/examples/opts-blocks-require.md +28 -0
- data/examples/{port.md → port-blocks.md} +18 -9
- data/examples/save.md +76 -4
- data/examples/vars-blocks.md +38 -0
- data/lib/colorize.rb +13 -0
- data/lib/constants.rb +1 -1
- data/lib/fcb.rb +202 -16
- data/lib/filter.rb +12 -12
- data/lib/hash_delegator.rb +695 -326
- data/lib/hierarchy_string.rb +133 -0
- data/lib/input_sequencer.rb +4 -2
- data/lib/link_history.rb +34 -1
- data/lib/markdown_exec/version.rb +1 -1
- data/lib/markdown_exec.rb +67 -79
- data/lib/mdoc.rb +122 -60
- data/lib/menu.src.yml +71 -21
- data/lib/menu.yml +59 -19
- data/lib/namer.rb +50 -0
- data/lib/poly.rb +152 -0
- data/lib/saved_assets.rb +4 -11
- data/lib/string_util.rb +0 -1
- data/lib/text_analyzer.rb +100 -0
- metadata +16 -6
- data/examples/vars.md +0 -20
- /data/examples/{opts.md → opts-blocks.md} +0 -0
- /data/examples/{pass-through.md → pass-through-arguments.md} +0 -0
data/examples/indent.md
CHANGED
@@ -1,4 +1,42 @@
|
|
1
|
-
This document demonstrates
|
1
|
+
# This document demonstrates the indentation of blocks and text
|
2
|
+
|
3
|
+
Indentation is either leading spaces or tabs.
|
4
|
+
Tabs are interpreted as 4 spaces.
|
5
|
+
|
6
|
+
## Related MDE options
|
7
|
+
fenced_start_and_end_regex | Matches the start and end of a fenced code block
|
8
|
+
fenced_start_extended_regex | Match the start of a fenced block
|
9
|
+
heading1_match | MDE_HEADING1_MATCH
|
10
|
+
heading2_match | MDE_HEADING2_MATCH
|
11
|
+
heading3_match | MDE_HEADING3_MATCH
|
12
|
+
menu_divider_match | Pattern for topics/dividers in block selection menu
|
13
|
+
menu_note_match | Pattern for notes in block selection menu
|
14
|
+
menu_task_match | Pattern for tasks
|
15
|
+
|
16
|
+
::: Flush divider, text, block, and comment
|
17
|
+
Text
|
18
|
+
```bash
|
19
|
+
echo 'This is a very long string to force line wrapping in the interface.'
|
20
|
+
# comment indented 1 space
|
21
|
+
```
|
22
|
+
/ Comment
|
23
|
+
|
24
|
+
::: Indented (2 spaces) text, block, and comment
|
25
|
+
Text
|
26
|
+
```bash
|
27
|
+
echo 'This is a very long string to force line wrapping in the interface.'
|
28
|
+
# comment indented 1 space
|
29
|
+
```
|
30
|
+
/ Comment
|
31
|
+
|
32
|
+
::: Indented (1 tab) text, block, and comment
|
33
|
+
Text
|
34
|
+
```bash
|
35
|
+
echo 'This is a very long string to force line wrapping in the interface.'
|
36
|
+
# comment indented 1 space
|
37
|
+
```
|
38
|
+
/ Comment
|
39
|
+
|
2
40
|
|
3
41
|
This is a concise guide for using Bash commands to find and list recent files in a Linux system. The commands are safe to use and can help you quickly locate recently modified or accessed files.
|
4
42
|
|
@@ -45,24 +83,27 @@ These commands provide a basic way to manage and track file modifications and ac
|
|
45
83
|
|
46
84
|
```link :Link1
|
47
85
|
```
|
48
|
-
|
86
|
+
::: Indented (4 spaces) Link block
|
49
87
|
```link :Link2
|
50
88
|
```
|
51
89
|
|
52
90
|
```opts :Opts1
|
53
91
|
```
|
54
92
|
|
93
|
+
::: Indented (4 spaces) Opts block
|
55
94
|
```opts :Opts2
|
56
95
|
```
|
57
96
|
|
58
97
|
```port :Port1
|
59
98
|
```
|
60
99
|
|
100
|
+
::: Indented (4 spaces) Port block
|
61
101
|
```port :Port2
|
62
102
|
```
|
63
103
|
|
64
104
|
```vars :Vars1
|
65
105
|
```
|
66
106
|
|
107
|
+
::: Indented (4 spaces) Vars block
|
67
108
|
```vars :Vars2
|
68
109
|
```
|
@@ -0,0 +1,59 @@
|
|
1
|
+
::: Load file into inherited lines
|
2
|
+
Load (do not evaluate) and append to inherited lines.
|
3
|
+
```link :load1
|
4
|
+
load: examples/load1.sh
|
5
|
+
```
|
6
|
+
Load, evaluate, and append output to inherited lines.
|
7
|
+
```link :load2_eval
|
8
|
+
load: examples/load2.sh
|
9
|
+
eval: true
|
10
|
+
```
|
11
|
+
|
12
|
+
::: Load file into inherited lines and switch document
|
13
|
+
Load (do not evaluate) and append to inherited lines and switch document.
|
14
|
+
```link :load_from_file_link_and_show
|
15
|
+
block: show_vars
|
16
|
+
file: examples/linked_show.md
|
17
|
+
load: examples/load1.sh
|
18
|
+
```
|
19
|
+
|
20
|
+
::: Save and Load
|
21
|
+
Save inherited lines to a file.
|
22
|
+
```link :save1
|
23
|
+
save: tmp/save1.sh
|
24
|
+
```
|
25
|
+
Load inherited lines from a file.
|
26
|
+
Subsequently, run the `display_variables` block.
|
27
|
+
```link :load_saved
|
28
|
+
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
|
+
```
|
36
|
+
|
37
|
+
::: Load file matching glob pattern into inherited lines
|
38
|
+
Load (do not evaluate) and append to inherited lines.
|
39
|
+
```link :load_glob_load1*
|
40
|
+
load: examples/load1*.sh
|
41
|
+
```
|
42
|
+
```link :load_glob_load*
|
43
|
+
load: examples/load*.sh
|
44
|
+
```
|
45
|
+
```link :load_glob_fail
|
46
|
+
load: examples/fail*
|
47
|
+
```
|
48
|
+
```link :load_glob_with_format
|
49
|
+
load: "%{home}/examples/load*.sh"
|
50
|
+
```
|
51
|
+
```link :save_glob_load*
|
52
|
+
save: examples/*.sh
|
53
|
+
```
|
54
|
+
```link :save_glob_*
|
55
|
+
save: examples/*.sh
|
56
|
+
```
|
57
|
+
```link :load_glob_*
|
58
|
+
load: examples/*.sh
|
59
|
+
```
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# Demonstrate link blocks set variables
|
2
|
+
```opts :(document_options)
|
3
|
+
execute_in_own_window: false
|
4
|
+
menu_with_inherited_lines: true
|
5
|
+
output_execution_report: false
|
6
|
+
output_execution_summary: false
|
7
|
+
pause_after_script_execution: true
|
8
|
+
```
|
9
|
+
|
10
|
+
## Demonstrate a link block that sets a variable
|
11
|
+
::: Click 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)".
|
18
|
+
For each environment variable in `vars`, append an inherited line that assigns the variable the specified value.
|
19
|
+
```link
|
20
|
+
block: (print-VARIABLE1)
|
21
|
+
vars:
|
22
|
+
VARIABLE1: 1
|
23
|
+
```
|
24
|
+
|
25
|
+
## Demonstrate a link block that requires a shell block that sets a variable
|
26
|
+
This block "[bash_set_to_3]" is required below. It sets the variable "ALPHA".
|
27
|
+
```bash :[bash_set_to_3]
|
28
|
+
ALPHA=3
|
29
|
+
```
|
30
|
+
::: Click below to trigger. If it prints "ALPHA: 3", the Link block was processed.
|
31
|
+
These blocks require the *code* of the named shell block.
|
32
|
+
```link +[bash_set_to_3]
|
33
|
+
block: "(display_variable_ALPHA)"
|
34
|
+
```
|
35
|
+
```link +[bash_set_to_3]
|
36
|
+
next_block: "(display_variable_ALPHA)"
|
37
|
+
```
|
38
|
+
|
39
|
+
This block "[bash_set_to_4]" is required below. It prints a command that sets the variable "ALPHA".
|
40
|
+
```bash :[bash_set_to_4]
|
41
|
+
echo "ALPHA=4"
|
42
|
+
```
|
43
|
+
::: Click below to trigger. If it prints "ALPHA: 4", the Link block was processed.
|
44
|
+
These blocks require the *output* of the execution of the code in the named shell block.
|
45
|
+
```link +[bash_set_to_4]
|
46
|
+
eval: true
|
47
|
+
block: "(display_variable_ALPHA)"
|
48
|
+
```
|
49
|
+
```link +[bash_set_to_4]
|
50
|
+
eval: true
|
51
|
+
next_block: "(display_variable_ALPHA)"
|
52
|
+
```
|
53
|
+
```bash :(display_variable_ALPHA)
|
54
|
+
source bin/colorize_env_vars.sh
|
55
|
+
colorize_env_vars '' ALPHA
|
56
|
+
```
|
data/examples/linked.md
CHANGED
@@ -6,38 +6,6 @@ pause_after_script_execution: false
|
|
6
6
|
user_must_approve: false
|
7
7
|
```
|
8
8
|
|
9
|
-
```link :missing_block
|
10
|
-
block: (display_variable)
|
11
|
-
eval: true
|
12
|
-
```
|
13
|
-
Block name with all chars.
|
14
|
-
/ !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~
|
15
|
-
/ ¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ
|
16
|
-
```link :!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~
|
17
|
-
file: examples/linked2.md
|
18
|
-
block: show_vars
|
19
|
-
vars:
|
20
|
-
page2_var_via_environment: for_page2_from_page1_via_current_environment
|
21
|
-
```
|
22
|
-
```link :¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ
|
23
|
-
file: examples/linked2.md
|
24
|
-
block: show_vars
|
25
|
-
vars:
|
26
|
-
page2_var_via_environment: for_page2_from_page1_via_current_environment
|
27
|
-
```
|
28
|
-
Block with no title is displayed correctly in a single line (for a Bash comment).
|
29
|
-
```link
|
30
|
-
file: examples/linked2.md
|
31
|
-
block: show_vars
|
32
|
-
vars:
|
33
|
-
page2_var_via_environment: for_page2_from_page1_via_current_environment
|
34
|
-
```
|
35
|
-
Spaces in variable value are unchanged.
|
36
|
-
```link :link_with_vars_with_spaces
|
37
|
-
vars:
|
38
|
-
test: "1 2 3"
|
39
|
-
```
|
40
|
-
|
41
9
|
::: Set variable ALPHA in a Vars block
|
42
10
|
For each environment variable named in block,
|
43
11
|
append an inherited line that assigns the variable the specified value.
|
@@ -45,16 +13,6 @@ For each environment variable named in block,
|
|
45
13
|
ALPHA: 1
|
46
14
|
```
|
47
15
|
|
48
|
-
::: Set variable ALPHA in a Link block
|
49
|
-
For each environment variable in `vars`,
|
50
|
-
append an inherited line that assigns the variable the specified value.
|
51
|
-
Subsequently, run the `display_variable_ALPHA` block.
|
52
|
-
```link :[set_ALPHA_to_2_via_link_block_and_display]
|
53
|
-
block: display_variable_ALPHA
|
54
|
-
vars:
|
55
|
-
ALPHA: 2
|
56
|
-
```
|
57
|
-
|
58
16
|
Make the code in the required block `(bash_set_to_3)` into inherited lines.
|
59
17
|
Subsequently, run the `display_variable_ALPHA` block.
|
60
18
|
```bash :(bash_set_to_3)
|
@@ -82,42 +40,6 @@ echo The current value of environment variable ALPHA is now:
|
|
82
40
|
colorize_env_vars '' ALPHA
|
83
41
|
```
|
84
42
|
|
85
|
-
::: Load file into inherited lines
|
86
|
-
Load (do not evaluate) and append to inherited lines.
|
87
|
-
```link :load1
|
88
|
-
load: examples/load1.sh
|
89
|
-
```
|
90
|
-
Load, evaluate, and append output to inherited lines.
|
91
|
-
```link :load2_eval
|
92
|
-
load: examples/load2.sh
|
93
|
-
eval: true
|
94
|
-
```
|
95
|
-
|
96
|
-
::: Load file into inherited lines and switch document
|
97
|
-
Load (do not evaluate) and append to inherited lines and switch document.
|
98
|
-
```link :load_from_file_link_and_show
|
99
|
-
block: show_vars
|
100
|
-
file: examples/linked_show.md
|
101
|
-
load: examples/load1.sh
|
102
|
-
```
|
103
|
-
|
104
|
-
::: Save and Load
|
105
|
-
Save inherited lines to a file.
|
106
|
-
```link :save1
|
107
|
-
save: tmp/save1.sh
|
108
|
-
```
|
109
|
-
Load inherited lines from a file.
|
110
|
-
Subsequently, run the `display_variables` block.
|
111
|
-
```link :load_saved
|
112
|
-
load: tmp/save1.sh
|
113
|
-
block: display_variables
|
114
|
-
```
|
115
|
-
Display variables ALPHA, var1, var2
|
116
|
-
```bash :display_variables
|
117
|
-
source bin/colorize_env_vars.sh
|
118
|
-
colorize_env_vars '' ALPHA var1 var2
|
119
|
-
```
|
120
|
-
|
121
43
|
Execute a script requiring input from the user.
|
122
44
|
Save the output setting TIMESTAMP into inherited lines.
|
123
45
|
Subsequently, run the `display_TIMESTAMP` block.
|
@@ -141,26 +63,9 @@ source bin/colorize_env_vars.sh
|
|
141
63
|
colorize_env_vars '' TIMESTAMP
|
142
64
|
```
|
143
65
|
|
144
|
-
|
145
|
-
|
146
|
-
```link :
|
147
|
-
|
148
|
-
|
149
|
-
```
|
150
|
-
load: examples/load*.sh
|
151
|
-
```
|
152
|
-
```link :load_glob_fail
|
153
|
-
load: examples/fail*
|
154
|
-
```
|
155
|
-
```link :load_glob_with_format
|
156
|
-
load: "%{home}/examples/load*.sh"
|
157
|
-
```
|
158
|
-
```link :save_glob_load*
|
159
|
-
save: examples/*.sh
|
160
|
-
```
|
161
|
-
```link :save_glob_*
|
162
|
-
save: examples/*.sh
|
163
|
-
```
|
164
|
-
```link :load_glob_*
|
165
|
-
load: examples/*.sh
|
166
|
-
```
|
66
|
+
## Values
|
67
|
+
Spaces in variable value are unchanged.
|
68
|
+
```link :link_with_vars_with_spaces
|
69
|
+
vars:
|
70
|
+
test: "1 2 3"
|
71
|
+
```
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# Demonstrate requiring blocks
|
2
|
+
```opts :(document_options) +(custom) +[custom]
|
3
|
+
menu_divider_color: red # color to indicate failure
|
4
|
+
```
|
5
|
+
```opts :(custom)
|
6
|
+
menu_divider_color: green # color to indicate success
|
7
|
+
```
|
8
|
+
## Automatic documents options
|
9
|
+
::: If this text is green, the required Opts block was processed; if this text is red, the required Opts block was NOT processed hidden, name: "(custom)"
|
10
|
+
|
11
|
+
## Click this named block to test
|
12
|
+
::: Click below to trigger. If this text starts with "+++", the required Opts block was processed; name: "custom"
|
13
|
+
```opts :custom
|
14
|
+
menu_divider_format: "+++ %{line}" # format to indicate success
|
15
|
+
```
|
16
|
+
|
17
|
+
## Click this nicknamed block to test
|
18
|
+
::: Click below to trigger. If this text starts with "!!!", the Opts block was processed; name: "[custom]"
|
19
|
+
This block has a nickname "[custom]". It is executable.
|
20
|
+
```opts :[custom]
|
21
|
+
menu_divider_format: "!!! %{line}" # format to indicate success
|
22
|
+
```
|
23
|
+
|
24
|
+
## Click this unnamed block to test
|
25
|
+
::: Click below to trigger. If this text starts with "@@@", the required Opts block was processed; unnamed
|
26
|
+
```opts
|
27
|
+
menu_divider_format: "@@@ %{line}" # format to indicate success
|
28
|
+
```
|
@@ -1,12 +1,11 @@
|
|
1
1
|
# Demo variable porting
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
:
|
8
|
-
|
9
|
-
colorize_env_vars '' VAULT
|
3
|
+
```opts :(document_options)
|
4
|
+
dump_inherited_lines: true
|
5
|
+
execute_in_own_window: false
|
6
|
+
output_execution_report: false
|
7
|
+
output_execution_summary: false
|
8
|
+
pause_after_script_execution: true
|
10
9
|
```
|
11
10
|
|
12
11
|
::: Set the VAULT value in memory.
|
@@ -16,8 +15,18 @@ colorize_env_vars '' VAULT
|
|
16
15
|
VAULT: This variable was set by the "set" block.
|
17
16
|
```
|
18
17
|
|
19
|
-
:::
|
18
|
+
::: This is a Port block that saves current/live environment variable values into the generated script.
|
20
19
|
|
21
|
-
```port :
|
20
|
+
```port :[vault]
|
22
21
|
VAULT
|
22
|
+
VAULT2
|
23
|
+
```
|
24
|
+
|
25
|
+
::: This block requires the Port block and displays the value.
|
26
|
+
::: The Port block contributes the variable VAULT to the generated script.
|
27
|
+
|
28
|
+
```bash :show +[vault]
|
29
|
+
: ${VAULT:=This variable has not been set.}
|
30
|
+
source bin/colorize_env_vars.sh
|
31
|
+
colorize_env_vars '' VAULT
|
23
32
|
```
|
data/examples/save.md
CHANGED
@@ -1,7 +1,79 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
# Demonstrate custom file names
|
2
|
+
```opts :(document_options) +[custom]
|
3
|
+
pause_after_script_execution: true # for interactive demos
|
4
|
+
save_executed_script: true # demonstrate saved scripts
|
5
|
+
save_execution_output: true # demonstrate saved output
|
4
6
|
```
|
5
|
-
|
7
|
+
|
8
|
+
## Related MDE options
|
9
|
+
save_executed_script | Whether to save an executed script
|
10
|
+
save_execution_output | Save standard output of the executed script
|
11
|
+
saved_asset_format | Format for script and log file names
|
12
|
+
saved_asset_match | Regexp for script and log file names
|
13
|
+
saved_history_format | Format for each row displayed in history
|
14
|
+
|
15
|
+
### Add "DOMAIN" shell expansion. Include a wildcard as default to allow for matching when undefined.
|
16
|
+
::: Default
|
17
|
+
```opts
|
18
|
+
saved_asset_format: "%{prefix}%{join}%{time}%{join}%{filename}%{join}%{mark}%{join}%{blockname}%{join}%{exts}"
|
19
|
+
```
|
20
|
+
::: Custom
|
21
|
+
```opts :[custom]
|
22
|
+
# Add "DOMAIN" shell expansion. Include a wildcard as default to allow for matching when undefined.
|
23
|
+
saved_asset_format: "%{prefix}%{join}${DOMAIN:-*}%{join}%{time}%{join}%{filename}%{join}%{mark}%{join}%{blockname}%{join}%{exts}"
|
24
|
+
```
|
25
|
+
### Add "domain" capture group
|
26
|
+
::: Default
|
27
|
+
```opts
|
28
|
+
saved_asset_match: "^(?<prefix>.+)(?<join>_)(?<time>[0-9\\-]+)\\g'join'(?<filename>.+)\\g'join'(?<mark>~)\\g'join'(?<blockname>.+)\\g'join'(?<exts>\\..+)$"
|
29
|
+
```
|
30
|
+
::: Custom
|
31
|
+
```opts :[custom]
|
32
|
+
# Add "domain" capture group
|
33
|
+
saved_asset_match: "^(?<prefix>.+)(?<join>_)(?<domain>.*)\\g'join'(?<time>[0-9\\-]+)\\g'join'(?<filename>.+)\\g'join'(?<mark>~)\\g'join'(?<blockname>.+)\\g'join'(?<exts>\\..+)$"
|
34
|
+
```
|
35
|
+
### Add "domain" to history display
|
36
|
+
::: Default
|
37
|
+
```opts
|
38
|
+
saved_history_format: "%{time} %{blockname} %{exts}"
|
39
|
+
```
|
40
|
+
::: Custom
|
41
|
+
```opts :[custom]
|
42
|
+
# Add "domain" to history display
|
43
|
+
saved_history_format: "%{domain} %{time} %{blockname} %{exts}"
|
44
|
+
```
|
45
|
+
|
46
|
+
## Append to Inherited Lines
|
47
|
+
::: Load the DOMAIN variable.
|
48
|
+
1. Set DOMAIN to "site.local"
|
49
|
+
```vars
|
50
|
+
DOMAIN: site.local
|
51
|
+
```
|
52
|
+
|
53
|
+
2. Set DOMAIN to "site.remote"
|
54
|
+
```vars
|
55
|
+
DOMAIN: site.remote
|
56
|
+
```
|
57
|
+
|
58
|
+
- Notice how the history changes according to the current DOMAIN.
|
59
|
+
|
60
|
+
## Saved files
|
61
|
+
::: Run this command to generate files for the script and the output of the execution.
|
62
|
+
```bash :test +(test2)
|
6
63
|
echo "$(date -u)"
|
7
64
|
```
|
65
|
+
```bash :(test2)
|
66
|
+
echo "$(date -u)"
|
67
|
+
```
|
68
|
+
- Notice how the saved files increase by 2 with every execution.
|
69
|
+
::: Test block with no name
|
70
|
+
```bash
|
71
|
+
sleep 1
|
72
|
+
echo $(date -u)
|
73
|
+
sleep 2
|
74
|
+
echo $(date -u)
|
75
|
+
sleep 3
|
76
|
+
echo $(date -u)
|
77
|
+
sleep 4
|
78
|
+
echo $(date -u)
|
79
|
+
```
|
@@ -0,0 +1,38 @@
|
|
1
|
+
```opts :(document_options)
|
2
|
+
execute_in_own_window: false
|
3
|
+
output_execution_report: false
|
4
|
+
output_execution_summary: false
|
5
|
+
pause_after_script_execution: true
|
6
|
+
```
|
7
|
+
The hidden block "(defaults)" sets the environment variable VAULT to "default" if it is unset.
|
8
|
+
```bash :(defaults)
|
9
|
+
: ${VAULT:=default}
|
10
|
+
```
|
11
|
+
|
12
|
+
::: Click below to trigger. If it prints "VAULT: default", the shell block was processed.
|
13
|
+
The named block prints the environment variable VAULT. It requires hidden block "(defaults)" before printing.
|
14
|
+
```bash :show_vars +(defaults)
|
15
|
+
source bin/colorize_env_vars.sh
|
16
|
+
colorize_env_vars '' VAULT
|
17
|
+
```
|
18
|
+
|
19
|
+
The block sets the environment variable VAULT to "11".
|
20
|
+
When clicked, it adds the variable to the inherited code. It does not output.
|
21
|
+
```vars :[set_vault_11]
|
22
|
+
VAULT: 11
|
23
|
+
```
|
24
|
+
|
25
|
+
# DOES NOT WORK 2024-07-20
|
26
|
+
## This does not evaluate the shell block.
|
27
|
+
::: Click below to trigger. If it prints "VAULT: 22", the shell block was processed.
|
28
|
+
The block sets the environment variable VAULT to "22". It requires block "show_vars". Notice block "show_vars" is called after the variable is set.
|
29
|
+
```vars :[set_with_show] +show_vars
|
30
|
+
VAULT: 22
|
31
|
+
```
|
32
|
+
|
33
|
+
## This outputs the value before the variable is set.
|
34
|
+
The named block prints the environment variable VAULT. It requires block "set".
|
35
|
+
```bash :show_with_set +[set_vault_11]
|
36
|
+
source bin/colorize_env_vars.sh
|
37
|
+
colorize_env_vars '' VAULT
|
38
|
+
```
|
data/lib/colorize.rb
CHANGED
@@ -101,4 +101,17 @@ class String
|
|
101
101
|
def red; fg_rgbh_FF_00_00; end
|
102
102
|
def violet; fg_rgbh_94_00_D3; end
|
103
103
|
def yellow; fg_rgbh_FF_FF_00; end
|
104
|
+
|
105
|
+
# graphics modes
|
106
|
+
def bold; "\033[1m#{self}\033[22m"; end
|
107
|
+
def bold_italic; "\033[1m\033[3m#{self}\033[22m\033[23m"; end
|
108
|
+
def bold_underline; "\033[1m\033[4m#{self}\033[22m\033[24m"; end
|
109
|
+
def dim; "\033[2m#{self}\033[22m"; end
|
110
|
+
def italic; "\033[3m#{self}\033[23m"; end
|
111
|
+
def underline; "\033[4m#{self}\033[24m"; end
|
112
|
+
def underline_italic; "\033[4m\033[3m#{self}\033[23m\033[24m"; end
|
113
|
+
def blinking; "\033[5m#{self}\033[25m"; end
|
114
|
+
def inverse; "\033[7m#{self}\033[27m"; end
|
115
|
+
def hidden; "\033[8m#{self}\033[28m"; end
|
116
|
+
def strikethrough; "\033[9m#{self}\033[29m"; end
|
104
117
|
end
|
data/lib/constants.rb
CHANGED