markdown_exec 1.4 → 1.5
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/.pryrc +3 -1
- data/.rubocop.yml +3 -1
- data/CHANGELOG.md +29 -0
- data/Gemfile.lock +1 -1
- data/bin/bmde +103 -1
- data/bin/tab_completion.sh +2 -2
- data/examples/linked1.md +1 -0
- data/examples/linked2.md +0 -1
- data/examples/opts.md +16 -4
- data/lib/block_types.rb +9 -5
- data/lib/filter.rb +15 -4
- data/lib/markdown_exec/version.rb +1 -1
- data/lib/markdown_exec.rb +607 -341
- data/lib/mdoc.rb +106 -32
- data/lib/menu.src.yml +173 -6
- data/lib/menu.yml +62 -7
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 41787e8352174177ca182e0376cabec7aee5923af43536a81fc2a9e61ee109e3
|
4
|
+
data.tar.gz: 6a6c1fa34bf57aad286892772dcdbec19abb41fdb0385a69e264fee70747f742
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a4b9377c62c5054d077974b2056d7f89acd54088cd064d9c495b10eda49f64750154dc6618e6f7719dee93aaf3a0e0ca3cafa8d8fd7ca3ccbdb970e2c433b23c
|
7
|
+
data.tar.gz: c9ed40b8c0df7b4b41e2db40d495a420ae1a294bbdd0c7df7702f5bfd99c6e9931a89e197e0fb5b3109fbec3403ef2b7c28126b1f0d000c6aea7c0426cde9a34
|
data/.pryrc
CHANGED
@@ -1,9 +1,11 @@
|
|
1
1
|
if defined?(PryByebug)
|
2
2
|
Pry.config.pager = false
|
3
3
|
Pry.commands.alias_command 'c', 'continue'
|
4
|
+
Pry.commands.alias_command 'd', 'down'
|
4
5
|
Pry.commands.alias_command 'f', 'finish'
|
5
|
-
Pry.commands.alias_command 's', 'step'
|
6
6
|
Pry.commands.alias_command 'n', 'next'
|
7
|
+
Pry.commands.alias_command 's', 'step'
|
8
|
+
Pry.commands.alias_command 'u', 'up'
|
7
9
|
|
8
10
|
Pry::Commands.command /^$/, 'repeat last command' do
|
9
11
|
_pry_.run_command Pry.history.to_a.last
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,34 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## [1.5] - 2023-11-08
|
4
|
+
|
5
|
+
### Added
|
6
|
+
|
7
|
+
- Confirmation between execution of block and display of next menu.
|
8
|
+
- Option for block loaded automatically per document.
|
9
|
+
- Options for note lines copied from source into menu.
|
10
|
+
- Options to format menu chrome.
|
11
|
+
- Options to generate title for a block without a name.
|
12
|
+
- Remove consecutive blank lines from menu.
|
13
|
+
- Restore options between menu choices. Add options for "notes" in menu.
|
14
|
+
|
15
|
+
## [1.4.1] - 2023-11-02
|
16
|
+
|
17
|
+
### Added
|
18
|
+
|
19
|
+
- Support for nested links.
|
20
|
+
A Link block name can be followed by the block name to execute in the linked document.
|
21
|
+
Nested links result in scripts with nested required blocks.
|
22
|
+
|
23
|
+
## [1.4] - 2023-10-31
|
24
|
+
|
25
|
+
### Added
|
26
|
+
|
27
|
+
- Add required code blocks to link block types.
|
28
|
+
Allows for nested required code as links are navigated.
|
29
|
+
|
30
|
+
- Add fg_rgbh_* methods to process hex RGB specifications.
|
31
|
+
|
3
32
|
## [1.3.9] - 2023-10-29
|
4
33
|
|
5
34
|
Add block types for linking and variable control
|
data/Gemfile.lock
CHANGED
data/bin/bmde
CHANGED
@@ -8,4 +8,106 @@ Bundler.require(:default)
|
|
8
8
|
|
9
9
|
require_relative '../lib/markdown_exec'
|
10
10
|
|
11
|
-
|
11
|
+
if true
|
12
|
+
|
13
|
+
MarkdownExec::MarkParse.new.run
|
14
|
+
else
|
15
|
+
|
16
|
+
def trace_event_properties(tp)
|
17
|
+
# TracePoint.new(:call, :return, :c_call, :c_return, :raise) do |tp|
|
18
|
+
# puts "Event information:"
|
19
|
+
# puts "Event type: #{tp.event}"
|
20
|
+
# puts "File: #{tp.path}"
|
21
|
+
# puts "Line: #{tp.lineno}"
|
22
|
+
# puts "Defined class: #{tp.defined_class}"
|
23
|
+
# puts "Method ID: #{tp.method_id}"
|
24
|
+
# puts "Class method ID: #{tp.defined_class} #{tp.method_id}"
|
25
|
+
# puts "Binding: #{tp.binding.inspect}"
|
26
|
+
# puts "Return value: #{tp.return_value.inspect}" if [:return, :c_return].include?(tp.event)
|
27
|
+
puts "Raised exception: #{tp.raised_exception.inspect}" if tp.event == :raise
|
28
|
+
# puts "---------------------------------"
|
29
|
+
# binding.pry
|
30
|
+
# print format("\n%-20.20s %-20.20s % 5.5d %20s %s", tp.method_id, tp.defined_class, tp.lineno, tp.path.split('/').last, caller[1].split('/').last)
|
31
|
+
|
32
|
+
# print format("\n%-20.20s %-30.30s %s", tp.method_id, tp.defined_class, caller[1].split('/').last.split(':', 3)[0..1].join(':'))
|
33
|
+
# print __LINE__, '.'
|
34
|
+
return if %i[method_missing present?].include?(tp.method_id)
|
35
|
+
return unless %r(/markdown_exec/lib/) =~ caller[1]
|
36
|
+
|
37
|
+
if [:return, :c_return].include?(tp.event)
|
38
|
+
print format("%1.1s %-20.20s %s\n", tp.event, tp.method_id, tp.return_value)
|
39
|
+
else
|
40
|
+
print format("%1.1s %-20.20s %-30.30s %20s\n", tp.event, tp.method_id, tp.defined_class, $~.post_match)
|
41
|
+
end
|
42
|
+
# end.enable
|
43
|
+
end
|
44
|
+
|
45
|
+
def start_trace(events = [:call])
|
46
|
+
trace = TracePoint.new(*events) do |tp|
|
47
|
+
trace_event_properties(tp)
|
48
|
+
end
|
49
|
+
|
50
|
+
trace.enable
|
51
|
+
yield
|
52
|
+
trace.disable
|
53
|
+
end
|
54
|
+
|
55
|
+
start_trace([:call, :return]) { MarkdownExec::MarkParse.new.run }
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
=begin
|
62
|
+
|
63
|
+
To filter what is traced, you can pass any of the following as events:
|
64
|
+
|
65
|
+
:line
|
66
|
+
execute an expression or statement on a new line
|
67
|
+
|
68
|
+
:class
|
69
|
+
start a class or module definition
|
70
|
+
|
71
|
+
:end
|
72
|
+
finish a class or module definition
|
73
|
+
|
74
|
+
:call
|
75
|
+
call a Ruby method
|
76
|
+
|
77
|
+
:return
|
78
|
+
return from a Ruby method
|
79
|
+
|
80
|
+
:c_call
|
81
|
+
call a C-language routine
|
82
|
+
|
83
|
+
:c_return
|
84
|
+
return from a C-language routine
|
85
|
+
|
86
|
+
:raise
|
87
|
+
raise an exception
|
88
|
+
|
89
|
+
:b_call
|
90
|
+
event hook at block entry
|
91
|
+
|
92
|
+
:b_return
|
93
|
+
event hook at block ending
|
94
|
+
|
95
|
+
:a_call
|
96
|
+
event hook at all calls (call, b_call, and c_call)
|
97
|
+
|
98
|
+
:a_return
|
99
|
+
event hook at all returns (return, b_return, and c_return)
|
100
|
+
|
101
|
+
:thread_begin
|
102
|
+
event hook at thread beginning
|
103
|
+
|
104
|
+
:thread_end
|
105
|
+
event hook at thread ending
|
106
|
+
|
107
|
+
:fiber_switch
|
108
|
+
event hook at fiber switch
|
109
|
+
|
110
|
+
:script_compiled
|
111
|
+
new Ruby code compiled (with eval, load or require)
|
112
|
+
|
113
|
+
=end
|
data/bin/tab_completion.sh
CHANGED
@@ -13,7 +13,7 @@ __filedirs_all()
|
|
13
13
|
}
|
14
14
|
|
15
15
|
_mde_echo_version() {
|
16
|
-
echo "1.
|
16
|
+
echo "1.5"
|
17
17
|
}
|
18
18
|
|
19
19
|
_mde() {
|
@@ -138,4 +138,4 @@ _mde() {
|
|
138
138
|
|
139
139
|
complete -o filenames -o nospace -F _mde mde
|
140
140
|
# _mde_echo_version
|
141
|
-
# echo "Updated: 2023-
|
141
|
+
# echo "Updated: 2023-11-08 15:34:04 UTC"
|
data/examples/linked1.md
CHANGED
@@ -15,6 +15,7 @@ colorize_env_vars 'vars for page3' PAGE3_VAR_VIA_INHERIT page3_var_via_environme
|
|
15
15
|
::: 1. requires a block that sets environment variable PAGE2_VAR_VIA_INHERIT,
|
16
16
|
::: 2. navigates to document 2, and
|
17
17
|
::: 3. executes block "show_vars" to display the imported PAGE2_VAR_VIA_INHERIT.
|
18
|
+
::: Any script generated by page 2 will contain the inherited code.
|
18
19
|
|
19
20
|
```bash :(vars2)
|
20
21
|
PAGE2_VAR_VIA_INHERIT=for_page2_from_page1_via_inherited_code_file
|
data/examples/linked2.md
CHANGED
@@ -11,7 +11,6 @@ colorize_env_vars 'vars for page2' PAGE2_VAR_VIA_INHERIT page2_var_via_environme
|
|
11
11
|
colorize_env_vars 'vars for page3' PAGE3_VAR_VIA_INHERIT page3_var_via_environment
|
12
12
|
```
|
13
13
|
|
14
|
-
|
15
14
|
::: This Link block requires a block that
|
16
15
|
::: 1. sets environment variable PAGE3_VAR_VIA_INHERIT,
|
17
16
|
::: 2. navigates to document 3, and
|
data/examples/opts.md
CHANGED
@@ -1,13 +1,25 @@
|
|
1
1
|
# Demo configuring options
|
2
|
-
|
2
|
+
+ note1
|
3
|
+
a
|
3
4
|
::: These Opts blocks set the color of a couple of menu options to demonstrate the live update of options.
|
4
|
-
|
5
|
+
b
|
6
|
+
+ note2
|
7
|
+
c
|
5
8
|
```opts :opts1
|
6
9
|
menu_divider_color: yellow
|
10
|
+
menu_note_match:
|
7
11
|
menu_task_color: fg_rgb_255_63_255
|
8
12
|
```
|
9
|
-
|
13
|
+
+ note3
|
10
14
|
```opts :opts2
|
11
|
-
menu_divider_color:
|
15
|
+
menu_divider_color: red
|
16
|
+
menu_note_color: yellow
|
17
|
+
menu_note_match: "^\\+ +(?<line>.+?) *$"
|
12
18
|
menu_task_color: fg_rgb_127_127_255
|
13
19
|
```
|
20
|
+
+ note4
|
21
|
+
```opts :(document_options)
|
22
|
+
menu_divider_color: green
|
23
|
+
menu_link_color: fg_rgbh_88_cc_66
|
24
|
+
menu_note_color: yellow
|
25
|
+
```
|
data/lib/block_types.rb
CHANGED
@@ -1,7 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
3
|
+
class BlockType
|
4
|
+
ALL = [
|
5
|
+
BASH = 'bash',
|
6
|
+
LINK = 'link',
|
7
|
+
OPTS = 'opts',
|
8
|
+
PORT = 'port',
|
9
|
+
VARS = 'vars'
|
10
|
+
].freeze
|
11
|
+
end
|
data/lib/filter.rb
CHANGED
@@ -125,7 +125,7 @@ module MarkdownExec
|
|
125
125
|
|
126
126
|
return unless options[:bash_only]
|
127
127
|
|
128
|
-
filters[:shell_default] = (shell ==
|
128
|
+
filters[:shell_default] = (shell == BlockType::BASH)
|
129
129
|
end
|
130
130
|
|
131
131
|
# Evaluates the filter settings to make a final decision on
|
@@ -138,8 +138,8 @@ module MarkdownExec
|
|
138
138
|
# if it should be excluded.
|
139
139
|
#
|
140
140
|
def self.evaluate_filters(options, filters)
|
141
|
-
if
|
142
|
-
|
141
|
+
if filters[:fcb_chrome] == true
|
142
|
+
!options[:no_chrome]
|
143
143
|
elsif options[:exclude_expect_blocks] && filters[:shell_expect] == true
|
144
144
|
false
|
145
145
|
elsif filters[:hidden_name] == true
|
@@ -159,6 +159,17 @@ module MarkdownExec
|
|
159
159
|
true
|
160
160
|
end
|
161
161
|
end
|
162
|
+
|
163
|
+
# blocks for menu, without missing exit and back chrome
|
164
|
+
# remove hidden blocks
|
165
|
+
#
|
166
|
+
def self.prepared_not_in_menu?(options, fcb)
|
167
|
+
fcb[:shell] == BlockType::BASH &&
|
168
|
+
((options[:block_name_include_match].present? &&
|
169
|
+
fcb[:oname] =~ /#{options[:block_name_include_match]}/) ||
|
170
|
+
(options[:block_name_wrapper_match].present? &&
|
171
|
+
fcb[:oname] =~ /#{options[:block_name_wrapper_match]}/))
|
172
|
+
end
|
162
173
|
end
|
163
174
|
end
|
164
175
|
|
@@ -239,7 +250,7 @@ if $PROGRAM_NAME == __FILE__
|
|
239
250
|
|
240
251
|
def test_bash_only_condition_true
|
241
252
|
@options[:bash_only] = true
|
242
|
-
@fcb[:shell] =
|
253
|
+
@fcb[:shell] = BlockType::BASH
|
243
254
|
assert Filter.fcb_select?(@options, @fcb)
|
244
255
|
end
|
245
256
|
|