markdown_exec 2.0.6 → 2.0.7
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 +10 -2
- data/CHANGELOG.md +27 -0
- data/Gemfile.lock +1 -1
- data/bin/tab_completion.sh +2 -2
- data/examples/interrupt.md +9 -0
- data/examples/line-wrapping.md +17 -0
- data/examples/nickname.md +46 -9
- data/examples/pause-after-execution.md +9 -0
- data/lib/colorize.rb +25 -0
- data/lib/constants.rb +1 -0
- data/lib/fcb.rb +15 -0
- data/lib/hash_delegator.rb +365 -100
- data/lib/markdown_exec/version.rb +1 -1
- data/lib/markdown_exec.rb +1 -0
- data/lib/mdoc.rb +9 -14
- data/lib/menu.src.yml +38 -13
- data/lib/menu.yml +26 -14
- data/lib/saved_assets.rb +4 -3
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: af8a53f03e48c890798b520b84bd0357ccef4f31d93b97cc7cc8b4b72ca1a035
|
4
|
+
data.tar.gz: cd5983d2ff18ee8e2a29da6bea364c03bdaf6a43871d45b16483a8996d129894
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 47e4e75e5a4e473ab9e9726cb7774aec95eb4a26d1d48035e3f6a69df0162c6b004fa625f5ae9f3c973bb25f732c9e938c0008dd07abb759f3211258d943fcc8
|
7
|
+
data.tar.gz: 306fc1218c64d57b1ca82191060298f87f9ae996e43f278cd72144fa3b839e3e4e4b8d3168f34c2fca4bd1ba9fa8ca1ab0a42659980d115b2d3293edc5e75238
|
data/.rubocop.yml
CHANGED
@@ -13,8 +13,10 @@ Layout/LeadingCommentSpace:
|
|
13
13
|
Layout/LineContinuationLeadingSpace:
|
14
14
|
Enabled: false
|
15
15
|
|
16
|
-
Layout/LineLength:
|
17
|
-
|
16
|
+
Layout/LineLength: # 2024-01-21 temp disable
|
17
|
+
Enabled: false
|
18
|
+
# Max: 96
|
19
|
+
# Max: 120
|
18
20
|
|
19
21
|
Lint/Debugger:
|
20
22
|
Enabled: false
|
@@ -46,6 +48,9 @@ Metrics/CyclomaticComplexity:
|
|
46
48
|
Metrics/MethodLength:
|
47
49
|
Enabled: false
|
48
50
|
|
51
|
+
Metrics/ParameterLists:
|
52
|
+
Enabled: false
|
53
|
+
|
49
54
|
Metrics/PerceivedComplexity:
|
50
55
|
Enabled: false
|
51
56
|
|
@@ -67,6 +72,9 @@ Style/ClassVars:
|
|
67
72
|
Style/CommentedKeyword:
|
68
73
|
Enabled: false
|
69
74
|
|
75
|
+
Style/Documentation: # 2024-01-21 temp disable
|
76
|
+
Enabled: false
|
77
|
+
|
70
78
|
Style/DoubleNegation:
|
71
79
|
Enabled: false
|
72
80
|
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,32 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## [2.0.7] - 2024-06-04
|
4
|
+
|
5
|
+
### Added
|
6
|
+
|
7
|
+
- Color names that set foreground and background color.
|
8
|
+
Similar to the existing foreground-only color names.
|
9
|
+
The background colors follow the foreground color values in the name.
|
10
|
+
Two names, to accept values as decimal and hex.
|
11
|
+
- Example document for line wrapping.
|
12
|
+
- Menu entry to execute shell commands.
|
13
|
+
- Option to control menu entry for shell commands.
|
14
|
+
- Recognition of nicknames in command line processing.
|
15
|
+
- Trap user interrupting executing scripts.
|
16
|
+
|
17
|
+
### Changed
|
18
|
+
|
19
|
+
- Do not decorate indentations.
|
20
|
+
- Line-wrap and center headings.
|
21
|
+
Headings are now centered, the text is case-folded and the color
|
22
|
+
(foreground and background) is according to the level.
|
23
|
+
Centering is based on the console width detected.
|
24
|
+
- Line-wrap normal document text and format headings.
|
25
|
+
- Parse lines into indentation, text, and trailing whitespace.
|
26
|
+
- Update nicknames example to exercise hidden blocks from the command line.
|
27
|
+
- The optional prompt to exit after execution is now more frequent.
|
28
|
+
- Set characters used in saved file names
|
29
|
+
|
3
30
|
## [2.0.6] - 2024-05-28
|
4
31
|
|
5
32
|
### Added
|
data/Gemfile.lock
CHANGED
data/bin/tab_completion.sh
CHANGED
@@ -13,7 +13,7 @@ __filedirs_all()
|
|
13
13
|
}
|
14
14
|
|
15
15
|
_mde_echo_version() {
|
16
|
-
echo "2.0.
|
16
|
+
echo "2.0.7"
|
17
17
|
}
|
18
18
|
|
19
19
|
_mde() {
|
@@ -178,4 +178,4 @@ _mde() {
|
|
178
178
|
|
179
179
|
complete -o filenames -o nospace -F _mde mde
|
180
180
|
# _mde_echo_version
|
181
|
-
# echo "Updated: 2024-05
|
181
|
+
# echo "Updated: 2024-06-05 03:00:42 UTC"
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# Demo wrapping long lines
|
2
|
+
|
3
|
+
MDE detects the screen's dimensions: height (lines) and width (characters)
|
4
|
+
|
5
|
+
If `select_page_height` is positive, the height of the MDE menu is fixed. Otherwise, the height is derived from the screen's height.
|
6
|
+
|
7
|
+
Normal document text is displayed as disabled menu lines. The width of these lines is limited according to the screen's width.
|
8
|
+
|
9
|
+
::: Test Indented Lines
|
10
|
+
|
11
|
+
Indented with two spaces, this line should wrap in an aesthetically pleasing way. Indented with two spaces, this line should wrap in an aesthetically pleasing way.
|
12
|
+
|
13
|
+
Indented with a tab, this line should wrap in an aesthetically pleasing way. Indented with a tab, this line should wrap in an aesthetically pleasing way.
|
14
|
+
|
15
|
+
# Heading 1 - UPPER lower Mixed - Alpha Beta Gamma Delta Epsilon Zeta Eta Theta Iota Kappa Lambda Mu Nu Xi Omicron Pi Rho Sigma Tau Upsilon Phi Chi Psi Omega
|
16
|
+
## Heading 2 - UPPER lower Mixed - Alpha Beta Gamma Delta Epsilon Zeta Eta Theta Iota Kappa Lambda Mu Nu Xi Omicron Pi Rho Sigma Tau Upsilon Phi Chi Psi Omega
|
17
|
+
### Heading 3 - UPPER lower Mixed - Alpha Beta Gamma Delta Epsilon Zeta Eta Theta Iota Kappa Lambda Mu Nu Xi Omicron Pi Rho Sigma Tau Upsilon Phi Chi Psi Omega
|
data/examples/nickname.md
CHANGED
@@ -1,26 +1,63 @@
|
|
1
1
|
# Demo block nicknames
|
2
2
|
|
3
3
|
```opts :(document_options)
|
4
|
-
|
4
|
+
pause_after_script_execution: true
|
5
5
|
```
|
6
6
|
|
7
|
+
## Blocks with no name
|
7
8
|
::: This block has no name.
|
8
9
|
::: The code block is displayed.
|
9
10
|
|
10
11
|
```bash
|
11
|
-
echo
|
12
|
+
echo This block has no name.
|
12
13
|
```
|
13
14
|
|
14
|
-
|
15
|
-
::: The code
|
16
|
-
::: The
|
15
|
+
## Blocks with nicknames
|
16
|
+
::: The code block is displayed.
|
17
|
+
::: The nickname can be used to require the block.
|
17
18
|
|
18
19
|
```bash :[A]
|
19
|
-
echo
|
20
|
+
echo 'This block has a nickname: [A].'
|
21
|
+
echo The full block is displayed in the menu.
|
20
22
|
```
|
21
23
|
|
22
|
-
|
23
|
-
|
24
|
+
### Nicknames in documents
|
25
|
+
::: Execute this block that requires the block above by its nickname.
|
24
26
|
```bash :[B] +[A]
|
25
|
-
echo
|
27
|
+
echo 'This block has a nickname: [B].'
|
28
|
+
echo 'This block requires block [A].'
|
29
|
+
```
|
30
|
+
|
31
|
+
### Nicknames from the command line
|
32
|
+
Block `[A]` is called from the command line.
|
33
|
+
```bash
|
34
|
+
mde examples/nickname.md '[A]'
|
35
|
+
```
|
36
|
+
|
37
|
+
## Blocks with hidden names
|
38
|
+
### There is a hidden block here.
|
39
|
+
::: This block has a hidden name: (C).
|
40
|
+
::: This block does not appear in the menu.
|
41
|
+
::: This block requires the block above by its nickname.
|
42
|
+
```bash :(C) +[A]
|
43
|
+
echo 'This block has a hidden name: (C).'
|
44
|
+
echo This block is hidden from the menu.
|
45
|
+
echo 'This block requires block [A].'
|
46
|
+
```
|
47
|
+
|
48
|
+
### Hidden names from the command line
|
49
|
+
Block `(C)` is called from the command line.
|
50
|
+
```bash
|
51
|
+
mde examples/nickname.md '(C)'
|
52
|
+
```
|
53
|
+
|
54
|
+
### Block without a name
|
55
|
+
::: This block does not have a name.
|
56
|
+
::: It requires hidden block (D).
|
57
|
+
```bash +(D)
|
58
|
+
echo "Block without a name"
|
59
|
+
```
|
60
|
+
::: This block has a hidden name: (D).
|
61
|
+
```bash :(D)
|
62
|
+
echo "Block D"
|
26
63
|
```
|
data/lib/colorize.rb
CHANGED
@@ -13,6 +13,11 @@ class String
|
|
13
13
|
# @return [String] The formatted string.
|
14
14
|
def method_missing(method_name, *args, &block)
|
15
15
|
case method_name.to_s
|
16
|
+
when /^fg_bg_rgb_/
|
17
|
+
bytes = $'.split('_')
|
18
|
+
fg_bg_rgb_color(bytes[0..2].join(';'), bytes[3..5].join(';'))
|
19
|
+
when /^fg_bg_rgbh_/
|
20
|
+
hex_to_fg_bg_rgb($')
|
16
21
|
when /^fg_rgb_/
|
17
22
|
fg_rgb_color($'.gsub('_', ';'))
|
18
23
|
when /^fg_rgbh_/
|
@@ -29,6 +34,14 @@ class String
|
|
29
34
|
"\033[#{self}\033[0m"
|
30
35
|
end
|
31
36
|
|
37
|
+
# Applies a 24-bit RGB foreground color to the string.
|
38
|
+
#
|
39
|
+
# @param rgb [String] The RGB color, expressed as a string like "1;2;3".
|
40
|
+
# @return [String] The string with the applied RGB foreground color.
|
41
|
+
def fg_bg_rgb_color(fg_rgb, bg_rgb)
|
42
|
+
"38;2;#{fg_rgb}m\033[48;2;#{bg_rgb}m#{self}".ansi_control_sequence
|
43
|
+
end
|
44
|
+
|
32
45
|
# Applies a 24-bit RGB foreground color to the string.
|
33
46
|
#
|
34
47
|
# @param rgb [String] The RGB color, expressed as a string like "1;2;3".
|
@@ -37,6 +50,18 @@ class String
|
|
37
50
|
"38;2;#{rgb}m#{self}".ansi_control_sequence
|
38
51
|
end
|
39
52
|
|
53
|
+
# Converts hex color codes to RGB and applies them to the string.
|
54
|
+
#
|
55
|
+
# @param hex_str [String] The RGB color, expressed as a hex string like "FF00FF".
|
56
|
+
# @return [String] The string with the applied RGB foreground color.
|
57
|
+
def hex_to_fg_bg_rgb(hex_str)
|
58
|
+
values = hex_str.split('_').map { |hex| hex.to_i(16).to_s }
|
59
|
+
fg_bg_rgb_color(
|
60
|
+
values[0..2].join(';'),
|
61
|
+
values[3..5].join(';')
|
62
|
+
)
|
63
|
+
end
|
64
|
+
|
40
65
|
# Converts hex color codes to RGB and applies them to the string.
|
41
66
|
#
|
42
67
|
# @param hex_str [String] The RGB color, expressed as a hex string like "FF00FF".
|
data/lib/constants.rb
CHANGED
data/lib/fcb.rb
CHANGED
@@ -3,6 +3,21 @@
|
|
3
3
|
|
4
4
|
# encoding=utf-8
|
5
5
|
|
6
|
+
class Hash
|
7
|
+
# block name in commands and documents
|
8
|
+
def pub_name
|
9
|
+
fetch(:nickname, nil) || fetch(:oname, nil)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
# require 'ostruct'
|
13
|
+
|
14
|
+
# class BlkS < OpenStruct
|
15
|
+
# # Method to fetch the value associated with the attribute :nickname or :oname
|
16
|
+
# def pub_name
|
17
|
+
# self.nickname || self.oname
|
18
|
+
# end
|
19
|
+
# end
|
20
|
+
|
6
21
|
module MarkdownExec
|
7
22
|
class Error < StandardError; end
|
8
23
|
|