markdown_exec 1.8.4 → 1.8.6

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: c5acb96c20743bda8d745d4dece7997ff6cd5b5474fdeba4b7401474c7500528
4
- data.tar.gz: 8e52cb02c35801816c9472c94112b521b110a758f602fdf0b19c4dd851c23243
3
+ metadata.gz: 44e42ccdbdf5eed7e6ee36add8a5dcdcfe62d6cd3fb6fd531daf960c6ce7c9b7
4
+ data.tar.gz: 753076d46e44f5d17698be53a0421212d8f2c804368f9737591dc92a7d5457d6
5
5
  SHA512:
6
- metadata.gz: bb66529f2a2766cb1f8cbdd8b071c02eb29ef0c55e29507576a3cb9a0fc4920093fb03af95ddd480a8f6a189d3a86c4b504315f2faadba173a345d07fd16de8e
7
- data.tar.gz: 19af41e603d32a7acc84151ac4db6e4ae4b746990289cb3c89bf8e436a5bf1c98b2e73814f94b4ee348f6a9bcb3fbce35d195c4588a10965bea9e88c0f486b53
6
+ metadata.gz: 84d952fcfafed40a5e3949783760aec570448de48293fdae536b5386b95d8080d2c9c41f0149861686d2fd4985a59ebea6794e7953d7b4dc1185340d790e68a2
7
+ data.tar.gz: 9db0c523154e32c3094046084594564c9114fbd2519f6ff5d9a8fcc5feb0d31b76dc3ccd1d6c4e2625507b81b4f70f9b6fdf31e250d132a5fdf2fa54d3cb8c77
data/.pryrc CHANGED
@@ -1,3 +1,4 @@
1
+ binding.pry
1
2
  if defined?(PryByebug)
2
3
  Pry.config.pager = false
3
4
  Pry.commands.alias_command 'c', 'continue'
data/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.8.6] - 2023-12-25
4
+
5
+ ### Added
6
+
7
+ - Default path for find command
8
+
9
+ ### Changed
10
+
11
+ - Refactor command-line processing
12
+
13
+ ## [1.8.5] - 2023-12-22
14
+
15
+ ### Added
16
+
17
+ - "eval" key for link block type to compute lines to append to the inherited state.
18
+ - Options for dumping data associated with the menu or state.
19
+ - Debug and irb gems.
20
+
3
21
  ## [1.8.4] - 2023-12-15
4
22
 
5
23
  ### Added
data/Gemfile CHANGED
@@ -7,7 +7,9 @@ source 'https://rubygems.org'
7
7
 
8
8
  gemspec
9
9
  gem 'clipboard'
10
+ gem 'debug'
10
11
  gem 'erb'
12
+ gem 'irb', '>= 1.8.0'
11
13
  gem 'mocha', require: false
12
14
  gem 'minitest', require: false
13
15
  gem 'pry-nav'
@@ -22,7 +24,4 @@ gem 'rubocop-rake', require: false
22
24
  gem 'rubocop-rspec', require: false
23
25
  gem 'shellwords'
24
26
  gem 'uri'
25
-
26
- gem 'visual_call_graph'
27
-
28
27
  gem 'yaml', '~> 0.2.1'
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- markdown_exec (1.8.4)
4
+ markdown_exec (1.8.6)
5
5
  clipboard (~> 1.3.6)
6
6
  open3 (~> 0.1.1)
7
7
  optparse (~> 0.1.1)
@@ -39,6 +39,9 @@ GEM
39
39
  coderay (1.1.3)
40
40
  concurrent-ruby (1.2.2)
41
41
  crass (1.0.6)
42
+ debug (1.9.0)
43
+ irb (~> 1.10)
44
+ reline (>= 0.3.8)
42
45
  debug_inspector (1.1.0)
43
46
  diff-lcs (1.5.0)
44
47
  erb (4.0.3)
@@ -46,6 +49,10 @@ GEM
46
49
  erubi (1.12.0)
47
50
  i18n (1.14.1)
48
51
  concurrent-ruby (~> 1.0)
52
+ io-console (0.7.1)
53
+ irb (1.10.1)
54
+ rdoc
55
+ reline (>= 0.3.8)
49
56
  json (2.6.3)
50
57
  kwalify (0.7.2)
51
58
  language_server-protocol (3.17.0.3)
@@ -74,6 +81,8 @@ GEM
74
81
  pry-stack_explorer (0.6.1)
75
82
  binding_of_caller (~> 1.0)
76
83
  pry (~> 0.13)
84
+ psych (5.1.1.1)
85
+ stringio
77
86
  racc (1.7.1)
78
87
  rack (2.2.8)
79
88
  rack-test (2.1.0)
@@ -94,11 +103,15 @@ GEM
94
103
  zeitwerk (~> 2.5)
95
104
  rainbow (3.1.1)
96
105
  rake (13.0.6)
106
+ rdoc (6.6.2)
107
+ psych (>= 4.0.0)
97
108
  reek (6.1.4)
98
109
  kwalify (~> 0.7.0)
99
110
  parser (~> 3.2.0)
100
111
  rainbow (>= 2.0, < 4.0)
101
112
  regexp_parser (2.8.1)
113
+ reline (0.4.1)
114
+ io-console (~> 0.5)
102
115
  rexml (3.2.6)
103
116
  rspec (3.12.0)
104
117
  rspec-core (~> 3.12.0)
@@ -139,11 +152,10 @@ GEM
139
152
  rubocop (~> 1.33)
140
153
  rubocop-capybara (~> 2.17)
141
154
  rubocop-factory_bot (~> 2.22)
142
- ruby-graphviz (1.2.5)
143
- rexml
144
155
  ruby-progressbar (1.13.0)
145
156
  ruby2_keywords (0.0.5)
146
157
  shellwords (0.1.0)
158
+ stringio (3.1.0)
147
159
  thor (1.2.2)
148
160
  tty-color (0.6.0)
149
161
  tty-cursor (0.7.1)
@@ -159,8 +171,6 @@ GEM
159
171
  concurrent-ruby (~> 1.0)
160
172
  unicode-display_width (2.5.0)
161
173
  uri (0.12.2)
162
- visual_call_graph (0.4.0)
163
- ruby-graphviz (~> 1.2, >= 1.2.0)
164
174
  wisper (2.0.1)
165
175
  yaml (0.2.1)
166
176
  zeitwerk (2.6.12)
@@ -170,7 +180,9 @@ PLATFORMS
170
180
 
171
181
  DEPENDENCIES
172
182
  clipboard
183
+ debug
173
184
  erb
185
+ irb (>= 1.8.0)
174
186
  markdown_exec!
175
187
  minitest
176
188
  mocha
@@ -186,7 +198,6 @@ DEPENDENCIES
186
198
  rubocop-rspec
187
199
  shellwords
188
200
  uri
189
- visual_call_graph
190
201
  yaml (~> 0.2.1)
191
202
 
192
203
  BUNDLED WITH
data/bin/bmde CHANGED
@@ -8,106 +8,4 @@ Bundler.require(:default)
8
8
 
9
9
  require_relative '../lib/markdown_exec'
10
10
 
11
- if true
12
-
13
- MarkdownExec::MarkParse.new.run
14
- else
15
-
16
- def trace_event_properties(tp)
17
- # TracePoint.new(:call, :return, :c_call, :c_return, :raise) do |tp|
18
- # puts "Event information:"
19
- # puts "Event type: #{tp.event}"
20
- # puts "File: #{tp.path}"
21
- # puts "Line: #{tp.lineno}"
22
- # puts "Defined class: #{tp.defined_class}"
23
- # puts "Method ID: #{tp.method_id}"
24
- # puts "Class method ID: #{tp.defined_class} #{tp.method_id}"
25
- # puts "Binding: #{tp.binding.inspect}"
26
- # puts "Return value: #{tp.return_value.inspect}" if [:return, :c_return].include?(tp.event)
27
- puts "Raised exception: #{tp.raised_exception.inspect}" if tp.event == :raise
28
- # puts "---------------------------------"
29
- # binding.pry
30
- # print format("\n%-20.20s %-20.20s % 5.5d %20s %s", tp.method_id, tp.defined_class, tp.lineno, tp.path.split('/').last, caller[1].split('/').last)
31
-
32
- # print format("\n%-20.20s %-30.30s %s", tp.method_id, tp.defined_class, caller[1].split('/').last.split(':', 3)[0..1].join(':'))
33
- # print __LINE__, '.'
34
- return if %i[method_missing present?].include?(tp.method_id)
35
- return unless %r(/markdown_exec/lib/) =~ caller[1]
36
-
37
- if [:return, :c_return].include?(tp.event)
38
- print format("%1.1s %-20.20s %s\n", tp.event, tp.method_id, tp.return_value)
39
- else
40
- print format("%1.1s %-20.20s %-30.30s %20s\n", tp.event, tp.method_id, tp.defined_class, $~.post_match)
41
- end
42
- # end.enable
43
- end
44
-
45
- def start_trace(events = [:call])
46
- trace = TracePoint.new(*events) do |tp|
47
- trace_event_properties(tp)
48
- end
49
-
50
- trace.enable
51
- yield
52
- trace.disable
53
- end
54
-
55
- start_trace([:call, :return]) { MarkdownExec::MarkParse.new.run }
56
-
57
- end
58
-
59
-
60
-
61
- =begin
62
-
63
- To filter what is traced, you can pass any of the following as events:
64
-
65
- :line
66
- execute an expression or statement on a new line
67
-
68
- :class
69
- start a class or module definition
70
-
71
- :end
72
- finish a class or module definition
73
-
74
- :call
75
- call a Ruby method
76
-
77
- :return
78
- return from a Ruby method
79
-
80
- :c_call
81
- call a C-language routine
82
-
83
- :c_return
84
- return from a C-language routine
85
-
86
- :raise
87
- raise an exception
88
-
89
- :b_call
90
- event hook at block entry
91
-
92
- :b_return
93
- event hook at block ending
94
-
95
- :a_call
96
- event hook at all calls (call, b_call, and c_call)
97
-
98
- :a_return
99
- event hook at all returns (return, b_return, and c_return)
100
-
101
- :thread_begin
102
- event hook at thread beginning
103
-
104
- :thread_end
105
- event hook at thread ending
106
-
107
- :fiber_switch
108
- event hook at fiber switch
109
-
110
- :script_compiled
111
- new Ruby code compiled (with eval, load or require)
112
-
113
- =end
11
+ MarkdownExec::MarkParse.new.run
@@ -13,7 +13,7 @@ __filedirs_all()
13
13
  }
14
14
 
15
15
  _mde_echo_version() {
16
- echo "1.8.4"
16
+ echo "1.8.6"
17
17
  }
18
18
 
19
19
  _mde() {
@@ -36,8 +36,12 @@ _mde() {
36
36
 
37
37
  -d) COMPREPLY="0"; return 0 ;;
38
38
 
39
+ --dump-dump-delegate-object) COMPREPLY="0"; return 0 ;;
40
+
39
41
  --dump-blocks-in-file) COMPREPLY="0"; return 0 ;;
40
42
 
43
+ --dump-dump-inherited-lines) COMPREPLY="0"; return 0 ;;
44
+
41
45
  --dump-menu-blocks) COMPREPLY="0"; return 0 ;;
42
46
 
43
47
  --dump-selected-block) COMPREPLY="0"; return 0 ;;
@@ -50,6 +54,8 @@ _mde() {
50
54
 
51
55
  -?) COMPREPLY="''"; return 0 ;;
52
56
 
57
+ --find-path) COMPREPLY="''"; return 0 ;;
58
+
53
59
  --how) COMPREPLY="''"; return 0 ;;
54
60
 
55
61
  -?) COMPREPLY="''"; return 0 ;;
@@ -88,7 +94,7 @@ _mde() {
88
94
  # present matching option names
89
95
  #
90
96
  if [[ ${cur} == -* ]] ; then
91
- opts=("--block-name" "--config" "--debug" "--dump-blocks-in-file" "--dump-menu-blocks" "--dump-selected-block" "--exit" "--filename" "--find" "--help" "--how" "--list-blocks" "--list-count" "--list-default-env" "--list-default-yaml" "--list-docs" "--list-recent-output" "--list-recent-scripts" "--output-execution-summary" "--output-script" "--output-stdout" "--path" "--pwd" "--run-last-script" "--save-executed-script" "--save-execution-output" "--saved-script-folder" "--saved-stdout-folder" "--select-recent-output" "--select-recent-script" "--tab-completions" "--user-must-approve" "--version" "--display-level")
97
+ opts=("--block-name" "--config" "--debug" "--dump-dump-delegate-object" "--dump-blocks-in-file" "--dump-dump-inherited-lines" "--dump-menu-blocks" "--dump-selected-block" "--exit" "--filename" "--find" "--find-path" "--help" "--how" "--list-blocks" "--list-count" "--list-default-env" "--list-default-yaml" "--list-docs" "--list-recent-output" "--list-recent-scripts" "--output-execution-summary" "--output-script" "--output-stdout" "--path" "--pwd" "--run-last-script" "--save-executed-script" "--save-execution-output" "--saved-script-folder" "--saved-stdout-folder" "--select-recent-output" "--select-recent-script" "--tab-completions" "--user-must-approve" "--version" "--display-level")
92
98
  COMPREPLY=( $(compgen -W "$(printf "'%s' " "${opts[@]}")" -- "${cur}") )
93
99
 
94
100
  return 0
@@ -111,8 +117,12 @@ _mde() {
111
117
 
112
118
  -d) COMPREPLY=".BOOL."; return 0 ;;
113
119
 
120
+ --dump-dump-delegate-object) COMPREPLY=".BOOL."; return 0 ;;
121
+
114
122
  --dump-blocks-in-file) COMPREPLY=".BOOL."; return 0 ;;
115
123
 
124
+ --dump-dump-inherited-lines) COMPREPLY=".BOOL."; return 0 ;;
125
+
116
126
  --dump-menu-blocks) COMPREPLY=".BOOL."; return 0 ;;
117
127
 
118
128
  --dump-selected-block) COMPREPLY=".BOOL."; return 0 ;;
@@ -125,6 +135,8 @@ _mde() {
125
135
 
126
136
  -?) COMPREPLY=".FIND."; return 0 ;;
127
137
 
138
+ --find-path) COMPREPLY=".FIND_PATH."; return 0 ;;
139
+
128
140
  --how) COMPREPLY=".HOW."; return 0 ;;
129
141
 
130
142
  -?) COMPREPLY=".HOW."; return 0 ;;
@@ -166,4 +178,4 @@ _mde() {
166
178
 
167
179
  complete -o filenames -o nospace -F _mde mde
168
180
  # _mde_echo_version
169
- # echo "Updated: 2023-12-16 00:15:53 UTC"
181
+ # echo "Updated: 2023-12-26 00:07:49 UTC"
@@ -0,0 +1,52 @@
1
+ Demonstrate setting a variable interactively for use in generated scripts.
2
+
3
+ ```opts :(document_options)
4
+ dump_inherited_lines: true
5
+ pause_after_script_execution: false
6
+ user_must_approve: false
7
+ ```
8
+
9
+ ::: Set VARIABLE to "A"
10
+
11
+ ```link :set_to_A +(set_to_A)
12
+ block: display_variable
13
+ ```
14
+
15
+ ```bash :(set_to_A)
16
+ VARIABLE=A
17
+ ```
18
+
19
+ ```link :set_to_A_eval +(set_to_A_eval)
20
+ block: display_variable
21
+ eval: true
22
+ ```
23
+
24
+ ```bash :(set_to_A_eval)
25
+ echo VARIABLE=A
26
+ ```
27
+
28
+ ::: Set VARIABLE to "B"
29
+
30
+ ```link :set_to_B +(set_to_B)
31
+ block: display_variable
32
+ ```
33
+
34
+ ```bash :(set_to_B)
35
+ VARIABLE=B
36
+ ```
37
+
38
+ ```link :set_to_B_eval +(set_to_B_eval)
39
+ block: display_variable
40
+ eval: true
41
+ ```
42
+
43
+ ```bash :(set_to_B_eval)
44
+ echo VARIABLE=B
45
+ ```
46
+
47
+ ::: Display value of VARIABLE
48
+
49
+ ```bash :display_variable
50
+ source bin/colorize_env_vars.sh
51
+ colorize_env_vars '' VARIABLE
52
+ ```
data/examples/linked1.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Demo document linking
2
2
 
3
+ ```opts :(document_options)
4
+ dump_inherited_lines: true
5
+ pause_after_script_execution: false
6
+ user_must_approve: false
7
+ ```
8
+
3
9
  ::: * This is document 1 *
4
10
  ::: This document links to a matching document to demonstrate navigation between documents.
5
11
 
@@ -12,7 +18,11 @@ colorize_env_vars 'vars for page3' PAGE3_VAR_VIA_INHERIT page3_var_via_environme
12
18
  ```
13
19
 
14
20
  ```bash :(vars2)
15
- PAGE2_VAR_VIA_INHERIT=for_page2_from_page1_via_inherited_code_file
21
+ PAGE2_VAR_VIA_INHERIT=for_page2_from_page1_via_inherited_code_blocks
22
+ ```
23
+
24
+ ```link :linked2 +(vars2)
25
+ file: examples/linked2.md
16
26
  ```
17
27
 
18
28
  ```link :(linked2) +(vars2)
data/examples/linked2.md CHANGED
@@ -17,7 +17,11 @@ colorize_env_vars 'vars for page3' PAGE3_VAR_VIA_INHERIT page3_var_via_environme
17
17
  ::: 3. executes block "show_vars" to display the imported PAGE3_VAR_VIA_INHERIT.
18
18
 
19
19
  ```bash :(vars3)
20
- PAGE3_VAR_VIA_INHERIT=for_page3_from_page2_via_inherited_code_file
20
+ PAGE3_VAR_VIA_INHERIT=for_page3_from_page2_via_inherited_code_blocks
21
+ ```
22
+
23
+ ```link :linked3 +(vars3)
24
+ file: examples/linked3.md
21
25
  ```
22
26
 
23
27
  ```link :(linked3) +(vars3)
data/examples/opts.md CHANGED
@@ -2,13 +2,15 @@
2
2
 
3
3
  ::: These Opts blocks set the color of a couple of menu options to demonstrate the live update of options.
4
4
 
5
- ```opts :opts1
5
+ ```opts
6
+ # color scheme 1
6
7
  menu_divider_color: yellow
7
- menu_note_match:
8
+ menu_note_match: "^ *(?<line>.+?) *$"
8
9
  menu_task_color: fg_rgb_255_63_255
9
10
  ```
10
11
 
11
- ```opts :opts2
12
+ ```opts
13
+ # color scheme 2
12
14
  menu_divider_color: red
13
15
  menu_note_color: yellow
14
16
  menu_note_match: "^\\+ +(?<line>.+?) *$"
@@ -27,3 +29,21 @@ note 1
27
29
  note 2 ends with /
28
30
  / note 3 starts with /
29
31
  note 4
32
+
33
+ ::: These options toggle the dump of debug information.
34
+
35
+ ```opts
36
+ dump_blocks_in_file: true # Dump BlocksInFile (stage 1)
37
+ dump_delegate_object: true # Dump @delegate_object
38
+ dump_inherited_lines: true # Dump inherited lines
39
+ dump_menu_blocks: true # Dump MenuBlocks (stage 2)
40
+ dump_selected_block: true # Dump selected block
41
+ ```
42
+
43
+ ```opts
44
+ dump_blocks_in_file: false # Dump BlocksInFile (stage 1)
45
+ dump_delegate_object: false # Dump @delegate_object
46
+ dump_inherited_lines: false # Dump inherited lines
47
+ dump_menu_blocks: false # Dump MenuBlocks (stage 2)
48
+ dump_selected_block: false # Dump selected block
49
+ ```
@@ -28,47 +28,6 @@ class AnsiFormatter
28
28
  # "#{line_prefix}#{string_send_color(label, highlight_color_sym)}#{line_postfix}\n" + formatted_deps.join("\n")
29
29
  end
30
30
 
31
- # Formats and highlights a list of data. data are presented with indentation,
32
- # and specific items can be highlighted in a specified color, while others are shown in a plain color.
33
- #
34
- # @param data [Hash] A hash of data, where each key is a dependency name,
35
- # and its value is an array of sub-items.
36
- # @param highlight_color_sym [Symbol] The color method to apply to highlighted items.
37
- # Default is :exception_color_detail.
38
- # @param plain_color_sym [Symbol] The color method for non-highlighted items.
39
- # Default is :menu_chrome_color.
40
- # @param label [String] The label to prefix the list of data with.
41
- # Default is 'data:'.
42
- # @param highlight [Array] An array of items to highlight. Each item in this array will be
43
- # formatted with the specified highlight color.
44
- # @param line_prefix [String] Prefix for each line. Default is ' '.
45
- # @param line_postfix [String] Postfix for each line. Default is ''.
46
- # @param detail_sep [String] Separator for items in the sub-list. Default is ' '.
47
- # @return [String] A formatted string representation of the data with highlighted items.
48
- def format_and_highlight_hash(
49
- data,
50
- highlight_color_sym: :exception_color_detail,
51
- plain_color_sym: :menu_chrome_color,
52
- label: 'Data:',
53
- highlight: [],
54
- line_prefix: ' ',
55
- line_postfix: '',
56
- detail_sep: ' '
57
- )
58
- formatted_deps = data&.map do |dep_name, sub_items|
59
- formatted_sub_items = sub_items.map do |item|
60
- color_sym = highlight.include?(item) ? highlight_color_sym : plain_color_sym
61
- string_send_color(item, color_sym)
62
- end.join(detail_sep)
63
-
64
- "#{line_prefix}- #{string_send_color(dep_name,
65
- highlight.include?(dep_name) ? highlight_color_sym : plain_color_sym)}: #{formatted_sub_items}#{line_postfix}"
66
- end || []
67
-
68
- "#{line_prefix}#{string_send_color(label,
69
- highlight_color_sym)}#{line_postfix}\n" + formatted_deps.join("\n")
70
- end
71
-
72
31
  # Function to scan a string and process its segments based on multiple substrings
73
32
  # @param str [String] The string to scan.
74
33
  # @param substrings [Array<String>] The substrings to match in the string.
@@ -6,15 +6,9 @@
6
6
  # version 2023-10-03
7
7
 
8
8
  require 'fileutils'
9
+ require_relative 'constants'
9
10
  require_relative 'exceptions'
10
11
 
11
- # a struct to hold the data for a single line
12
- NestedLine = Struct.new(:text, :depth) do
13
- def to_s
14
- text
15
- end
16
- end
17
-
18
12
  ##
19
13
  # The CachedNestedFileReader class provides functionality to read file lines with the ability
20
14
  # to process '#import filename' directives. When such a directive is encountered in a file,
data/lib/constants.rb CHANGED
@@ -3,12 +3,20 @@
3
3
 
4
4
  # encoding=utf-8
5
5
 
6
+ require_relative 'block_types'
7
+
6
8
  class ExecutionStreams
7
9
  StdErr = :stderr
8
10
  StdIn = :stdin
9
11
  StdOut = :stdout
10
12
  end
11
13
 
14
+ IndexedLine = Struct.new(:index, :line) do
15
+ def to_s
16
+ line
17
+ end
18
+ end
19
+
12
20
  class LoadFile
13
21
  Load = true
14
22
  Reuse = false
@@ -34,6 +42,13 @@ class MenuState
34
42
  EXIT = :exit
35
43
  end
36
44
 
45
+ # a struct to hold the data for a single line
46
+ NestedLine = Struct.new(:text, :depth) do
47
+ def to_s
48
+ text
49
+ end
50
+ end
51
+
37
52
  # selected block and subsequent menu state
38
53
  #
39
54
  SelectedBlockMenuState = Struct.new(:block, :state)
@@ -44,3 +59,5 @@ SHELL_COLOR_OPTIONS = {
44
59
  BlockType::OPTS => :menu_opts_color,
45
60
  BlockType::VARS => :menu_vars_color
46
61
  }.freeze
62
+
63
+ ### Struct.new(:state, :block)
@@ -4,6 +4,31 @@
4
4
  # encoding=utf-8
5
5
 
6
6
  require 'find'
7
+ require_relative 'constants'
8
+
9
+ def format_and_highlight_hash(
10
+ data,
11
+ highlight_color_sym: :exception_color_detail,
12
+ plain_color_sym: :menu_chrome_color,
13
+ label: 'Data:',
14
+ highlight: [],
15
+ line_prefix: ' ',
16
+ line_postfix: '',
17
+ key_has_value: ': '
18
+ )
19
+ formatted_deps = data&.map do |key, value|
20
+ color_sym = highlight.include?(key) ? highlight_color_sym : plain_color_sym
21
+ dkey = string_send_color(key, color_sym)
22
+
23
+ "#{line_prefix}#{dkey}#{key_has_value}" \
24
+ "#{string_send_color(value,
25
+ highlight.include?(value) ? highlight_color_sym : plain_color_sym)}: " \
26
+ "#{formatted_sub_items}#{line_postfix}"
27
+ end
28
+
29
+ "#{line_prefix}#{string_send_color(label,
30
+ highlight_color_sym)}#{line_postfix}\n" + formatted_deps.join("\n")
31
+ end
7
32
 
8
33
  # Formats and highlights a list of dependencies. Dependencies are presented with indentation,
9
34
  # and specific items can be highlighted in a specified color, while others are shown in a plain color.
@@ -47,10 +72,22 @@ def format_and_highlight_dependencies(
47
72
  end
48
73
  # warn menu_blocks.to_yaml.sub(/^(?:---\n)?/, "MenuBlocks:\n")
49
74
 
50
- IndexedLine = Struct.new(:index, :line) do
51
- def to_s
52
- line
53
- end
75
+ def format_and_highlight_lines(
76
+ lines,
77
+ highlight_color_sym: :exception_color_detail,
78
+ plain_color_sym: :menu_chrome_color,
79
+ label: 'Dependencies:',
80
+ highlight: [],
81
+ line_prefix: ' ',
82
+ line_postfix: ''
83
+ )
84
+ formatted_deps = lines&.map do |item|
85
+ "#{line_prefix}- #{string_send_color(dep_name,
86
+ highlight.include?(dep_name) ? highlight_color_sym : plain_color_sym)}: #{item}#{line_postfix}"
87
+ end || []
88
+
89
+ "#{line_prefix}#{string_send_color(label,
90
+ highlight_color_sym)}#{line_postfix}\n" + formatted_deps.join("\n")
54
91
  end
55
92
 
56
93
  # Class DirectorySearcher
@@ -77,7 +114,6 @@ class DirectorySearcher
77
114
  match_dirs = []
78
115
  @paths.each do |path|
79
116
  Find.find(path) do |p|
80
- # p 'search_in_directory_names', p
81
117
  # Find.prune unless @include_subdirectories || path == p
82
118
  match_dirs << p if File.directory?(p) && p.match?(@pattern)
83
119
  end
data/lib/filter.rb CHANGED
@@ -61,15 +61,8 @@ module MarkdownExec
61
61
  # @param name [String] The name of the fenced code block.
62
62
  #
63
63
  def self.apply_name_filters(options, filters, name)
64
- if name.present? && options[:block_name]
65
- if name =~ /#{options[:block_name]}/
66
- filters[:name_select] = true
67
- filters[:name_exclude] = false
68
- else
69
- filters[:name_exclude] = true
70
- filters[:name_select] = false
71
- end
72
- end
64
+ filters[:name_select] = true
65
+ filters[:name_exclude] = false
73
66
 
74
67
  if name.present? && filters[:name_select].nil? && options[:select_by_name_regex].present?
75
68
  filters[:name_select] =
@@ -239,12 +232,6 @@ if $PROGRAM_NAME == __FILE__
239
232
  assert Filter.fcb_select?(@options, @fcb)
240
233
  end
241
234
 
242
- def test_name_exclude_condition
243
- @options[:block_name] = 'test'
244
- @fcb[:oname] = 'sample'
245
- refute Filter.fcb_select?(@options, @fcb)
246
- end
247
-
248
235
  def test_shell_exclude_condition
249
236
  @options[:exclude_by_shell_regex] = 'exclude_this'
250
237
  @fcb[:shell] = 'exclude_this_shell'
@@ -269,12 +256,6 @@ if $PROGRAM_NAME == __FILE__
269
256
  assert Filter.fcb_select?(@options, @fcb)
270
257
  end
271
258
 
272
- def test_bash_only_condition_false
273
- @options[:bash_only] = true
274
- @fcb[:shell] = 'zsh'
275
- refute Filter.fcb_select?(@options, @fcb)
276
- end
277
-
278
259
  def test_default_case
279
260
  assert Filter.fcb_select?(@options, @fcb)
280
261
  end