asciidoctor-reducer 1.0.6 → 1.1.0
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3aad6e916f11307d608d015b5befc14567f71638ed6baf9023416846ee8d2136
|
4
|
+
data.tar.gz: e51e12a72a7b4acaa6335e69cf489a356e109d57640dff8b1c7f4bfdfedaed53
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 46f16ea6198d0aa04dc00c890522b8014a2f5e9bad8c684acf7a39dc275bc339ddc587409c8bc34bee1227aa976ba7f4d25c3a08e2412070a7963219483acec8
|
7
|
+
data.tar.gz: b5c42486dcccd3e178d1cbda2b09f1c7656746a830087f64a9ece7d79ab99ef9e67e40bacd19b9310063915a3bf76ea26af73b6ba18e957edc9580cdbc13773b
|
data/CHANGELOG.adoc
CHANGED
@@ -4,6 +4,17 @@
|
|
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.1.0 (2024-11-24) - @mojavelinux
|
8
|
+
|
9
|
+
=== Added
|
10
|
+
|
11
|
+
* Track header attributes in source document and assign to `source_header_attributes` attr reader on Document instance (#59)
|
12
|
+
* Add JavaScript build that publishes the `@antora/reducer` an npm package (#57)
|
13
|
+
|
14
|
+
=== Details
|
15
|
+
|
16
|
+
{url-repo}/releases/tag/v1.1.0[git tag] | {url-repo}/compare/v1.0.6\...v1.1.0[full diff]
|
17
|
+
|
7
18
|
== 1.0.6 (2024-02-12) - @mojavelinux
|
8
19
|
|
9
20
|
=== 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
|
3
|
+
v1.1.0, 2024-11-24
|
4
4
|
:idprefix:
|
5
5
|
:idseparator: -
|
6
6
|
ifndef::env-github[:icons: font]
|
@@ -20,6 +20,9 @@ endif::[]
|
|
20
20
|
Additionally, the tool evaluates preprocessor conditionals (unless the option to preserve them is enabled), only keeping those lines from conditions which are true.
|
21
21
|
If the document does not contain any preprocessor directives, the tool returns the unmodified source.
|
22
22
|
|
23
|
+
TIP: This extension is also published as an npm package named `@asciidoctor/reducer` for use with Asciidoctor.js, and hence, with Antora.
|
24
|
+
See the xref:js/README.adoc[README] to find instructions on how to use this package.
|
25
|
+
|
23
26
|
== Prerequisites
|
24
27
|
|
25
28
|
{project-name} is a Ruby application that you install using Ruby packaging.
|
@@ -112,7 +115,7 @@ require 'asciidoctor/reducer/api'
|
|
112
115
|
----
|
113
116
|
|
114
117
|
Next, reduce a parent document that contains includes.
|
115
|
-
This works without having to specify the safe mode since the default safe mode when using
|
118
|
+
(This works without having to specify the safe mode since the default safe mode when using this API is `:safe`).
|
116
119
|
|
117
120
|
[,ruby]
|
118
121
|
----
|
@@ -128,6 +131,13 @@ puts doc.source
|
|
128
131
|
|
129
132
|
The benefit of this approach is that you can access the reduced source and the parsed document that corresponds to it.
|
130
133
|
|
134
|
+
If you only want AsciiDoctor Reducer to process include directives, leaving preprocessor conditional directives untouched, set the `:preserve_conditionals` option:
|
135
|
+
|
136
|
+
[,ruby]
|
137
|
+
----
|
138
|
+
doc = Asciidoctor::Reducer.reduce_file 'sample.adoc', preserve_conditionals: true
|
139
|
+
----
|
140
|
+
|
131
141
|
If you don't need the parsed document, you can retrieve the reduced source directly by passing the `String` type to the `:to` option:
|
132
142
|
|
133
143
|
[,ruby]
|
@@ -190,8 +200,10 @@ The reducer then uses a tree processor extension to fold the include stack into
|
|
190
200
|
It does so by working from the end of the stack and inserting the lines into the parent until the stack has been flattened.
|
191
201
|
As it goes, it also removes lines that have been excluded by the preprocessor conditionals as well as the directive lines themselves (unless the option to preserve conditionals has been specified).
|
192
202
|
|
193
|
-
|
194
|
-
|
203
|
+
If the sourcemap is enabled, it loads the document again.
|
204
|
+
Finally, it returns the document.
|
205
|
+
The reduced source is available on the reconstructed document via `Document#source` or `Document#source_lines`.
|
206
|
+
The source header attributes (those defined in the header of the document) are available via `Document#source_header_attributes`.
|
195
207
|
|
196
208
|
=== Impact on Extensions
|
197
209
|
|
@@ -1,8 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
require_relative '
|
3
|
+
unless RUBY_ENGINE == 'opal'
|
4
|
+
require 'asciidoctor' unless defined? Asciidoctor.load
|
5
|
+
require_relative 'header_attribute_tracker'
|
6
|
+
require_relative 'preprocessor'
|
7
|
+
require_relative 'tree_processor'
|
8
|
+
end
|
6
9
|
|
7
10
|
module Asciidoctor::Reducer
|
8
11
|
module Extensions
|
@@ -10,9 +13,11 @@ module Asciidoctor::Reducer
|
|
10
13
|
|
11
14
|
def group
|
12
15
|
proc do
|
13
|
-
|
16
|
+
document.extend HeaderAttributeTracker
|
17
|
+
next if document.options[:reduced] # group invoked again if includes are found and sourcemap option is true
|
14
18
|
preprocessor Preprocessor
|
15
19
|
tree_processor TreeProcessor
|
20
|
+
nil
|
16
21
|
end
|
17
22
|
end
|
18
23
|
|
@@ -31,12 +36,13 @@ module Asciidoctor::Reducer
|
|
31
36
|
end
|
32
37
|
end
|
33
38
|
|
34
|
-
def register
|
35
|
-
::Asciidoctor::Extensions.
|
39
|
+
def register registry = nil
|
40
|
+
(registry || ::Asciidoctor::Extensions).groups[key] ||= group
|
36
41
|
end
|
37
42
|
|
38
|
-
def unregister
|
39
|
-
::Asciidoctor::Extensions.groups.delete key
|
43
|
+
def unregister registry = nil
|
44
|
+
(registry || ::Asciidoctor::Extensions).groups.delete key
|
45
|
+
nil
|
40
46
|
end
|
41
47
|
end
|
42
48
|
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Asciidoctor::Reducer
|
4
|
+
module HeaderAttributeTracker
|
5
|
+
def self.extended instance
|
6
|
+
instance.singleton_class.send :attr_reader, :source_header_attributes
|
7
|
+
end
|
8
|
+
|
9
|
+
def finalize_header(*) # rubocop:disable Style/MethodDefParentheses
|
10
|
+
@source_header_attributes = @attributes_modified.each_with_object({}) do |name, accum|
|
11
|
+
accum[name] = @attributes[name]
|
12
|
+
end
|
13
|
+
super
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -1,7 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
require_relative '
|
3
|
+
unless RUBY_ENGINE == 'opal'
|
4
|
+
require_relative 'include_directive_tracker'
|
5
|
+
require_relative 'conditional_directive_tracker'
|
6
|
+
end
|
5
7
|
|
6
8
|
module Asciidoctor::Reducer
|
7
9
|
class Preprocessor < ::Asciidoctor::Extensions::Preprocessor
|
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
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dan Allen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-11-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: asciidoctor
|
@@ -72,6 +72,7 @@ files:
|
|
72
72
|
- lib/asciidoctor/reducer/cli.rb
|
73
73
|
- lib/asciidoctor/reducer/conditional_directive_tracker.rb
|
74
74
|
- lib/asciidoctor/reducer/extensions.rb
|
75
|
+
- lib/asciidoctor/reducer/header_attribute_tracker.rb
|
75
76
|
- lib/asciidoctor/reducer/include_directive_tracker.rb
|
76
77
|
- lib/asciidoctor/reducer/include_mapper.rb
|
77
78
|
- lib/asciidoctor/reducer/include_mapper/extension.rb
|
@@ -101,7 +102,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
101
102
|
- !ruby/object:Gem::Version
|
102
103
|
version: '0'
|
103
104
|
requirements: []
|
104
|
-
rubygems_version: 3.
|
105
|
+
rubygems_version: 3.5.22
|
105
106
|
signing_key:
|
106
107
|
specification_version: 4
|
107
108
|
summary: Reduces an AsciiDoc document containing includes and conditionals to a single
|