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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bf1cce75f6ae919ebb237862e74ade141e6300426e514331b4410cf7cfa0b27e
4
- data.tar.gz: 2ea6f8f6fa47f01b324b6663c6c1dcd0f69a0c2a164d7591f5c714d9618b90a4
3
+ metadata.gz: 5b2dff995a0986c3e248185703f187d49b9cabaabdfae999af261b524ebac1d9
4
+ data.tar.gz: 4303e59dc01d2c600872b506cb365d1de0452a93bacb13c47358525e80d39ad8
5
5
  SHA512:
6
- metadata.gz: 87b6c3f35b0fd85b06dc1d94afc6c145fd27989def6972dcaf66e85a8c899e3550376efa9b0e70efe2327e403a46615b6c51a5210653bf5bdd0e1c6946d477f7
7
- data.tar.gz: 78fd6cb33feabb7a94c0df274528cf2ffd0d4b60e1bf37328304a125b71edc44c6fd884c003af7088b0953923cee3e3a2b3f39b139b1559bf0b2b4337792ecc9
6
+ metadata.gz: ab35fe5e0b66c683133f65e9937cdf3336231e3522aed575bedceae8a7044fcf155b11c7e28b324720858dfa53f1443e35b8c5b188796300aa499bb6071930f1
7
+ data.tar.gz: e8146b88c20bf43c4f43c6d19dd016a249f3227f42450196bf1a40b3356a1f37ae53c645122d25b285ae58c806df3724dd5e32d2e1ac120b45e8f4f86fe7ebbf
data/CHANGELOG.md CHANGED
@@ -1,5 +1,50 @@
1
1
  # Changelog
2
2
 
3
+ ## [2.7.4] - 2025-02-02
4
+
5
+ ### Added
6
+
7
+ - Option to control initial truncation of table cell text to fit screen width.
8
+ - Truncate text to fit table cell fit to screen width. Click on first row of any table to toggle.
9
+
10
+ ### Changed
11
+
12
+ - Fix the display of collapsible sections.
13
+ - Fix the display of shell expansion and command substitution output.
14
+ - Hide gem sources in caller.deref.
15
+
16
+ ## [2.7.3] - 2025-01-29
17
+
18
+ ### Added
19
+
20
+ - Automatic loading of multiple Opts and Vars blocks when opening a document.
21
+
22
+ ### Changed
23
+
24
+ - Fix text displayed when text is wrapped to the next line.
25
+ - Handle and report failure of single tests.
26
+
27
+ ## [2.7.2] - 2025-01-03
28
+
29
+ ### Added
30
+
31
+ - Block name comparison in FCB class.
32
+ - Option for automatic shell block per document.
33
+
34
+ ### Changed
35
+
36
+ - Disable command substitution in comments.
37
+ - Fix the source reported by debug function ww0.
38
+ - Inverse the entire line to highlight the active menu line.
39
+ - Return single file if no globs in load block.
40
+ - Update the calculation and use of IDs for blocks used to retrieve the block selected from the menu.
41
+
42
+ ## [2.7.1] - 2024-12-10
43
+
44
+ ### Changed
45
+
46
+ - Register console dimensions prior to arguments.
47
+
3
48
  ## [2.7.0] - 2024-12-09
4
49
 
5
50
  ### Added
@@ -399,7 +444,7 @@ Rename options to match use.
399
444
  These blocks can be hidden blocks and required in a script.
400
445
 
401
446
  - Add a "wrap" fenced code block type to facilitate script generation.
402
- See document `examples/wrap.md`.
447
+ See document `examples/wrapped-blocks.md`.
403
448
  These blocks are hidden and can be required by one or more blocks.
404
449
 
405
450
  ### Changed
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- markdown_exec (2.7.2)
4
+ markdown_exec (2.7.4)
5
5
  clipboard (~> 1.3.6)
6
6
  open3 (~> 0.1.1)
7
7
  optparse (~> 0.1.1)
data/Rakefile CHANGED
@@ -74,14 +74,38 @@ task :clean do
74
74
  system 'rm *.gem'
75
75
  end
76
76
 
77
+ def execute_with_error_handling(iterator)
78
+ all_error_level = 0
79
+ all_failed_files = []
80
+
81
+ iterator.each do |item|
82
+ command = yield(item)
83
+ next unless command # Skip if command is nil
84
+
85
+ result = system(command)
86
+ error_level = $?.exitstatus
87
+
88
+ if error_level != 0
89
+ puts "Error: Command '#{command}' failed with exit status #{error_level}."
90
+ all_error_level = error_level
91
+ all_failed_files << command
92
+ end
93
+ end
94
+
95
+ if all_error_level != 0
96
+ puts "Error: #{all_failed_files.join(', ')} failed."
97
+ exit all_error_level
98
+ end
99
+ end
100
+
77
101
  desc 'bats'
78
102
  task :bats do
79
- FileList['bats/**/*.bats'].each do |file|
80
- next if %w[bats/bats.bats bats/fail.bats].include?(file)
103
+ execute_with_error_handling(FileList['bats/**/*.bats']) do |file|
104
+ next nil if %w[bats/bats.bats bats/fail.bats].include?(file)
81
105
 
82
106
  # temporary clear WW to disable debugging
83
107
  # WW pollutes output expected by BATS tests
84
- system "unset WW; bats #{file}"
108
+ "unset WW; bats #{file}"
85
109
  end
86
110
  end
87
111
 
@@ -118,14 +142,8 @@ task :minitest do
118
142
  './lib/dev/process_template.rb --test'
119
143
  ]
120
144
 
121
- commands.each do |command|
122
- result = system("bundle exec ruby #{command}")
123
- error_level = $?.exitstatus
124
-
125
- if error_level != 0
126
- puts "Error: Command '#{command}' failed with exit status #{error_level}."
127
- exit error_level
128
- end
145
+ execute_with_error_handling(commands) do |command|
146
+ "bundle exec ruby #{command}"
129
147
  end
130
148
  end
131
149
  task mini: %i[minitest]
@@ -0,0 +1,23 @@
1
+ #!/usr/bin/env bats
2
+
3
+ load 'test_helper'
4
+
5
+ # Type: Opts
6
+
7
+ @test 'Opts block - before' {
8
+ skip 'Fails because command executes after the block is processed'
9
+ spec_mde_xansi_dname_doc_blocks_expect docs/dev/block-type-opts.md \
10
+ 'BEFORE Species_menu_note_format: "AFTER %{line}" '
11
+ }
12
+
13
+ @test 'Opts block - after' {
14
+ spec_mde_xansi_dname_doc_blocks_expect docs/dev/block-type-opts.md \
15
+ '[decorate-note]' \
16
+ 'AFTER Species_menu_note_format: "AFTER %{line}"'
17
+ }
18
+
19
+ @test 'Opts block - show that menu has changed' {
20
+ skip 'Unable to show that menu has changed'
21
+ spec_mde_args_expect docs/dev/block-type-opts.md '[decorate-note]' \
22
+ 'AFTER Species'
23
+ }
@@ -0,0 +1,26 @@
1
+ #!/usr/bin/env bats
2
+
3
+ load 'test_helper'
4
+
5
+ # Type: Vars
6
+
7
+ # includes output from automatic vars blocks
8
+ @test 'Vars block - auto load' {
9
+ BATS_OUTPUT_FILTER=A
10
+ spec_mde_args_expect docs/dev/block-type-vars.md show \
11
+ 'Species = Not specified Genus = Not specified Species: Not specified VAULT:'
12
+ }
13
+
14
+ # includes output from assignment and from shell block
15
+ @test 'Vars block - set variable' {
16
+ BATS_OUTPUT_FILTER=A
17
+ spec_mde_args_expect docs/dev/block-type-vars.md '[set_vault_1]' show \
18
+ 'Species = Not specified Genus = Not specified VAULT = 1 Species: Not specified VAULT: 1'
19
+ }
20
+
21
+ # handles invalid YAML in block
22
+ @test 'Vars block - invalid YAML' {
23
+ BATS_OUTPUT_FILTER=A
24
+ spec_mde_args_expect docs/dev/block-type-vars.md '[invalid_yaml]' show \
25
+ 'Species = Not specified Genus = Not specified Species: Not specified VAULT:'
26
+ }
@@ -47,26 +47,6 @@ load 'test_helper'
47
47
  run_mde_specs_md_args_expect_xansi '[VARIABLE1]' '(echo-VARIABLE1)' ' VARIABLE1: 1 VARIABLE1: 1'
48
48
  }
49
49
 
50
- # Type: Opts
51
-
52
- @test 'Opts block - before' {
53
- skip 'Fails because command executes after the block is processed'
54
- spec_mde_xansi_dname_doc_blocks_expect docs/dev/block-type-opts.md \
55
- 'BEFORE Species_menu_note_format: "AFTER %{line}" '
56
- }
57
-
58
- @test 'Opts block - after' {
59
- spec_mde_xansi_dname_doc_blocks_expect docs/dev/block-type-opts.md \
60
- '[decorate-note]' \
61
- 'AFTER Species_menu_note_format: "AFTER %{line}"'
62
- }
63
-
64
- @test 'Opts block - show that menu has changed' {
65
- skip 'Unable to show that menu has changed'
66
- spec_mde_args_expect docs/dev/block-type-opts.md '[decorate-note]' \
67
- 'AFTER Species'
68
- }
69
-
70
50
  # Type: Port
71
51
 
72
52
  # includes output from assignment and from shell block
@@ -81,19 +61,3 @@ load 'test_helper'
81
61
  spec_mde_args_expect docs/dev/block-type-port.md VAULT-is-export show \
82
62
  ' VAULT: This variable has not been set.'
83
63
  }
84
-
85
- # Type: Vars
86
-
87
- # includes output from automatic vars block
88
- @test 'Vars block - auto load' {
89
- BATS_OUTPUT_FILTER=A
90
- spec_mde_args_expect docs/dev/block-type-vars.md show \
91
- 'Species = Not specified Species: Not specified VAULT:'
92
- }
93
-
94
- # includes output from assignment and from shell block
95
- @test 'Vars block - set variable' {
96
- BATS_OUTPUT_FILTER=A
97
- spec_mde_args_expect docs/dev/block-type-vars.md '[set_vault_1]' show \
98
- 'Species = Not specified VAULT = 1 Species: Not specified VAULT: 1'
99
- }
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bats
2
+
3
+ load 'test_helper'
4
+
5
+ @test 'Text and Headings' {
6
+ spec_mde_xansi_dname_doc_blocks_expect docs/dev/line-wrapping.md \
7
+ " DEMO WRAPPING LONG LINES__MDE detects the screen's dimensions:_height (lines) and width (characters)__Normal document text is displayed as_disabled menu lines. The width of these_lines is limited according to the screen's_width.__Test Indented Lines__ Indented with two spaces, this line_ should wrap in an aesthetically pleasing_ way.__ Indented with a tab, this line should_ wrap in an aesthetically pleasing way.__ SPECIES GENUS FAMILY ORDER CLASS PHYLUM_ KINGDOM DOMAIN_species genus family order class phylum_kingdom domain"
8
+ }
@@ -4,23 +4,23 @@ load 'test_helper'
4
4
 
5
5
  @test 'Options - Collapsible - Document options' {
6
6
  spec_mde_xansi_oname_doc_blocks_expect docs/dev/options-collapse.md \
7
- 'H1.1_L1.1_H2.1_H1.2_H2.2_H1.3_H2.3_L2.3_h3.3_L3.3_D4.3_L4.3'
7
+ 'H1.1_L1.1_H2.1_H1.2_H1.3_L1.3_H2.3_L2.3_h3.3_L3.3_D4.3_L4.3'
8
8
  }
9
9
 
10
10
  @test 'Options - Collapsible Heading - Expand' {
11
11
  spec_mde_xansi_oname_doc_blocks_expect docs/dev/options-collapse.md \
12
12
  H2.1 \
13
- 'H1.1_L1.1_H2.1_L2.1_h3.1_L3.1_D4.1_L4.1_H1.2_L1.2_H2.2_H1.3_H2.3_L2.3_h3.3_L3.3_D4.3_L4.3'
13
+ 'H1.1_L1.1_H2.1_L2.1_h3.1_L3.1_D4.1_L4.1_H1.2_H1.3_L1.3_H2.3_L2.3_h3.3_L3.3_D4.3_L4.3'
14
14
  }
15
15
 
16
16
  @test 'Options - Collapsible Divider' {
17
17
  spec_mde_xansi_oname_doc_blocks_expect docs/dev/options-collapse.md \
18
18
  D4.3 \
19
- 'H1.1_L1.1_H2.1_H1.2_H2.2_H1.3_H2.3_L2.3_h3.3_L3.3_D4.3'
19
+ 'H1.1_L1.1_H2.1_H1.2_H1.3_L1.3_H2.3_L2.3_h3.3_L3.3_D4.3'
20
20
  }
21
21
 
22
22
  @test 'Options - Reveal' {
23
23
  spec_mde_xansi_oname_doc_blocks_expect docs/dev/options-collapse.md \
24
- H2.2 h3.2 D4.2 \
25
- 'H1.1_L1.1_H2.1_H1.2_H2.2_L2.2_h3.2_L3.2_D4.2_L4.2_H1.3_L1.3_H2.3_L2.3_h3.3_L3.3_D4.3_L4.3'
24
+ H1.2 H2.2 h3.2 D4.2 \
25
+ 'H1.1_L1.1_H2.1_H1.2_L1.2_H2.2_L2.2_h3.2_L3.2_D4.2_L4.2_H1.3_L1.3_H2.3_L2.3_h3.3_L3.3_D4.3_L4.3'
26
26
  }
@@ -13,7 +13,7 @@ __filedirs_all()
13
13
  }
14
14
 
15
15
  _mde_echo_version() {
16
- echo "2.7.2"
16
+ echo "2.7.4"
17
17
  }
18
18
 
19
19
  _mde() {
@@ -6,6 +6,9 @@ menu_note_format: "AFTER %{line}"
6
6
  ```opts :(document_opts)
7
7
  menu_final_divider:
8
8
  menu_for_saved_lines: false
9
+ ```
10
+ / Demonstrate multiple (document_opts) in a single file
11
+ ```opts :(document_opts)
9
12
  menu_initial_divider:
10
13
  menu_note_format: "BEFORE %{line}"
11
- ```
14
+ ```
@@ -1,6 +1,15 @@
1
+ ```vars :(document_vars)
2
+ Species: Not specified
3
+ ```
4
+ ```vars :(document_vars)
5
+ Genus: Not specified
6
+ ```
1
7
  ```vars :[set_vault_1]
2
8
  VAULT: 1
3
9
  ```
10
+ ```vars :[invalid_yaml]
11
+ this is not yaml
12
+ ```
4
13
  ```bash :show
5
14
  echo "Species: $Species"
6
15
  echo "VAULT: $VAULT"
@@ -8,8 +17,6 @@ echo "VAULT: $VAULT"
8
17
  | Variable| Value
9
18
  | -| -
10
19
  | Species| ${Species}
20
+ | Genus| ${Genus}
11
21
  | VAULT| ${VAULT}
12
- @import bats-document-configuration.md
13
- ```vars :(document_vars)
14
- Species: Not specified
15
- ```
22
+ @import bats-document-configuration.md
@@ -0,0 +1,24 @@
1
+ # Demo wrapping long lines
2
+
3
+ MDE detects the screen's dimensions: height (lines) and width (characters)
4
+
5
+ Normal document text is displayed as disabled menu lines. The width of these lines is limited according to the screen's width.
6
+
7
+ ::: Test Indented Lines
8
+
9
+ Indented with two spaces, this line should wrap in an aesthetically pleasing way.
10
+
11
+ Indented with a tab, this line should wrap in an aesthetically pleasing way.
12
+
13
+ # species genus family order class phylum kingdom domain
14
+ ## species genus family order class phylum kingdom domain
15
+ @import bats-document-configuration.md
16
+ ```opts :(document_opts)
17
+ divider4_center: false
18
+ heading1_center: true
19
+ heading2_center: false
20
+ screen_width: 48
21
+
22
+ menu_note_match: "^(?<indent>[ \t]*)(?<line>(?!/)(?<text>.*?)(?<trailing>[ \t]*))?$"
23
+
24
+ ```
@@ -33,7 +33,7 @@ divider4_collapse: false
33
33
  divider4_collapsible: true
34
34
  heading1_center: false
35
35
  heading1_collapse: false
36
- heading1_collapsible: false
36
+ heading1_collapsible: true
37
37
  heading2_center: false
38
38
  heading2_collapse: true
39
39
  heading2_collapsible: true
@@ -1,59 +1,87 @@
1
- # Demonstrate link blocks set variables
2
- @import example-document-opts.md
3
- ```opts :(document_opts)
4
- execute_in_own_window: false
5
- menu_with_inherited_lines: true
6
- output_execution_report: false
7
- output_execution_summary: false
8
- pause_after_script_execution: true
1
+ # Demonstrate Setting Variables in the Inherited Lines
2
+
3
+ ```link :select-a-folder +(select-a-folder)
4
+ eval: true
5
+ ```
6
+ ```bash :(select-a-folder)
7
+ echo "PT=$(osascript -e 'do shell script "echo " & quoted form of POSIX path of (choose folder with prompt "Please select a folder:")' 2>/dev/null)"
9
8
  ```
10
9
 
11
- ## Demonstrate a link block that sets a variable
12
- ::: Select below to trigger. If it prints "VARIABLE1: 1", the Link block was processed.
10
+ This table displays the value of variables in the context of the current inherited lines. At first, the variable is empty unless it exists in the current shell environment.
13
11
 
14
12
  | Variable| Value
15
13
  | -| -
16
- | VARIABLE1| ${VARIABLE1}
14
+ | SPECIES| ${SPECIES}
15
+
16
+ ## Current Inherited Lines
17
+
18
+ ```view
19
+ View the current inherited lines.
20
+ ```
21
+
22
+ The inherited lines can also be displayed automatically within the menu by enabling this option:
23
+
24
+ ```opts
25
+ menu_with_inherited_lines: true
26
+ ```
27
+
28
+ ## Setting Variables in the Inherited Lines
29
+
30
+ You can set environment variables in the inherited lines by adding shell expressions. For example, a line such as `SPECIES=Unknown` in the inherited lines defines a variable that can be used in the rest of the executed script.
31
+
32
+ Below are several ways to add such expressions to the inherited lines:
33
+
34
+ ### Vars Block
35
+
36
+ This block (YAML) adds a variable and its value to the inherited lines:
37
+
38
+ ```vars
39
+ SPECIES: Tapanuli Orangutan
40
+ ```
41
+
42
+ ### Link Block
43
+
44
+ This block (YAML) also adds a variable and its value to the inherited lines:
17
45
 
18
- The block sets VARIABLE1.
19
- For each environment variable in `vars`, append an inherited line that assigns the variable the specified value.
20
46
  ```link
21
47
  vars:
22
- VARIABLE1: 1
48
+ SPECIES: Psychedelic Frogfish
23
49
  ```
24
50
 
25
- ## Demonstrate a link block that requires a shell block that sets a variable
26
- This block "[bash_set_to_3]" is required below. It sets the variable "ALPHA".
27
- ```bash :[bash_set_to_3]
28
- ALPHA=3
29
- ```
30
- ::: Select below to trigger. If it prints "ALPHA: 3", the Link block was processed.
31
- These blocks require the *code* of the named shell block.
32
- ```link +[bash_set_to_3]
33
- block: "(display_variable_ALPHA)"
34
- ```
35
- ```link +[bash_set_to_3]
36
- next_block: "(display_variable_ALPHA)"
37
- ```
51
+ ### Link+Bash Blocks
38
52
 
39
- This block "[bash_set_to_4]" is required below. It prints a command that sets the variable "ALPHA".
40
- ```bash :[bash_set_to_4]
41
- echo "ALPHA=4"
42
- ```
43
- ::: Select below to trigger. If it prints "ALPHA: 4", the Link block was processed.
44
- These blocks require the *output* of the execution of the code in the named shell block.
45
- ```link +[bash_set_to_4]
46
- eval: true
47
- block: "(display_variable_ALPHA)"
53
+ ::: Adding Code to the Inherited Lines
54
+
55
+ This Link block (YAML) appends the Bash code defined in the referenced block to the inherited lines:
56
+
57
+ ```link :add-bash-code +[bash_species]
48
58
  ```
49
- ```link +[bash_set_to_4]
59
+ ```bash :[bash_species] @disable
60
+ SPECIES='Ruby Seadragon'
61
+ ```
62
+
63
+ If necessary to extract environment variable values displayed in the menu, inherited lines are executed every time the menu displayed. Therefore, do add code that has unwanted side effects when executed multiple times.
64
+
65
+ ::: Adding Evaluated Code Output to the Inherited Lines
66
+
67
+ This Link block (YAML) appends the output of the Bash code to the inherited lines. The Bash code is executed first to generate the output:
68
+
69
+ ```link :add-evaluated-bash-code +[bash_species_code]
50
70
  eval: true
51
- next_block: "(display_variable_ALPHA)"
52
71
  ```
72
+ ```bash :[bash_species_code] @disable
73
+ echo "SPECIES='Illacme tobini (Millipede)'"
74
+ ```
53
75
 
54
76
  | Variable| Value
55
77
  | -| -
56
- | ALPHA| ${ALPHA}
78
+ | SPECIES| ${SPECIES}
57
79
 
58
- ```bash :(display_variable_ALPHA)
59
- ```
80
+ @import example-document-opts.md
81
+ ```opts :(document_opts)
82
+ execute_in_own_window: false
83
+ menu_with_inherited_lines: false
84
+ output_execution_report: false
85
+ output_execution_summary: false
86
+ pause_after_script_execution: true
87
+ ```
data/lib/collapser.rb CHANGED
@@ -6,18 +6,20 @@
6
6
  require_relative 'constants'
7
7
 
8
8
  class Collapser
9
- attr_accessor :options, :state
9
+ attr_accessor :compress_ids, :expand_ids, :options
10
10
 
11
11
  def initialize(
12
12
  collapsed_level: nil,
13
13
  collapsible_types: COLLAPSIBLE_TYPES,
14
- options: {},
15
- state: Hash.new(nil)
14
+ compress_ids:,
15
+ expand_ids:,
16
+ options: {}
16
17
  )
17
18
  @collapsed_level = collapsed_level
18
19
  @collapsible_types = collapsible_types.dup
19
20
  @options = options.dup
20
- @state = state # do not dup
21
+ @compress_ids = compress_ids # by ref, user action
22
+ @expand_ids = expand_ids # by ref, user action
21
23
  end
22
24
 
23
25
  def collapse_per_options?(fcb, options: @options)
@@ -27,13 +29,15 @@ class Collapser
27
29
  criteria
28
30
  end
29
31
 
30
- def collapse_per_state?(fcb, default: false, state: @state)
31
- return false if state.nil?
32
-
33
- criteria = state[fcb.id]
34
- return default if criteria.nil?
35
-
36
- !!criteria
32
+ # collapse per user action
33
+ def collapse_per_state?(fcb, default: false)
34
+ if @compress_ids.key?(fcb.id) && !!@compress_ids[fcb.id]
35
+ true
36
+ elsif @expand_ids.key?(fcb.id) && !!@expand_ids[fcb.id]
37
+ false
38
+ else
39
+ default
40
+ end
37
41
  end
38
42
 
39
43
  def collapse_per_token?(fcb)
@@ -52,10 +56,11 @@ class Collapser
52
56
  end
53
57
 
54
58
  def collapse?(fcb, initialize: false)
59
+ per_options_and_token = (collapse_per_options?(fcb) || collapse_per_token?(fcb)) && !expand_per_token?(fcb)
55
60
  if initialize
56
- (collapse_per_options?(fcb) || collapse_per_token?(fcb)) && !expand_per_token?(fcb)
61
+ per_options_and_token
57
62
  else
58
- collapse_per_state?(fcb, default: false)
63
+ collapse_per_state?(fcb, default: per_options_and_token)
59
64
  end
60
65
  end
61
66
 
@@ -100,8 +105,13 @@ class Collapser
100
105
  else
101
106
  fcb.hide = true
102
107
  end
103
- @state[fcb.id] = fcb.level if fcb.collapse
104
-
108
+ if fcb.collapse
109
+ @compress_ids[fcb.id] = fcb.level
110
+ @expand_ids.delete(fcb.id)
111
+ else
112
+ @compress_ids.delete(fcb.id)
113
+ @expand_ids[fcb.id] = fcb.level
114
+ end
105
115
  collapsed_level
106
116
  end
107
117
 
@@ -138,13 +148,15 @@ OPTIONS = {
138
148
  heading3_collapse: false,
139
149
  heading3_collapsible: true
140
150
  }.freeze
141
- STATE = {}.freeze
142
151
 
143
152
  class CollapserTest < Minitest::Test
144
153
  def setup
145
- @collapser = Collapser.new(collapsible_types: COLLAPSIBLE_TYPES.dup,
146
- options: OPTIONS.dup,
147
- state: STATE).dup
154
+ @collapser = Collapser.new(
155
+ collapsible_types: COLLAPSIBLE_TYPES.dup,
156
+ options: OPTIONS.dup,
157
+ compress_ids: {},
158
+ expand_ids: {}
159
+ ).dup
148
160
  end
149
161
 
150
162
  def test_analyze
@@ -312,7 +324,8 @@ class CollapserTest < Minitest::Test
312
324
  { name: 'collapsed remains collapsed',
313
325
  fcbs: [fc_h1a__collapse_collapsible],
314
326
  options: { heading1_collapsible: true },
315
- state: { 'h1a' => 1 },
327
+ compress_ids: { 'h1a' => 1 },
328
+ expand_ids: {},
316
329
  initialize: false,
317
330
  expected: [fc_h1a__collapse_collapsible] }
318
331
  ]
@@ -324,7 +337,8 @@ class CollapserTest < Minitest::Test
324
337
  collapsed_level: test_case[:collapsed_level],
325
338
  collapsible_types: test_case[:collapsible_types] || COLLAPSIBLE_TYPES,
326
339
  options: (test_case[:options] || OPTIONS).dup,
327
- state: (test_case[:state] || STATE).dup
340
+ compress_ids: test_case[:compress_ids] || {},
341
+ expand_ids: {}
328
342
  )
329
343
  analysis = @collapser.analyze(
330
344
  test_case[:fcbs],