markdown_exec 1.3.9 → 1.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.
- checksums.yaml +4 -4
- data/.pryrc +11 -0
- data/.rubocop.yml +15 -1
- data/Gemfile.lock +1 -1
- data/bin/bmde +11 -0
- data/bin/tab_completion.sh +2 -2
- data/examples/linked1.md +13 -13
- data/examples/linked2.md +15 -14
- data/examples/linked3.md +12 -0
- data/lib/block_types.rb +2 -0
- data/lib/colorize.rb +52 -55
- data/lib/filter.rb +3 -3
- data/lib/markdown_exec/version.rb +1 -1
- data/lib/markdown_exec.rb +873 -614
- data/lib/mdoc.rb +53 -51
- data/lib/menu.src.yml +19 -1
- data/lib/menu.yml +20 -2
- data/lib/method_sorter.rb +76 -0
- data/lib/sort_yaml_gpt4.rb +32 -0
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 25d73d643251be40fcf14edd59a890d3d4fca847217b02c9ee6ad6fdbb06b72e
|
4
|
+
data.tar.gz: 8bde8d7e84230d50f34425fa3d549c9bbf7b78bb89219290a454547ba6a6b001
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 04fec544c21aac267c89868755a76cbc0f0565cc676ed3ed647ab9459c7308cf01a26572cb059a0aadc26c403067b3ead4fcd2ce5d05051320ee2aa2b8dee911
|
7
|
+
data.tar.gz: 3f6ffedbddbf9a15c3fa7c05b24f61367dbff5c717328a333b1cded39ebba13e18f333383f4d35786b565b8985f2433e683daadf01a89963a606471415a4a503
|
data/.pryrc
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
if defined?(PryByebug)
|
2
|
+
Pry.config.pager = false
|
3
|
+
Pry.commands.alias_command 'c', 'continue'
|
4
|
+
Pry.commands.alias_command 'f', 'finish'
|
5
|
+
Pry.commands.alias_command 's', 'step'
|
6
|
+
Pry.commands.alias_command 'n', 'next'
|
7
|
+
|
8
|
+
Pry::Commands.command /^$/, 'repeat last command' do
|
9
|
+
_pry_.run_command Pry.history.to_a.last
|
10
|
+
end
|
11
|
+
end
|
data/.rubocop.yml
CHANGED
@@ -15,7 +15,6 @@ Layout/LineContinuationLeadingSpace:
|
|
15
15
|
|
16
16
|
Layout/LineLength:
|
17
17
|
Max: 96
|
18
|
-
# Max: 120
|
19
18
|
|
20
19
|
Lint/Debugger:
|
21
20
|
Enabled: false
|
@@ -65,6 +64,9 @@ Style/DoubleNegation:
|
|
65
64
|
Style/EmptyElse:
|
66
65
|
Enabled: false
|
67
66
|
|
67
|
+
Style/FormatStringToken:
|
68
|
+
Enabled: false
|
69
|
+
|
68
70
|
Style/GlobalVars:
|
69
71
|
Enabled: false
|
70
72
|
|
@@ -74,6 +76,18 @@ Style/MixinUsage:
|
|
74
76
|
Style/MultilineBlockChain:
|
75
77
|
Enabled: false
|
76
78
|
|
79
|
+
Style/PerlBackrefs: # Prefer ::Regexp.last_match.post_match over $'.
|
80
|
+
Enabled: false
|
81
|
+
|
82
|
+
Style/RegexpLiteral:
|
83
|
+
Enabled: false
|
84
|
+
|
85
|
+
Style/Semicolon: # Do not use semicolons to terminate expressions.
|
86
|
+
Enabled: false
|
87
|
+
|
88
|
+
Style/SingleLineMethods: # Avoid single-line method definitions.
|
89
|
+
Enabled: false
|
90
|
+
|
77
91
|
Style/SlicingWithRange:
|
78
92
|
Enabled: false
|
79
93
|
|
data/Gemfile.lock
CHANGED
data/bin/bmde
ADDED
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.4"
|
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-10-
|
141
|
+
# echo "Updated: 2023-10-31 15:43:43 UTC"
|
data/examples/linked1.md
CHANGED
@@ -3,26 +3,26 @@
|
|
3
3
|
::: * This is document 1 *
|
4
4
|
::: This document links to a matching document to demonstrate navigation between documents.
|
5
5
|
|
6
|
-
::: This Bash block displays the value of variables "
|
6
|
+
::: This Bash block displays the value of variables "page1_var_via_environment" and "page2_var_via_environment"
|
7
7
|
|
8
|
-
```bash :
|
8
|
+
```bash :show_vars
|
9
9
|
source bin/colorize_env_vars.sh
|
10
|
-
colorize_env_vars '
|
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
|
11
12
|
```
|
12
13
|
|
13
|
-
::: This Link block
|
14
|
+
::: This Link block
|
15
|
+
::: 1. requires a block that sets environment variable PAGE2_VAR_VIA_INHERIT,
|
16
|
+
::: 2. navigates to document 2, and
|
17
|
+
::: 3. executes block "show_vars" to display the imported PAGE2_VAR_VIA_INHERIT.
|
14
18
|
|
15
|
-
```
|
16
|
-
|
17
|
-
vars:
|
18
|
-
linked2var: from_linked1
|
19
|
+
```bash :(vars2)
|
20
|
+
PAGE2_VAR_VIA_INHERIT=for_page2_from_page1_via_inherited_code_file
|
19
21
|
```
|
20
22
|
|
21
|
-
|
22
|
-
|
23
|
-
```link :linked2_show_vars
|
23
|
+
```link :linked2_import_vars +(vars2)
|
24
24
|
file: examples/linked2.md
|
25
|
-
block:
|
25
|
+
block: show_vars
|
26
26
|
vars:
|
27
|
-
|
27
|
+
page2_var_via_environment: for_page2_from_page1_via_current_environment
|
28
28
|
```
|
data/examples/linked2.md
CHANGED
@@ -3,26 +3,27 @@
|
|
3
3
|
::: * This is document 2 *
|
4
4
|
::: This document links to a matching document to demonstrate navigation between documents.
|
5
5
|
|
6
|
-
::: This Bash block displays the value of variables "
|
6
|
+
::: This Bash block displays the value of variables "page1_var_via_environment" and "page2_var_via_environment"
|
7
7
|
|
8
|
-
```bash :
|
8
|
+
```bash :show_vars
|
9
9
|
source bin/colorize_env_vars.sh
|
10
|
-
colorize_env_vars '
|
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
|
11
12
|
```
|
12
13
|
|
13
|
-
::: This Link block sets variable "linked1var" and navigates to document 1.
|
14
14
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
```
|
15
|
+
::: This Link block requires a block that
|
16
|
+
::: 1. sets environment variable PAGE3_VAR_VIA_INHERIT,
|
17
|
+
::: 2. navigates to document 3, and
|
18
|
+
::: 3. executes block "show_vars" to display the imported PAGE3_VAR_VIA_INHERIT.
|
20
19
|
|
21
|
-
|
20
|
+
```bash :(vars3)
|
21
|
+
PAGE3_VAR_VIA_INHERIT=for_page3_from_page2_via_inherited_code_file
|
22
|
+
```
|
22
23
|
|
23
|
-
```link :
|
24
|
-
file: examples/
|
25
|
-
block:
|
24
|
+
```link :linked3_import_vars +(vars3)
|
25
|
+
file: examples/linked3.md
|
26
|
+
block: show_vars
|
26
27
|
vars:
|
27
|
-
|
28
|
+
page3_var_via_environment: for_page3_from_page2_via_current_environment
|
28
29
|
```
|
data/examples/linked3.md
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
# Demo document linking
|
2
|
+
|
3
|
+
::: * This is document 3 *
|
4
|
+
::: This document is linked from another document to demonstrate code transfer.
|
5
|
+
|
6
|
+
::: This Bash block displays the value of variables "PAGE3_VAR_VIA_INHERIT" and "page3_var_via_environment"
|
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
|
+
```
|
data/lib/block_types.rb
CHANGED
data/lib/colorize.rb
CHANGED
@@ -2,81 +2,78 @@
|
|
2
2
|
|
3
3
|
# encoding=utf-8
|
4
4
|
|
5
|
+
# Extends Ruby's native String class to include ANSI coloring functionality.
|
6
|
+
# Adds methods to apply RGB colors, named colors, and other formatting to strings.
|
5
7
|
class String
|
6
|
-
|
7
|
-
|
8
|
+
# Handles dynamic method calls to create RGB colors.
|
9
|
+
#
|
10
|
+
# @param method_name [Symbol] The name of the method being called.
|
11
|
+
# @param args [Array] The arguments passed to the method.
|
12
|
+
# @param block [Proc] An optional block.
|
13
|
+
# @return [String] The formatted string.
|
8
14
|
def method_missing(method_name, *args, &block)
|
9
|
-
|
15
|
+
case method_name.to_s
|
16
|
+
when /^fg_rgb_/
|
10
17
|
fg_rgb_color($'.gsub('_', ';'))
|
18
|
+
when /^fg_rgbh_/
|
19
|
+
hex_to_rgb($')
|
11
20
|
else
|
12
|
-
|
21
|
+
super
|
13
22
|
end
|
14
23
|
end
|
15
24
|
|
16
|
-
# control sequence
|
25
|
+
# Generates an ANSI control sequence for the string.
|
17
26
|
#
|
27
|
+
# @return [String] The string wrapped in an ANSI control sequence.
|
18
28
|
def ansi_control_sequence
|
19
29
|
"\033[#{self}\033[0m"
|
20
30
|
end
|
21
31
|
|
22
|
-
#
|
23
|
-
# ex: 1;2;3
|
32
|
+
# Applies a 24-bit RGB foreground color to the string.
|
24
33
|
#
|
34
|
+
# @param rgb [String] The RGB color, expressed as a string like "1;2;3".
|
35
|
+
# @return [String] The string with the applied RGB foreground color.
|
25
36
|
def fg_rgb_color(rgb)
|
26
37
|
"38;2;#{rgb}m#{self}".ansi_control_sequence
|
27
38
|
end
|
28
39
|
|
29
|
-
|
30
|
-
self
|
31
|
-
end
|
32
|
-
|
33
|
-
# named colors
|
40
|
+
# Converts hex color codes to RGB and applies them to the string.
|
34
41
|
#
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
42
|
+
# @param hex_str [String] The RGB color, expressed as a hex string like "FF00FF".
|
43
|
+
# @return [String] The string with the applied RGB foreground color.
|
44
|
+
def hex_to_rgb(hex_str)
|
45
|
+
fg_rgb_color(
|
46
|
+
hex_str.split('_').map { |hex| hex.to_i(16).to_s }.join(';')
|
47
|
+
)
|
41
48
|
end
|
42
49
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
"32m#{self}".ansi_control_sequence
|
49
|
-
end
|
50
|
-
|
51
|
-
def bgreen
|
52
|
-
"1;32m#{self}".ansi_control_sequence
|
53
|
-
end
|
54
|
-
|
55
|
-
def yellow
|
56
|
-
"33m#{self}".ansi_control_sequence
|
57
|
-
end
|
58
|
-
|
59
|
-
def byellow
|
60
|
-
"1;33m#{self}".ansi_control_sequence
|
61
|
-
end
|
62
|
-
|
63
|
-
def blue
|
64
|
-
"34m#{self}".ansi_control_sequence
|
65
|
-
end
|
66
|
-
|
67
|
-
def magenta
|
68
|
-
"35m#{self}".ansi_control_sequence
|
69
|
-
end
|
70
|
-
|
71
|
-
def cyan
|
72
|
-
"36m#{self}".ansi_control_sequence
|
73
|
-
end
|
74
|
-
|
75
|
-
def white
|
76
|
-
"37m#{self}".ansi_control_sequence
|
50
|
+
# Provides a plain, unmodified version of the string.
|
51
|
+
#
|
52
|
+
# @return [String] The original string.
|
53
|
+
def plain
|
54
|
+
self
|
77
55
|
end
|
78
56
|
|
79
|
-
|
80
|
-
|
81
|
-
|
57
|
+
# A collection of methods for applying named colors.
|
58
|
+
#
|
59
|
+
# For example, #black applies a black foreground color to the string.
|
60
|
+
# These are provided for convenience and easy readability.
|
61
|
+
|
62
|
+
def black; "30m#{self}".ansi_control_sequence; end
|
63
|
+
def bred; "1;31m#{self}".ansi_control_sequence; end
|
64
|
+
def bgreen; "1;32m#{self}".ansi_control_sequence; end
|
65
|
+
def byellow; "1;33m#{self}".ansi_control_sequence; end
|
66
|
+
def magenta; "35m#{self}".ansi_control_sequence; end
|
67
|
+
def cyan; "36m#{self}".ansi_control_sequence; end
|
68
|
+
def white; "37m#{self}".ansi_control_sequence; end
|
69
|
+
def bwhite; "1;37m#{self}".ansi_control_sequence; end
|
70
|
+
|
71
|
+
# More named colors using RGB hex values
|
72
|
+
def blue; fg_rgbh_00_00_FF; end
|
73
|
+
def green; fg_rgbh_00_FF_00; end
|
74
|
+
def indigo; fg_rgbh_4B_00_82; end
|
75
|
+
def orange; fg_rgbh_FF_7F_00; end
|
76
|
+
def red; fg_rgbh_FF_00_00; end
|
77
|
+
def violet; fg_rgbh_94_00_D3; end
|
78
|
+
def yellow; fg_rgbh_FF_FF_00; end
|
82
79
|
end
|
data/lib/filter.rb
CHANGED
@@ -38,7 +38,7 @@ module MarkdownExec
|
|
38
38
|
name = fcb.oname
|
39
39
|
shell = fcb.fetch(:shell, '')
|
40
40
|
|
41
|
-
apply_name_filters(options, filters, name)
|
41
|
+
apply_name_filters(options, filters, name)
|
42
42
|
apply_shell_filters(options, filters, shell)
|
43
43
|
apply_other_filters(options, filters, fcb)
|
44
44
|
|
@@ -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 == BLOCK_TYPE_BASH)
|
129
129
|
end
|
130
130
|
|
131
131
|
# Evaluates the filter settings to make a final decision on
|
@@ -239,7 +239,7 @@ if $PROGRAM_NAME == __FILE__
|
|
239
239
|
|
240
240
|
def test_bash_only_condition_true
|
241
241
|
@options[:bash_only] = true
|
242
|
-
@fcb[:shell] =
|
242
|
+
@fcb[:shell] = BLOCK_TYPE_BASH
|
243
243
|
assert Filter.fcb_select?(@options, @fcb)
|
244
244
|
end
|
245
245
|
|