markdown_exec 2.0.6 → 2.0.7

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: af8a53f03e48c890798b520b84bd0357ccef4f31d93b97cc7cc8b4b72ca1a035
4
+ data.tar.gz: cd5983d2ff18ee8e2a29da6bea364c03bdaf6a43871d45b16483a8996d129894
5
5
  SHA512:
6
- metadata.gz: 32702e459d5eeac152583bd7dd8c5de3f6049b0fa8b2c389441f45afadc132678dabbb6898336297d09fa5411ae44963cd0b2353a69f9dc319eb9b302d4ec2db
7
- data.tar.gz: a2ea933810ec3e90ed1cc62eccc9a2e8c94ee5dee1ed8c267b8750a97c67fb4a44bbcf8eb471137a65618b991966692d05684b3f69a97e5911dad3a777a15c60
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
- 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,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
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- markdown_exec (2.0.6)
4
+ markdown_exec (2.0.7)
5
5
  clipboard (~> 1.3.6)
6
6
  open3 (~> 0.1.1)
7
7
  optparse (~> 0.1.1)
@@ -13,7 +13,7 @@ __filedirs_all()
13
13
  }
14
14
 
15
15
  _mde_echo_version() {
16
- echo "2.0.6"
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-31 07:22:55 UTC"
181
+ # echo "Updated: 2024-06-05 03:00:42 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