markdown_exec 2.7.2 → 2.7.4

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.
data/lib/mdoc.rb CHANGED
@@ -220,101 +220,31 @@ module MarkdownExec
220
220
  end
221
221
 
222
222
  collapser = Collapser.new(
223
- options: opts, state: opts[:compressed_ids] || {}
223
+ options: opts,
224
+ compress_ids: opts[:compressed_ids] || {},
225
+ expand_ids: opts[:expanded_ids] || {}
224
226
  )
225
- selrows = collapser.reject(selrows, initialize: opts[:compressed_ids].nil?) do |fcb, hide, collapsed_level|
227
+ selrows = collapser.reject(
228
+ selrows,
229
+ initialize: opts[:compressed_ids].nil?
230
+ ) do |fcb, _hide, _collapsed_level|
226
231
  # update fcb per state
227
232
  if fcb.collapsible
228
233
  fcb.s1decorated = fcb.s1decorated + ' ' + (fcb.collapse ? opts[:menu_collapsible_symbol_collapsed] : opts[:menu_collapsible_symbol_expanded])
229
234
  end
230
235
  end
231
- opts[:compressed_ids] = collapser.state
236
+ opts[:compressed_ids] = collapser.compress_ids
237
+ opts[:expanded_ids] = collapser.expand_ids
232
238
 
233
239
  # remove
234
240
  # . empty chrome between code; edges are same as blanks
235
241
  #
236
- [
237
- select_elements_with_neighbor_conditions(selrows) do |prev_element, current, next_element|
238
- !(current[:chrome] && !current.oname.present?) ||
239
- !(!prev_element.nil? &&
240
- prev_element.shell.present? &&
241
- !next_element.nil? &&
242
- next_element.shell.present?)
243
- end,
244
- opts[:compressed_ids]
245
- ]
246
- end
247
-
248
- # Filters out blocks that are nested within a hierarchy of "hidden" blocks.
249
- #
250
- # The method iterates over selected rows and uses a callback block to determine if a given block
251
- # should trigger hiding for subsequent blocks in the hierarchy. Once hiding is triggered, all
252
- # blocks with a level greater than the triggering block's level are excluded until the next
253
- # visible collapsible block.
254
- #
255
- # @param selrows [Array] The array of selected rows to filter based on the callback's results.
256
- # @param callback [Lambda/Proc] Alternate to yield block.
257
- # @param collapsible_types [Array] Types to select, nil for all.
258
- # @yield [block] A callback to evaluate each block; should return true to initiate hiding.
259
- # @return [Array] Filtered list of rows, excluding those hidden by hierarchical hiding rules.
260
- #
261
- # Example:
262
- # proc_condition = Proc.new { |fcb| fcb.type == BlockType::HEADING && fcb.level == 1 }
263
- # reject_collapsed_blocks(selrows, callback: proc_condition)
264
- #
265
- # lambda_condition = ->(fcb) { fcb.type == BlockType::HEADING && fcb.level == 1 }
266
- # reject_collapsed_blocks(selrows, callback: lambda_condition)
267
- #
268
- # Block: Exits the enclosing method (test_with_block) if return is used.
269
- # Flexible with arguments
270
- # Proc: Exits the enclosing method (test_with_proc) when return is encountered, similar to a block.
271
- # Lambda: Only exits the lambda itself, allowing reject_collapsed_blocks to continue execution.
272
- # Stricter argument checking.
273
- #
274
- # **`lambda` provides more control** and avoids the early exit behavior caused by `return` in blocks or `Proc` objects, making it a safer choice when you want `reject_collapsed_blocks` to complete its execution regardless of the callback’s behavior.
275
- def reject_collapsed_blocks(
276
- selrows,
277
- callback: nil,
278
- reject_callback: nil,
279
- collapsible_types: nil,
280
- &block
281
- )
282
- block ||= callback # Use callback if no block is provided
283
- hiding = false # State to indicate if hiding is active
284
- hidden_level = nil # Level at which hiding was triggered
285
-
286
- selrows.reject do |fcb| # Reject rows that should be hidden based on the hierarchy
287
- if hiding
288
- # Currently in hiding mode; evaluate if the current block should remain hidden
289
- if collapsible_types.nil? || collapsible_types.include?(fcb.type)
290
- if hidden_level.nil?
291
- # No specific hidden level yet, allow the item to show
292
- false
293
- elsif fcb.level > hidden_level
294
- reject_callback.call(fcb, ) if reject_callback
295
- # The current block is at a deeper level and thus remains hidden
296
- true
297
- else
298
- # At the same or higher level than hidden_level, check if the callback initiates hiding again
299
- hiding = block.call(fcb)
300
- hidden_level = fcb.level if hiding # Update hidden level if hiding continues
301
- false # Do not hide the initiating block itself
302
- end
303
- else
304
- reject_callback.call(fcb) if reject_callback
305
- # Non-collapsible block types (e.g., text or note) continue hiding by default
306
- true
307
- end
308
-
309
- elsif block.call(fcb)
310
- # If callback triggers hiding, initialize hiding state and hidden_level
311
- hiding = fcb.type # Start hiding subsequent blocks
312
- hidden_level = fcb.level # Define the hierarchical level for hiding
313
- false # Do not hide the initiating block itself
314
-
315
- else
316
- false # Default: do not hide if no hiding state
317
- end
242
+ select_elements_with_neighbor_conditions(selrows) do |prev_element, current, next_element|
243
+ !(current[:chrome] && !current.oname.present?) ||
244
+ !(!prev_element.nil? &&
245
+ prev_element.shell.present? &&
246
+ !next_element.nil? &&
247
+ next_element.shell.present?)
318
248
  end
319
249
  end
320
250
 
@@ -605,7 +535,7 @@ if $PROGRAM_NAME == __FILE__
605
535
 
606
536
  def test_fcbs_per_options
607
537
  opts = { hide_blocks_by_name: true, block_name_hidden_match: 'block1' }
608
- result, _ = @doc.fcbs_per_options(opts)
538
+ result = @doc.fcbs_per_options(opts)
609
539
  assert_equal [@table[1], @table[2]], result
610
540
  end if false ### broken test
611
541
 
data/lib/menu.src.yml CHANGED
@@ -904,11 +904,10 @@
904
904
  :procname: val_as_str
905
905
 
906
906
  ## lines that start with "/" are comments (hidden), not notes (visible)
907
- # - :default: "^(?<indent>[ \t]*)(?<line>(?!/)(?<text>.*?)(?<trailing>[ \t]*))?$"
908
907
  - :opt_name: menu_note_match
909
908
  :env_var: MDE_MENU_NOTE_MATCH
910
909
  :description: Pattern for notes in block selection menu
911
- :default: "^(?<line>(?![ \t]*/)(?<text>.*?)(?<trailing>[ \t]*))$"
910
+ :default: "^(?<indent>[ \t]*)(?<line>(?!/)(?<text>.*?)(?<trailing>[ \t]*))?$"
912
911
  :procname: val_as_str
913
912
 
914
913
  - :opt_name: menu_option_back_name
@@ -1588,6 +1587,12 @@
1588
1587
  :description: Color for table border
1589
1588
  :default: fg_bg_rgbh_00_00_df_14_18_1c
1590
1589
 
1590
+ - :opt_name: table_cell_text_truncate
1591
+ :env_var: MDE_TABLE_CELL_TEXT_TRUNCATE
1592
+ :arg_name: BOOL
1593
+ :default: true
1594
+ :procname: val_as_bool
1595
+
1591
1596
  - :opt_name: table_center
1592
1597
  :env_var: MDE_TABLE_CENTER
1593
1598
  :arg_name: BOOL
data/lib/menu.yml CHANGED
@@ -766,7 +766,7 @@
766
766
  - :opt_name: menu_note_match
767
767
  :env_var: MDE_MENU_NOTE_MATCH
768
768
  :description: Pattern for notes in block selection menu
769
- :default: "^(?<line>(?![ \t]*/)(?<text>.*?)(?<trailing>[ \t]*))$"
769
+ :default: "^(?<indent>[ \t]*)(?<line>(?!/)(?<text>.*?)(?<trailing>[ \t]*))?$"
770
770
  :procname: val_as_str
771
771
  - :opt_name: menu_option_back_name
772
772
  :env_var: MDE_MENU_OPTION_BACK_NAME
@@ -1355,6 +1355,11 @@
1355
1355
  :env_var: MDE_TABLE_BORDER_COLOR
1356
1356
  :description: Color for table border
1357
1357
  :default: fg_bg_rgbh_00_00_df_14_18_1c
1358
+ - :opt_name: table_cell_text_truncate
1359
+ :env_var: MDE_TABLE_CELL_TEXT_TRUNCATE
1360
+ :arg_name: BOOL
1361
+ :default: true
1362
+ :procname: val_as_bool
1358
1363
  - :opt_name: table_center
1359
1364
  :env_var: MDE_TABLE_CENTER
1360
1365
  :arg_name: BOOL
data/lib/ww.rb CHANGED
@@ -15,7 +15,7 @@ if $debug && ENV['WW_MINIMUM'].nil?
15
15
  end
16
16
 
17
17
  def ww(*objs, **kwargs)
18
- return unless $debug
18
+ return objs.size == 1 ? objs.first : objs unless $debug
19
19
 
20
20
  ww0(*objs, **kwargs.merge(locations: caller_locations))
21
21
  end
@@ -24,7 +24,7 @@ def ww0(*objs,
24
24
  category: nil,
25
25
  full_backtrace: false,
26
26
  level: :debug,
27
- locations: caller_locations[1..-1],
27
+ locations: caller_locations,
28
28
  log_file: nil,
29
29
  output: $stderr,
30
30
  single_line: false,
@@ -70,18 +70,20 @@ def ww0(*objs,
70
70
  output.flush
71
71
 
72
72
  # Optionally log to a file
73
- return unless log_file
73
+ return objs.size == 1 ? objs.first : objs unless log_file
74
74
 
75
75
  File.open(log_file, 'a') do |file|
76
76
  file.puts(formatted_message)
77
77
  end
78
+
79
+ objs.size == 1 ? objs.first : objs
78
80
  end
79
81
 
80
82
  class Array
81
83
  unless defined?(deref)
82
84
  def deref
83
85
  map(&:deref).select do |line|
84
- !%r{^/vendor/}.match(line)
86
+ !%r{^/(vendor|\.bundle)/}.match(line)
85
87
  end
86
88
  end
87
89
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: markdown_exec
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.7.2
4
+ version: 2.7.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fareed Stevenson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-01-10 00:00:00.000000000 Z
11
+ date: 2025-02-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: clipboard
@@ -107,6 +107,8 @@ files:
107
107
  - assets/select_a_block.png
108
108
  - assets/select_a_file.png
109
109
  - bats/bats.bats
110
+ - bats/block-type-opts.bats
111
+ - bats/block-type-vars.bats
110
112
  - bats/block-types.bats
111
113
  - bats/border.bats
112
114
  - bats/cli.bats
@@ -115,6 +117,7 @@ files:
115
117
  - bats/fail.bats
116
118
  - bats/history.bats
117
119
  - bats/import.bats
120
+ - bats/line-wrapping.bats
118
121
  - bats/markup.bats
119
122
  - bats/mde.bats
120
123
  - bats/options-collapse.bats
@@ -143,6 +146,7 @@ files:
143
146
  - docs/dev/document-shell.md
144
147
  - docs/dev/import-missing.md
145
148
  - docs/dev/import.md
149
+ - docs/dev/line-wrapping.md
146
150
  - docs/dev/linked-file.md
147
151
  - docs/dev/load1.sh
148
152
  - docs/dev/load_code.md
@@ -201,7 +205,7 @@ files:
201
205
  - examples/variable-expansion-save-block.md
202
206
  - examples/variable-expansion.md
203
207
  - examples/vars-blocks.md
204
- - examples/wrap.md
208
+ - examples/wrapped-blocks.md
205
209
  - lib/ansi_formatter.rb
206
210
  - lib/ansi_string.rb
207
211
  - lib/argument_processor.rb
File without changes