asciidoctor-dita-topic 1.4.9 → 1.5.0
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 +4 -4
- data/README.adoc +27 -1
- data/lib/dita-topic/cli.rb +11 -0
- data/lib/dita-topic/filter.rb +55 -0
- data/lib/dita-topic/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b150bed25c8b6413a69a4caa81af642427d3c799fc70ec32ca090b4df36622ab
|
|
4
|
+
data.tar.gz: b49b48b67ebc6a056121ed223c3af0af321c3284372fb1238c3b19f8752c8e2b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9c30598e80430b66ee90928f3b6222486bc3f187a024b685ee09da7063e4b2d42666c014a70ca5c9892eca85487fa45831e630bc11ba8e22775c372cafaff9fb
|
|
7
|
+
data.tar.gz: a278c11c09eb8290c2fa1347a81cab381059a0083efc2f53477135e1ca222aa0482fdee5b62a12897cf981914ce52453227162c2f24025e7da0f5af06a0a367f
|
data/README.adoc
CHANGED
|
@@ -184,7 +184,7 @@ $ **asciidoctor -r dita-topic -b dita-topic -a dita-topic-callouts=off _your_fil
|
|
|
184
184
|
....
|
|
185
185
|
|
|
186
186
|
[#includes]
|
|
187
|
-
=== Disabling include directives
|
|
187
|
+
=== Disabling all include directives
|
|
188
188
|
|
|
189
189
|
By default, Asciidoctor resolves all `include` directives before converting the file. To only convert the contents of the selected file, run the `dita-topic` command with the `-I` option:
|
|
190
190
|
|
|
@@ -202,6 +202,32 @@ $ **asciidoctor -r dita-topic -b dita-topic -S secure _your_file_.adoc**
|
|
|
202
202
|
|
|
203
203
|
This disables processing of the include directives, but leaves cross references to the included files in the converted output.
|
|
204
204
|
|
|
205
|
+
[#include_filter]
|
|
206
|
+
=== Disabling inclusion of assemblies and modules
|
|
207
|
+
|
|
208
|
+
By default, Asciidoctor resolves all `include` directives before converting the file. To only include content from files explicitly marked as attributes or snippets, run the `dita-topic` command with the `-A` option:
|
|
209
|
+
|
|
210
|
+
[literal,subs="+quotes"]
|
|
211
|
+
....
|
|
212
|
+
$ **dita-topic -A _your_file_.adoc**
|
|
213
|
+
....
|
|
214
|
+
|
|
215
|
+
To mark a file as an attribute definition file, add the following line at the top of it:
|
|
216
|
+
|
|
217
|
+
[source,asciidoc]
|
|
218
|
+
----
|
|
219
|
+
:_mod-docs-content-type: ATTRIBUTES
|
|
220
|
+
----
|
|
221
|
+
|
|
222
|
+
To mark a file as a snippet file, add the following line at the top of it:
|
|
223
|
+
|
|
224
|
+
[source,asciidoc]
|
|
225
|
+
----
|
|
226
|
+
:_mod-docs-content-type: SNIPPET
|
|
227
|
+
----
|
|
228
|
+
|
|
229
|
+
Any other files are ignored. This functionality is not available in standard Asciidoctor.
|
|
230
|
+
|
|
205
231
|
[#abstracts]
|
|
206
232
|
=== Adding short descriptions
|
|
207
233
|
|
data/lib/dita-topic/cli.rb
CHANGED
|
@@ -25,6 +25,7 @@ require 'optparse'
|
|
|
25
25
|
require 'pathname'
|
|
26
26
|
require 'asciidoctor'
|
|
27
27
|
require_relative 'version'
|
|
28
|
+
require_relative 'filter'
|
|
28
29
|
require_relative '../dita-topic'
|
|
29
30
|
|
|
30
31
|
module AsciidoctorDitaTopic
|
|
@@ -34,6 +35,7 @@ module AsciidoctorDitaTopic
|
|
|
34
35
|
@opts = {
|
|
35
36
|
:output => false,
|
|
36
37
|
:standalone => true,
|
|
38
|
+
:modules => true,
|
|
37
39
|
:no_includes => 0
|
|
38
40
|
}
|
|
39
41
|
@prep = []
|
|
@@ -71,6 +73,10 @@ module AsciidoctorDitaTopic
|
|
|
71
73
|
@opts[:no_includes] += 1
|
|
72
74
|
end
|
|
73
75
|
|
|
76
|
+
opt.on('-A', '--no-modules', 'disable processing of include directives with assemblies and modules') do
|
|
77
|
+
@opts[:modules] = false
|
|
78
|
+
end
|
|
79
|
+
|
|
74
80
|
opt.separator ''
|
|
75
81
|
|
|
76
82
|
opt.on('-l', '--author-line', 'enable processing of author lines as metadata') do
|
|
@@ -125,6 +131,11 @@ module AsciidoctorDitaTopic
|
|
|
125
131
|
end
|
|
126
132
|
|
|
127
133
|
def convert_topic input, base_dir
|
|
134
|
+
if not @opts[:modules]
|
|
135
|
+
Asciidoctor::Extensions.register do
|
|
136
|
+
include_processor FilterIncludeDirectives
|
|
137
|
+
end
|
|
138
|
+
end
|
|
128
139
|
return Asciidoctor.convert input, backend: 'dita-topic', standalone: @opts[:standalone], safe: :unsafe, attributes: @attr, base_dir: base_dir
|
|
129
140
|
end
|
|
130
141
|
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# Copyright (C) 2026 Jaromir Hradilek
|
|
2
|
+
|
|
3
|
+
# MIT License
|
|
4
|
+
#
|
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
# a copy of this software and associated documentation files (the "Soft-
|
|
7
|
+
# ware"), to deal in the Software without restriction, including without
|
|
8
|
+
# limitation the rights to use, copy, modify, merge, publish, distribute,
|
|
9
|
+
# sublicense, and/or sell copies of the Software, and to permit persons to
|
|
10
|
+
# whom the Software is furnished to do so, subject to the following condi-
|
|
11
|
+
# tions:
|
|
12
|
+
#
|
|
13
|
+
# The above copyright notice and this permission notice shall be included
|
|
14
|
+
# in all copies or substantial portions of the Software.
|
|
15
|
+
#
|
|
16
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
17
|
+
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABI-
|
|
18
|
+
# LITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
|
|
19
|
+
# SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
|
|
20
|
+
# OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
|
21
|
+
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
22
|
+
# OTHER DEALINGS IN THE SOFTWARE.
|
|
23
|
+
|
|
24
|
+
require 'asciidoctor'
|
|
25
|
+
require 'pathname'
|
|
26
|
+
|
|
27
|
+
class FilterIncludeDirectives < Asciidoctor::Extensions::IncludeProcessor
|
|
28
|
+
def handles? target
|
|
29
|
+
target.end_with? '.adoc', '.asciidoc', '.asc', '.ad'
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def process doc, reader, target, attributes
|
|
33
|
+
file_path = Pathname.new(doc.base_dir) + target
|
|
34
|
+
|
|
35
|
+
begin
|
|
36
|
+
logger = Asciidoctor::LoggerManager.logger
|
|
37
|
+
include_doc = Asciidoctor.load_file file_path, safe: :secure, logger: false
|
|
38
|
+
ensure
|
|
39
|
+
Asciidoctor::LoggerManager.logger = logger
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
return reader unless supported_type? include_doc.attributes
|
|
43
|
+
|
|
44
|
+
reader.push_include File.read(file_path), target, target, 1, attributes
|
|
45
|
+
return reader
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def supported_type? attributes
|
|
49
|
+
type = attributes['_mod-docs-content-type'] ? attributes['_mod-docs-content-type'].downcase : nil
|
|
50
|
+
type = attributes['_content-type'] ? attributes['_content-type'].downcase : nil unless type
|
|
51
|
+
type = attributes['_module-type'] ? attributes['_module-type'].downcase : nil unless type
|
|
52
|
+
|
|
53
|
+
['attributes', 'snippet'].include? type
|
|
54
|
+
end
|
|
55
|
+
end
|
data/lib/dita-topic/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: asciidoctor-dita-topic
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.5.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Jaromir Hradilek
|
|
@@ -117,6 +117,7 @@ files:
|
|
|
117
117
|
- bin/dita-topic
|
|
118
118
|
- lib/dita-topic.rb
|
|
119
119
|
- lib/dita-topic/cli.rb
|
|
120
|
+
- lib/dita-topic/filter.rb
|
|
120
121
|
- lib/dita-topic/version.rb
|
|
121
122
|
homepage: https://github.com/jhradilek/asciidoctor-dita-topic
|
|
122
123
|
licenses:
|
|
@@ -139,7 +140,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
139
140
|
- !ruby/object:Gem::Version
|
|
140
141
|
version: '0'
|
|
141
142
|
requirements: []
|
|
142
|
-
rubygems_version:
|
|
143
|
+
rubygems_version: 4.0.10
|
|
143
144
|
specification_version: 4
|
|
144
145
|
summary: A custom AsciiDoc converter that generates individual DITA topics
|
|
145
146
|
test_files: []
|