asciidoctor-reducer 1.0.2 → 1.0.4

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: b5316a1e0a22871599401171fc8f5104e4a03cf09598eacee8670153354e6050
4
- data.tar.gz: 02cc09578b9798e53f3e8a23f81b2e051ef2b6714c39bee99d043a6cbee2acc5
3
+ metadata.gz: '093396b7e8100e4c3c7ee3a3aadfea734195bee629fe5284c2dc7e09d6a270d7'
4
+ data.tar.gz: d216e0f827b3c0eeb5f80f130ef0d8200567f14babda2f42b65fb141f465d842
5
5
  SHA512:
6
- metadata.gz: a2ef54d4a37f4c1f2205cb191735a1d6462ad271faa75db4ea87305c5ba25f2ba08885057f5c56006703ad745fc2c55928ac0c6db9205e9ee35284fab245f395
7
- data.tar.gz: '0018183fd91c359a67ad0a6e5b60901f5f868bc4223bd9fc27c639eb5fb05a684c938480507a9ff445bdd00ad260ff385c29d68a6359c2498cc6a4d9cee0320a'
6
+ metadata.gz: b2d405cce7f61beae5ed35f4247892ee321bdb4efbba0c49faa325560503be3bb68d828e2018df686e95c0ddf576436c625d3b81dc87847e8ccce6642d3ecc92
7
+ data.tar.gz: 4454a1023fbba097f8b8227de6d0c594f215a77cc6f57d71f423141c9594f07e6fee8635e8ef61939f6551a0f6062639dc39c52a197de5b162f9300b9cc3844a
data/CHANGELOG.adoc CHANGED
@@ -4,6 +4,30 @@
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.4 (2022-10-15) - @mojavelinux
8
+
9
+ === Changed
10
+
11
+ * don't add role to link that replaces include directive if role is already present
12
+
13
+ === Details
14
+
15
+ {url-repo}/releases/tag/v1.0.4[git tag] | {url-repo}/compare/v1.0.3\...v1.0.4[full diff]
16
+
17
+ == 1.0.3 (2022-09-22) - @mojavelinux
18
+
19
+ === Changed
20
+
21
+ * Log error message if program cannot locate include directive to reduce (indicates a probable logic error in the program)
22
+
23
+ === Fixed
24
+
25
+ * Reduce preprocessor directives in file included by include directive with `leveloffset` attribute (#45)
26
+
27
+ === Details
28
+
29
+ {url-repo}/releases/tag/v1.0.3[git tag] | {url-repo}/compare/v1.0.2\...v1.0.3[full diff]
30
+
7
31
  == 1.0.2 (2022-05-09) - @mojavelinux
8
32
 
9
33
  === Fixed
data/README.adoc CHANGED
@@ -1,6 +1,6 @@
1
1
  = {project-name}
2
2
  Dan Allen <https://github.com/mojavelinux[@mojavelinux]>
3
- v1.0.2, 2022-05-09
3
+ v1.0.4, 2022-10-15
4
4
  :idprefix:
5
5
  :idseparator: -
6
6
  ifndef::env-github[:icons: font]
@@ -260,6 +260,45 @@ Here's an example of that comment:
260
260
 
261
261
  When a document that contains the magic comment is converted, the include mapper reads the comma-separated paths in the value and loads them into the includes table of the document catalog.
262
262
 
263
+ == Reduce files in a GitHub repository
264
+
265
+ It's well known that the AsciiDoc preview on GitHub does not support the include directive.
266
+ With the help of GitHub Actions, Asciidoctor Reducer is ready-made to solve this problem.
267
+
268
+ In order to set up this automated process, you need to first rename the source file to make room for the reduced file.
269
+ Let's call the source file [.path]_README-source.adoc_ and the reduced file [.path]_README.adoc_.
270
+
271
+ Next, create a GitHub Actions workflow file named [.path]_.github/workflows/reduce-readme.yml_ and populate it with the following contents:
272
+
273
+ ..github/workflows/reduce-readme.yml
274
+ [,yaml]
275
+ ----
276
+ name: Reduce README
277
+ on:
278
+ push:
279
+ paths:
280
+ - README-source.adoc
281
+ branches: ['**']
282
+ jobs:
283
+ build:
284
+ runs-on: ubuntu-latest
285
+ steps:
286
+ - name: Checkout Repository
287
+ uses: actions/checkout@v2
288
+ - name: Install Asciidoctor Reducer
289
+ run: sudo gem install asciidoctor-reducer
290
+ - name: Reduce README
291
+ run: asciidoctor-reducer -o README.adoc README-source.adoc
292
+ - name: Commit and Push README
293
+ uses: EndBug/add-and-commit@v9
294
+ with:
295
+ add: README.adoc
296
+ ----
297
+
298
+ Now, each time you modify, commit, and push the [.path]_README-source.adoc_ file, the GitHub Action workflow will run, reduce that file, and push the reduced file back to the repository as [.path]_README.adoc_.
299
+
300
+ If you want to trigger the workflow on changes to other files as well, add those paths or path patterns to the value of the `paths` key.
301
+
263
302
  == Development
264
303
 
265
304
  Follow the instructions below to learn how to help develop the project or test-drive the development version.
@@ -18,7 +18,7 @@ Gem::Specification.new do |s|
18
18
  s.metadata = {
19
19
  'bug_tracker_uri' => 'https://github.com/asciidoctor/asciidoctor-reducer/issues',
20
20
  'changelog_uri' => 'https://github.com/asciidoctor/asciidoctor-reducer/blob/main/CHANGELOG.adoc',
21
- 'mailing_list_uri' => 'https://asciidoctor.zulipchat.com',
21
+ 'mailing_list_uri' => 'https://chat.asciidoctor.org',
22
22
  'source_code_uri' => 'https://github.com/asciidoctor/asciidoctor-reducer'
23
23
  }
24
24
 
@@ -15,8 +15,8 @@ module Asciidoctor::Reducer
15
15
  result = super
16
16
  unless @x_reducer[:include_pushed]
17
17
  if ((ln = peek_line true)&.end_with? ']') && !(unresolved = ln.start_with? 'Unresolved directive in ') &&
18
- directive_lineno == @lineno && (unresolved = ln.start_with? 'link:')
19
- ln = %(#{ln.slice 0, (ln.length - 1)}role=include])
18
+ directive_lineno == @lineno && (unresolved = ln.start_with? 'link:') && (ln.end_with? '[]')
19
+ ln = %(#{ln.chop}role=include])
20
20
  end
21
21
  push_include_replacement directive_lineno, (unresolved ? [ln] : []), 0, unresolved
22
22
  end
@@ -30,7 +30,11 @@ module Asciidoctor::Reducer
30
30
  prev_inc_depth = @include_stack.size
31
31
  offset = lineno > 1 ? lineno - 1 : 0
32
32
  result = super
33
- push_include_replacement directive_lineno, (@include_stack.size > prev_inc_depth ? lines : []), offset
33
+ if @include_stack.size > prev_inc_depth
34
+ inc_lines = lines
35
+ offset -= 2 if (attrs.key? 'leveloffset') && (inc_lines[0].start_with? ':leveloffset: ') && inc_lines[1]&.empty?
36
+ end
37
+ push_include_replacement directive_lineno, inc_lines || [], offset
34
38
  result
35
39
  end
36
40
 
@@ -8,8 +8,12 @@ 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 assurance that we're replacing the correct line
12
- next unless target_lines[(idx = it[:lineno] - 1)] == it[:line]
11
+ # adds extra assurance that the program is replacing the correct line
12
+ unless target_lines[(idx = it[:lineno] - 1)] == it[:line]
13
+ msg = %(include directive to reduce not found; expected: "#{it[:line]}"; got: "#{target_lines[idx]}")
14
+ doc.logger.error msg
15
+ next
16
+ end
13
17
  end
14
18
  lines = it[:lines]
15
19
  unless (drop = it[:drop] || []).empty?
@@ -21,7 +25,7 @@ module Asciidoctor::Reducer
21
25
  end
22
26
  reduced_source_lines = inc_replacements[0][:lines].flatten
23
27
  if doc.sourcemap
24
- logger = ::Asciidoctor::LoggerManager.logger
28
+ logger = doc.logger
25
29
  opts = doc.options.merge logger: nil, parse: false, reduced: true
26
30
  if (ext_reg = opts[:extension_registry])
27
31
  opts[:extension_registry] = ::Asciidoctor::Extensions::Registry.new ext_reg.groups
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Asciidoctor
4
4
  module Reducer
5
- VERSION = '1.0.2'
5
+ VERSION = '1.0.4'
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.2
4
+ version: 1.0.4
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-09 00:00:00.000000000 Z
11
+ date: 2022-10-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: asciidoctor
@@ -84,7 +84,7 @@ licenses:
84
84
  metadata:
85
85
  bug_tracker_uri: https://github.com/asciidoctor/asciidoctor-reducer/issues
86
86
  changelog_uri: https://github.com/asciidoctor/asciidoctor-reducer/blob/main/CHANGELOG.adoc
87
- mailing_list_uri: https://asciidoctor.zulipchat.com
87
+ mailing_list_uri: https://chat.asciidoctor.org
88
88
  source_code_uri: https://github.com/asciidoctor/asciidoctor-reducer
89
89
  post_install_message:
90
90
  rdoc_options: []