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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d1b2a98d8279b5a5705ba3dc3221d46f55387c0d834ec4283e93ac54f5929835
4
- data.tar.gz: 440070d30a4650c0bb8b9a8b472d91d0bcb4357d18f5330194b10d1c5d6a764d
3
+ metadata.gz: e071fd1fad2603543cbad492e8bed6ee2a1e437f914cf834d3bb99da3a87234f
4
+ data.tar.gz: ba95432a7a17319cde5eaa821c554a472f8cdfeca8238c370869a560e22fcae7
5
5
  SHA512:
6
- metadata.gz: 32702e459d5eeac152583bd7dd8c5de3f6049b0fa8b2c389441f45afadc132678dabbb6898336297d09fa5411ae44963cd0b2353a69f9dc319eb9b302d4ec2db
7
- data.tar.gz: a2ea933810ec3e90ed1cc62eccc9a2e8c94ee5dee1ed8c267b8750a97c67fb4a44bbcf8eb471137a65618b991966692d05684b3f69a97e5911dad3a777a15c60
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
- Max: 96
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
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- markdown_exec (2.0.6)
4
+ markdown_exec (2.0.8)
5
5
  clipboard (~> 1.3.6)
6
6
  open3 (~> 0.1.1)
7
7
  optparse (~> 0.1.1)
data/Rakefile CHANGED
@@ -89,6 +89,7 @@ task :minitest do
89
89
  './lib/object_present.rb',
90
90
  './lib/option_value.rb',
91
91
  './lib/regexp.rb',
92
+ './lib/resize_terminal.rb',
92
93
  './lib/saved_assets.rb',
93
94
  './lib/saved_files_matcher.rb'
94
95
  ]
@@ -13,7 +13,7 @@ __filedirs_all()
13
13
  }
14
14
 
15
15
  _mde_echo_version() {
16
- echo "2.0.6"
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-05-31 07:22:55 UTC"
181
+ # echo "Updated: 2024-06-06 00:36:41 UTC"
@@ -0,0 +1,9 @@
1
+ ```opts :(document_options)
2
+ pause_after_script_execution: false
3
+ ```
4
+ ```bash
5
+ tail -f ~/.bash_profile
6
+ ```
7
+ ```bash
8
+ tail -f ~/.profile
9
+ ```
@@ -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
- save_executed_script: true
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 Unnamed block
12
+ echo This block has no name.
12
13
  ```
13
14
 
14
- ::: These blocks use nicknames.
15
- ::: The code blocks are displayed.
16
- ::: The nicknames can be used for requiring blocks.
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 From the required block 2
20
+ echo 'This block has a nickname: [A].'
21
+ echo The full block is displayed in the menu.
20
22
  ```
21
23
 
22
- ::: Execute this block that requires the block above.
23
-
24
+ ### Nicknames in documents
25
+ ::: Execute this block that requires the block above by its nickname.
24
26
  ```bash :[B] +[A]
25
- echo From the parent block 1
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
  ```
@@ -0,0 +1,9 @@
1
+ # Demonstrate pause for user approval before returning to the menu
2
+ Controlled by option `pause_after_script_execution`.
3
+ ```opts :(document_options)
4
+ pause_after_script_execution: true
5
+ ```
6
+
7
+ ```bash
8
+ echo `date`
9
+ ```
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
@@ -50,6 +50,7 @@ class MenuState
50
50
  EXIT = :exit
51
51
  LOAD = :load
52
52
  SAVE = :save
53
+ SHELL = :shell
53
54
  VIEW = :view
54
55
  end
55
56
 
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