asciidoctor-reducer 1.0.1 → 1.0.2

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: '042939f0b251163208b57a67bed8a7b16d15d0972a616e67c171b8462a5ae61b'
4
- data.tar.gz: 9065fc1b7a742f057441f873956883e6c87ba88afb1984496c821f378e666e2b
3
+ metadata.gz: b5316a1e0a22871599401171fc8f5104e4a03cf09598eacee8670153354e6050
4
+ data.tar.gz: 02cc09578b9798e53f3e8a23f81b2e051ef2b6714c39bee99d043a6cbee2acc5
5
5
  SHA512:
6
- metadata.gz: 53e3e2cd52cf60ff810b93c5409cf521c1e5509106c8cece15ac89262d5a7d0ac998b2369ebb1cd8854675de930ea3a2f10c762bf072f758db663f3b6e7aa0ed
7
- data.tar.gz: 1785df7825bd0fb902dd619bf42b2de90360acdf975f3356ca5ad8ed7b65a32c71c8824b51b966aecce774078d14d5c6dcdf281d899eb6f54e61307dbec0b0ce
6
+ metadata.gz: a2ef54d4a37f4c1f2205cb191735a1d6462ad271faa75db4ea87305c5ba25f2ba08885057f5c56006703ad745fc2c55928ac0c6db9205e9ee35284fab245f395
7
+ data.tar.gz: '0018183fd91c359a67ad0a6e5b60901f5f868bc4223bd9fc27c639eb5fb05a684c938480507a9ff445bdd00ad260ff385c29d68a6359c2498cc6a4d9cee0320a'
data/CHANGELOG.adoc CHANGED
@@ -4,6 +4,16 @@
4
4
  This document provides a curated view of the changes to Asciidoctor Reducer in each release.
5
5
  For a detailed view of what has changed, refer to the {url-repo}/commits/main[commit history] on GitHub.
6
6
 
7
+ == 1.0.2 (2022-05-09) - @mojavelinux
8
+
9
+ === Fixed
10
+
11
+ * Replace include and conditional directives inside a file that has been included partially (i.e., has an offset) (#43)
12
+
13
+ === Details
14
+
15
+ {url-repo}/releases/tag/v1.0.2[git tag] | {url-repo}/compare/v1.0.1\...v1.0.2[full diff]
16
+
7
17
  == 1.0.1 (2022-05-08) - @mojavelinux
8
18
 
9
19
  === Changed
data/README.adoc CHANGED
@@ -1,6 +1,6 @@
1
1
  = {project-name}
2
2
  Dan Allen <https://github.com/mojavelinux[@mojavelinux]>
3
- v1.0.1, 2022-05-08
3
+ v1.0.2, 2022-05-09
4
4
  :idprefix:
5
5
  :idseparator: -
6
6
  ifndef::env-github[:icons: font]
@@ -8,7 +8,9 @@ module Asciidoctor::Reducer
8
8
  directive_lineno = @lineno
9
9
  result = super
10
10
  return result if @skipping && skip_active
11
- drop = @include_replacements.current[:drop] ||= []
11
+ curr_inc_replacement = @include_replacements.current
12
+ drop = curr_inc_replacement[:drop] ||= []
13
+ directive_lineno -= (curr_inc_replacement[:offset] ||= 0)
12
14
  if (depth_change = @conditional_stack.size - depth) < 0
13
15
  if skip_active
14
16
  drop.push(*(drop.pop..directive_lineno))
@@ -18,7 +18,7 @@ module Asciidoctor::Reducer
18
18
  directive_lineno == @lineno && (unresolved = ln.start_with? 'link:')
19
19
  ln = %(#{ln.slice 0, (ln.length - 1)}role=include])
20
20
  end
21
- push_include_replacement directive_lineno, (unresolved ? [ln] : []), unresolved
21
+ push_include_replacement directive_lineno, (unresolved ? [ln] : []), 0, unresolved
22
22
  end
23
23
  @x_reducer.clear
24
24
  result
@@ -28,8 +28,9 @@ module Asciidoctor::Reducer
28
28
  @x_reducer[:include_pushed] = true
29
29
  directive_lineno = @lineno - 1 # we're below the include line, which is 1-based
30
30
  prev_inc_depth = @include_stack.size
31
+ offset = lineno > 1 ? lineno - 1 : 0
31
32
  result = super
32
- push_include_replacement directive_lineno, (@include_stack.size > prev_inc_depth ? lines : [])
33
+ push_include_replacement directive_lineno, (@include_stack.size > prev_inc_depth ? lines : []), offset
33
34
  result
34
35
  end
35
36
 
@@ -40,12 +41,13 @@ module Asciidoctor::Reducer
40
41
 
41
42
  private
42
43
 
43
- def push_include_replacement lineno, lines, unresolved = false
44
+ def push_include_replacement lineno, lines, offset, unresolved = false
44
45
  (inc_replacements = @include_replacements) << {
45
46
  into: inc_replacements.pointer,
46
- lineno: lineno,
47
+ lineno: lineno - (inc_replacements.current[:offset] ||= 0),
47
48
  line: @x_reducer[:include_directive_line],
48
49
  lines: lines,
50
+ offset: offset,
49
51
  }
50
52
  inc_replacements.to_end unless unresolved || lines.empty?
51
53
  nil
@@ -8,7 +8,7 @@ module Asciidoctor::Reducer
8
8
  inc_replacements.reverse_each do |it|
9
9
  if (into = it[:into])
10
10
  target_lines = inc_replacements[into][:lines]
11
- # adds extra bit of assurance that we're replacing the correct line
11
+ # adds extra assurance that we're replacing the correct line
12
12
  next unless target_lines[(idx = it[:lineno] - 1)] == it[:line]
13
13
  end
14
14
  lines = it[:lines]
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Asciidoctor
4
4
  module Reducer
5
- VERSION = '1.0.1'
5
+ VERSION = '1.0.2'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: asciidoctor-reducer
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dan Allen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-05-08 00:00:00.000000000 Z
11
+ date: 2022-05-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: asciidoctor