markdown_exec 2.0.6 → 2.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +10 -2
- data/CHANGELOG.md +40 -0
- data/Gemfile.lock +1 -1
- data/Rakefile +1 -0
- 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 +390 -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 +45 -13
- data/lib/menu.yml +32 -14
- data/lib/resize_terminal.rb +215 -0
- data/lib/saved_assets.rb +4 -3
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e071fd1fad2603543cbad492e8bed6ee2a1e437f914cf834d3bb99da3a87234f
|
4
|
+
data.tar.gz: ba95432a7a17319cde5eaa821c554a472f8cdfeca8238c370869a560e22fcae7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0c3586f87853edbb872a7ad8ba766fe1a76d4184ebb6b02d11eaf6227ed152ae75b83c5b291981f0cf9a2208133cf122e8a3fcd4376bd694607f9bfa5d8bc577
|
7
|
+
data.tar.gz: 73a013bc437ba2d5aa87bd9c8a0c8039d6ad8cb6b95767a3b16ab340a90aec26ae1f2c0d0fa355280caa89cb45de7a474b51473683573a147d6cebc91b6522a1
|
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,45 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## [2.0.8] - 2024-06-05
|
4
|
+
|
5
|
+
### Added
|
6
|
+
|
7
|
+
- Option to automatically resize the menu.
|
8
|
+
Detect the maximum supported screen dimensions.
|
9
|
+
Resize the terminal to the maximum dimensions.
|
10
|
+
Every time the menu is displayed, format it to the terminal dimensions.
|
11
|
+
|
12
|
+
### Changed
|
13
|
+
|
14
|
+
- Remove "$" from saved file names to simplify handling.
|
15
|
+
|
16
|
+
## [2.0.7] - 2024-06-04
|
17
|
+
|
18
|
+
### Added
|
19
|
+
|
20
|
+
- Color names that set foreground and background color.
|
21
|
+
Similar to the existing foreground-only color names.
|
22
|
+
The background colors follow the foreground color values in the name.
|
23
|
+
Two names, to accept values as decimal and hex.
|
24
|
+
- Example document for line wrapping.
|
25
|
+
- Menu entry to execute shell commands.
|
26
|
+
- Option to control menu entry for shell commands.
|
27
|
+
- Recognition of nicknames in command line processing.
|
28
|
+
- Trap user interrupting executing scripts.
|
29
|
+
|
30
|
+
### Changed
|
31
|
+
|
32
|
+
- Do not decorate indentations.
|
33
|
+
- Line-wrap and center headings.
|
34
|
+
Headings are now centered, the text is case-folded and the color
|
35
|
+
(foreground and background) is according to the level.
|
36
|
+
Centering is based on the console width detected.
|
37
|
+
- Line-wrap normal document text and format headings.
|
38
|
+
- Parse lines into indentation, text, and trailing whitespace.
|
39
|
+
- Update nicknames example to exercise hidden blocks from the command line.
|
40
|
+
- The optional prompt to exit after execution is now more frequent.
|
41
|
+
- Set characters used in saved file names
|
42
|
+
|
3
43
|
## [2.0.6] - 2024-05-28
|
4
44
|
|
5
45
|
### Added
|
data/Gemfile.lock
CHANGED
data/Rakefile
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.8"
|
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-
|
181
|
+
# echo "Updated: 2024-06-06 00:36:41 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
|
|