markdown_exec 3.1.0 → 3.1.1

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: 401f0583b9951f0cfd6259313d7120d2f5f7fbbb3c596110eeafe449f63b9ca7
4
- data.tar.gz: 8c411e5c1f3ae394d76a2e0fbbc92aae009e31ba0e17b9fa29d30dabfd8b8e5a
3
+ metadata.gz: 7b38cc422f735f0c00b0c31e6bd6253bda083e28890475220198109953ce9a74
4
+ data.tar.gz: c62e5bc1a2f294b783e4ce53341ae459f46251c25b076e6bb214e483f0c4a2c8
5
5
  SHA512:
6
- metadata.gz: 896ac3441e10cac18bbccbe02913612f8a926a7108dd86a9b01d0dc8354d1da4f8ca58dcb8413f460072277802639be2bd4421efc83abced9e18ea9212505010
7
- data.tar.gz: 4804a98ff4a6ff6a5d7ba7dc0739e6ec2d6b7a115dd7f6198955261bf1d07ed62e93c9d1180570e14f3d1e43e6a59a6ae587c21fbbd13d02491b79ad7ac92e1e
6
+ metadata.gz: c1f902747ed7f5688ff734d0b43b8cda0cd9dcff8957290938a8689437c0090660c0534e98c739a7c85a55c066e8604d4593e063382bb68ca46be7e7aae5fc83
7
+ data.tar.gz: 1f6fdc9a5640a40159a49547784c09609b1889a4fcd0db7d4e333ff33c2a6a4f3d05ead80b05e4a9b75ae8ce4e880808dae3c37384f0145123824a27bc901ce7
data/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## [3.1.1] - 2025-06-28
4
+
5
+ ### Changed
6
+
7
+ - Fix inherited lines for chained blocks.
8
+ - Optimize import text replacement.
9
+
3
10
  ## [3.1.0] - 2025-06-23
4
11
 
5
12
  ### Added
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- markdown_exec (3.1.0)
4
+ markdown_exec (3.1.1)
5
5
  clipboard (~> 1.3.6)
6
6
  open3 (~> 0.1.1)
7
7
  optparse (~> 0.1.1)
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env bats
2
+
3
+ load 'test_helper'
4
+
5
+ @test 'initial value, inherited lines' {
6
+ spec_mde_xansi_dname_doc_blocks_expect docs/dev/block-type-ux-require-chained.md \
7
+ '[SPECIES]' \
8
+ 'ENTITY = Pongo tapanuliensis,Pongo_ENTITY="Pongo tapanuliensis,Pongo"_SPECIES=Pongo\ tapanuliensis_GENUS=Pongo_NAME=Pongo\ tapanuliensis\ -\ Pongo_NAME2=Pongo\ tapanuliensis\ -\ Pongo_SPECIES=Pongo tapanuliensis_GENUS=Pongo_NAME=Pongo tapanuliensis - Pongo_NAME2=Pongo tapanuliensis - Pongo'
9
+ }
@@ -6,3 +6,9 @@ load 'test_helper'
6
6
  spec_mde_xansi_dname_doc_blocks_expect docs/dev/block-type-ux-require.md \
7
7
  'SPECIES=Pongo tapanuliensis_GENUS=Pongo_NAME=Pongo tapanuliensis - Pongo_NAME2=Pongo tapanuliensis - Pongo'
8
8
  }
9
+
10
+ @test 'inherited lines' {
11
+ spec_mde_xansi_dname_doc_blocks_expect docs/dev/block-type-ux-require.md \
12
+ '(menu_with_inherited_lines)' \
13
+ 'SPECIES=Pongo\ tapanuliensis_GENUS=Pongo_NAME=Pongo\ tapanuliensis\ -\ Pongo_NAME2=Pongo\ tapanuliensis\ -\ Pongo_SPECIES=Pongo tapanuliensis_GENUS=Pongo_NAME=Pongo tapanuliensis - Pongo_NAME2=Pongo tapanuliensis - Pongo'
14
+ }
@@ -4,23 +4,23 @@ load 'test_helper'
4
4
 
5
5
  @test 'document initial state' {
6
6
  spec_mde_xansi_dname_doc_blocks_expect docs/dev/load-vars-state-demo.md \
7
- 'var1 = line1_var3 = line6_ inherited_lines_ - : var1="line1"_ - : var3="line6"_ LOAD BLOCK STATE MODIFICATION DEMO__This document demonstrates how a LOAD block can modify the inherited state that was initially set_by VARS blocks.__First, establish baseline variables using a VARS block:__Use a LOAD block to modify the initial state:__load-mode-default_load-mode-append_load-mode-replace'
7
+ 'var1 = line1_var3 = line6_ inherited_lines_ - : var1="line1"_ - : var3="line6"_ LOAD BLOCK STATE MODIFICATION DEMO__This document demonstrates how a LOAD block can modify_the inherited state that was initially set by VARS_blocks.__First, establish baseline variables using a VARS block:__Use a LOAD block to modify the initial state:__load-mode-default_load-mode-append_load-mode-replace'
8
8
  }
9
9
 
10
10
  @test 'load-mode-default' {
11
11
  spec_mde_xansi_dname_doc_blocks_expect docs/dev/load-vars-state-demo.md \
12
12
  load-mode-default \
13
- 'var1 = line1_var3 = line6_ inherited_lines_ - : var1="line1"_ - : var3="line6"_ inherited_lines_ - : var1="line1"_ - : var3="line6"_ - : # line 1_ - : var1=line2_ - : # line 3_ - : var2=line4_ - : # line 5_ LOAD BLOCK STATE MODIFICATION DEMO__This document demonstrates how a LOAD block can modify the inherited state that was initially set_by VARS blocks.__First, establish baseline variables using a VARS block:__Use a LOAD block to modify the initial state:__load-mode-default_load-mode-append_load-mode-replace'
13
+ 'var1 = line1_var3 = line6_ inherited_lines_ - : var1="line1"_ - : var3="line6"_ inherited_lines_ - : var1="line1"_ - : var3="line6"_ - : # line 1_ - : var1=line2_ - : # line 3_ - : var2=line4_ - : # line 5_ LOAD BLOCK STATE MODIFICATION DEMO__This document demonstrates how a LOAD block can modify_the inherited state that was initially set by VARS_blocks.__First, establish baseline variables using a VARS block:__Use a LOAD block to modify the initial state:__load-mode-default_load-mode-append_load-mode-replace'
14
14
  }
15
15
 
16
16
  @test 'load-mode-append' {
17
17
  spec_mde_xansi_dname_doc_blocks_expect docs/dev/load-vars-state-demo.md \
18
18
  load-mode-append \
19
- 'var1 = line1_var3 = line6_ inherited_lines_ - : var1="line1"_ - : var3="line6"_ inherited_lines_ - : var1="line1"_ - : var3="line6"_ - : # line 1_ - : var1=line2_ - : # line 3_ - : var2=line4_ - : # line 5_ LOAD BLOCK STATE MODIFICATION DEMO__This document demonstrates how a LOAD block can modify the inherited state that was initially set_by VARS blocks.__First, establish baseline variables using a VARS block:__Use a LOAD block to modify the initial state:__load-mode-default_load-mode-append_load-mode-replace'
19
+ 'var1 = line1_var3 = line6_ inherited_lines_ - : var1="line1"_ - : var3="line6"_ inherited_lines_ - : var1="line1"_ - : var3="line6"_ - : # line 1_ - : var1=line2_ - : # line 3_ - : var2=line4_ - : # line 5_ LOAD BLOCK STATE MODIFICATION DEMO__This document demonstrates how a LOAD block can modify_the inherited state that was initially set by VARS_blocks.__First, establish baseline variables using a VARS block:__Use a LOAD block to modify the initial state:__load-mode-default_load-mode-append_load-mode-replace'
20
20
  }
21
21
 
22
22
  @test 'load-mode-replace' {
23
23
  spec_mde_xansi_dname_doc_blocks_expect docs/dev/load-vars-state-demo.md \
24
24
  load-mode-replace \
25
- 'var1 = line1_var3 = line6_ inherited_lines_ - : var1="line1"_ - : var3="line6"_ inherited_lines_ - : # line 1_ - : var1=line2_ - : # line 3_ - : var2=line4_ - : # line 5_ LOAD BLOCK STATE MODIFICATION DEMO__This document demonstrates how a LOAD block can modify the inherited state that was initially set_by VARS blocks.__First, establish baseline variables using a VARS block:__Use a LOAD block to modify the initial state:__load-mode-default_load-mode-append_load-mode-replace'
25
+ 'var1 = line1_var3 = line6_ inherited_lines_ - : var1="line1"_ - : var3="line6"_ inherited_lines_ - : # line 1_ - : var1=line2_ - : # line 3_ - : var2=line4_ - : # line 5_ LOAD BLOCK STATE MODIFICATION DEMO__This document demonstrates how a LOAD block can modify_the inherited state that was initially set by VARS_blocks.__First, establish baseline variables using a VARS block:__Use a LOAD block to modify the initial state:__load-mode-default_load-mode-append_load-mode-replace'
26
26
  }
@@ -0,0 +1,33 @@
1
+ / UX blocks may requiring other UX blocks
2
+ ```vars :(document_vars)
3
+ ENTITY: Pongo tapanuliensis,Pongo
4
+ ```
5
+ ```ux :[SPECIES] +[GENUS] +[NAME]
6
+ act: :echo
7
+ echo: "${ENTITY%%,*}"
8
+ force: true
9
+ init: false
10
+ name: SPECIES
11
+ ```
12
+ ```ux :[GENUS]
13
+ echo: "${ENTITY##*,}"
14
+ force: true
15
+ init: false
16
+ name: GENUS
17
+ ```
18
+ ```ux :[NAME] +[NAME2]
19
+ echo: "$SPECIES - $GENUS"
20
+ force: true
21
+ init: false
22
+ name: NAME
23
+ ```
24
+ ```ux :[NAME2]
25
+ echo: "$NAME"
26
+ force: true
27
+ init: false
28
+ name: NAME2
29
+ ```
30
+ ```opts :(document_opts)
31
+ menu_with_inherited_lines: true
32
+ ```
33
+ @import bats-document-configuration.md
@@ -4,20 +4,28 @@ ENTITY='Pongo tapanuliensis,Pongo'
4
4
  ```
5
5
  ```ux +(shell)
6
6
  echo: "${ENTITY%%,*}"
7
+ force: true
7
8
  name: SPECIES
8
9
  ```
9
10
  ```ux +(shell)
10
11
  echo: "${ENTITY##*,}"
12
+ force: true
11
13
  name: GENUS
12
14
  ```
13
15
  / executed in context of prior ux blocks, uses their initial values
14
16
  ```ux
15
17
  echo: "$SPECIES - $GENUS"
18
+ force: true
16
19
  name: NAME
17
20
  ```
18
21
  / executed after other ux blocks, uses their initial values
19
22
  ```ux
20
23
  echo: "$NAME"
24
+ force: true
21
25
  name: NAME2
22
26
  ```
27
+ / This block is not visible. Execute to display the inherited lines for testing.
28
+ ```opts :(menu_with_inherited_lines)
29
+ menu_with_inherited_lines: true
30
+ ```
23
31
  @import bats-document-configuration.md
@@ -123,7 +123,9 @@ class CachedNestedFileReader
123
123
  /([A-Za-z_]\w*)=(?:"([^"]*)"|'([^']*)'|(\S+))/
124
124
  ) do |key, quoted_double, quoted_single, unquoted|
125
125
  value = quoted_double || quoted_single || unquoted
126
- params[key] = value
126
+ # skip replacement of equal values
127
+ # otherwise, the text is not available for other substitutions
128
+ params[key] = value if key != value
127
129
  end
128
130
  params
129
131
  end
data/lib/env_interface.rb CHANGED
@@ -10,7 +10,7 @@ class EnvInterface
10
10
  # @param transform [Proc] Optional transformation to apply to the value
11
11
  # @return [Object] The environment variable value
12
12
  def get(key, default: nil, transform: nil)
13
- ww key, \
13
+ wwt :env, key, \
14
14
  value = ENV[key]
15
15
  return default if value.nil?
16
16
 
@@ -23,7 +23,7 @@ ww key, \
23
23
  # @param transform [Proc] Optional transformation to apply before setting
24
24
  # @return [String] The set value
25
25
  def set(key, value, transform: nil)
26
- ww key, caller.deref[0..3], value
26
+ wwt :env, key, caller.deref[0..3], value
27
27
  transformed_value = transform ? transform.call(value) : value
28
28
  ENV[key] = transformed_value.to_s
29
29
  end
@@ -1110,7 +1110,7 @@ module MarkdownExec
1110
1110
  selected, mdoc, inherited_code: nil, force: true, only_default: false,
1111
1111
  silent:
1112
1112
  )
1113
- wwt :fcb, 'ux block with code', selected
1113
+ wwt :fcb, 'selected:', selected
1114
1114
  ret_command_result = nil
1115
1115
  exit_prompt = @delegate_object[:prompt_filespec_back]
1116
1116
 
@@ -1169,10 +1169,12 @@ module MarkdownExec
1169
1169
  end
1170
1170
  return command_result_w_e_t_nl if command_result_w_e_t_nl.failure?
1171
1171
 
1172
+ # update the required lines for this and subsequent blocks
1172
1173
  command_result_w_e_t_nl.new_lines =
1173
1174
  process_command_result_lines(command_result_w_e_t_nl, export,
1174
1175
  required_lines)
1175
1176
  required_lines.concat(command_result_w_e_t_nl.new_lines)
1177
+ command_result_w_e_t_nl.new_lines = required_lines
1176
1178
  ret_command_result = command_result_w_e_t_nl
1177
1179
  else
1178
1180
  raise "Invalid data type: #{data.inspect}"
@@ -7,5 +7,5 @@ module MarkdownExec
7
7
  BIN_NAME = 'mde'
8
8
  GEM_NAME = 'markdown_exec'
9
9
  TAP_DEBUG = 'MDE_DEBUG'
10
- VERSION = '3.1.0'
10
+ VERSION = '3.1.1'
11
11
  end
data/lib/ww.rb CHANGED
@@ -19,7 +19,8 @@ def ww(*objs, **kwargs)
19
19
  # return the last item in the list, as the label is usually first
20
20
  return objs.last unless $debug
21
21
 
22
- ww0(*objs, **kwargs.merge(locations: caller_locations))
22
+ locations = kwargs[:locations] || caller_locations
23
+ ww0(*objs, **kwargs.merge(locations: locations))
23
24
  end
24
25
 
25
26
  # select enabled, for exceptions
@@ -33,6 +34,8 @@ end
33
34
  # selectively enabled, for process tracking
34
35
  # print the failing line
35
36
  def wwp(*objs, **kwargs)
37
+ return objs.last unless $debug
38
+
36
39
  ww(*objs, **kwargs.merge(locations: caller_locations[0..0]))
37
40
  end
38
41
 
@@ -40,7 +43,7 @@ end
40
43
  # print the failing line
41
44
  # eg wwt :line, 'data:', data
42
45
  def wwt(*objs, **kwargs)
43
- # return if [:line].include? objs.first
46
+ return objs.last if !$debug || %i[env].include?(objs.first)
44
47
 
45
48
  formatted = ['Tagged', objs.first] + objs[1..]
46
49
  ww(*formatted, **kwargs.merge(locations: caller_locations[0..0]))
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: 3.1.0
4
+ version: 3.1.1
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-06-23 00:00:00.000000000 Z
11
+ date: 2025-06-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: clipboard
@@ -124,6 +124,7 @@ files:
124
124
  - bats/block-type-ux-hidden.bats
125
125
  - bats/block-type-ux-invalid.bats
126
126
  - bats/block-type-ux-readonly.bats
127
+ - bats/block-type-ux-require-chained.bats
127
128
  - bats/block-type-ux-require.bats
128
129
  - bats/block-type-ux-required-variables.bats
129
130
  - bats/block-type-ux-row-format.bats
@@ -182,6 +183,7 @@ files:
182
183
  - docs/dev/block-type-ux-hidden.md
183
184
  - docs/dev/block-type-ux-invalid.md
184
185
  - docs/dev/block-type-ux-readonly.md
186
+ - docs/dev/block-type-ux-require-chained.md
185
187
  - docs/dev/block-type-ux-require.md
186
188
  - docs/dev/block-type-ux-required-variables.md
187
189
  - docs/dev/block-type-ux-row-format.md