asciidoctor-dita-topic 1.4.8 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fa920fa9fdc9383aca4b8411314622cb154dd6ada686b0b12f997e6e184b2a65
4
- data.tar.gz: 56888969b54b717a5f716684e210688b04bd7a4b31e7023437faf5860992eaa5
3
+ metadata.gz: b150bed25c8b6413a69a4caa81af642427d3c799fc70ec32ca090b4df36622ab
4
+ data.tar.gz: b49b48b67ebc6a056121ed223c3af0af321c3284372fb1238c3b19f8752c8e2b
5
5
  SHA512:
6
- metadata.gz: ac7bb7c93a66b5b0b2ffd1cb202fc09e42c1944f3e98f60a79c6a06c7d8b271b9e549fa1f4362e7d78295d171ed8e54f9668d2daa5f85d23740ebcfb00667b1c
7
- data.tar.gz: 0f1722b7ea6b5adb0cdfa8a9816ccb85a98bb9f924b936acc08ad725b1f9b5e9133bd266bfa00321ae576d10f50a23627d3b2d05345ca2a5d6ad7a8943965b7f
6
+ metadata.gz: 9c30598e80430b66ee90928f3b6222486bc3f187a024b685ee09da7063e4b2d42666c014a70ca5c9892eca85487fa45831e630bc11ba8e22775c372cafaff9fb
7
+ data.tar.gz: a278c11c09eb8290c2fa1347a81cab381059a0083efc2f53477135e1ca222aa0482fdee5b62a12897cf981914ce52453227162c2f24025e7da0f5af06a0a367f
data/README.adoc CHANGED
@@ -133,7 +133,7 @@ To enable processing of author lines as metadata, run the `dita-topic` command w
133
133
  $ **dita-topic -l _your_file_.adoc**
134
134
  ....
135
135
 
136
- If you prefer to use Asciidoctor directly, set the value of the `dita-topic-authors` to `on`:
136
+ If you prefer to use Asciidoctor directly, set the value of the `dita-topic-authors` attribute to `on`:
137
137
 
138
138
  [literal,subs="+quotes"]
139
139
  ....
@@ -157,7 +157,7 @@ To disable this behavior, run the `dita-topic` command with the `-T` option:
157
157
  $ **dita-topic -T _your_file_.adoc**
158
158
  ....
159
159
 
160
- If you prefer to use Asciidoctor directly, set the value of the `dita-topic-titles` to `off`:
160
+ If you prefer to use Asciidoctor directly, set the value of the `dita-topic-titles` attribute to `off`:
161
161
 
162
162
  [literal,subs="+quotes"]
163
163
  ....
@@ -176,7 +176,7 @@ To disable this behavior, run the `dita-topic` command with the `-C` option:
176
176
  $ **dita-topic -C _your_file_.adoc**
177
177
  ....
178
178
 
179
- If you prefer to use Asciidoctor directly, set the value of the `dita-topic-callouts` to `off`:
179
+ If you prefer to use Asciidoctor directly, set the value of the `dita-topic-callouts` attribute to `off`:
180
180
 
181
181
  [literal,subs="+quotes"]
182
182
  ....
@@ -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
 
@@ -261,6 +287,20 @@ Read the [filename]`/etc/passwd` file to see the complete list of
261
287
  available user accounts.
262
288
  ----
263
289
 
290
+ To disable this behavior, for example when the source files do not annotate semantic markup consistently, run the `dita-topic` command with the `-M` option:
291
+
292
+ [literal,subs="+quotes"]
293
+ ....
294
+ $ **dita-topic -M _your_file_.adoc**
295
+ ....
296
+
297
+ If you prefer to use Asciidoctor directly, set the value of the `dita-topic-semantic` attribute to `off`:
298
+
299
+ [literal,subs="+quotes"]
300
+ ....
301
+ $ **asciidoctor -r dita-topic -b dita-topic -a dita-topic-semantic=off _your_file_.adoc**
302
+ ....
303
+
264
304
  [#metadata]
265
305
  === Adding metadata
266
306
 
@@ -341,6 +381,6 @@ Thematic breaks not supported in DITA:: Asciidoc allows you to use `'''`, `---`,
341
381
  [#copyright]
342
382
  == Copyright
343
383
 
344
- Copyright (C) 2024, 2025 Jaromir Hradilek
384
+ Copyright (C) 2024–2026 Jaromir Hradilek
345
385
 
346
386
  This program is free software, released under the terms of the link:LICENSE[MIT license]. It is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
@@ -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
@@ -85,6 +91,10 @@ module AsciidoctorDitaTopic
85
91
  @attr.append 'dita-topic-callouts=off'
86
92
  end
87
93
 
94
+ opt.on('-M', '--no-semantic-markup', 'disable processing of semantic markup') do
95
+ @attr.append 'dita-topic-semantic=off'
96
+ end
97
+
88
98
  opt.on('-S', '--no-sidebars', 'disable processing of sidebars') do
89
99
  @attr.append 'dita-topic-sidebars=off'
90
100
  end
@@ -121,6 +131,11 @@ module AsciidoctorDitaTopic
121
131
  end
122
132
 
123
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
124
139
  return Asciidoctor.convert input, backend: 'dita-topic', standalone: @opts[:standalone], safe: :unsafe, attributes: @attr, base_dir: base_dir
125
140
  end
126
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
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2025 Jaromir Hradilek
1
+ # Copyright (C) 2025, 2026 Jaromir Hradilek
2
2
 
3
3
  # MIT License
4
4
  #
@@ -24,5 +24,5 @@
24
24
  # frozen_string_literal: true
25
25
 
26
26
  module AsciidoctorDitaTopic
27
- VERSION = '1.4.8'
27
+ VERSION = '1.5.0'
28
28
  end
data/lib/dita-topic.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # A custom AsciiDoc converter that generates individual DITA topics
2
- # Copyright (C) 2024, 2025 Jaromir Hradilek
2
+ # Copyright (C) 2024-2026 Jaromir Hradilek
3
3
 
4
4
  # MIT License
5
5
  #
@@ -38,6 +38,9 @@ class DitaTopic < Asciidoctor::Converter::Base
38
38
  # Disable the author line by default:
39
39
  @authors_allowed = false
40
40
 
41
+ # Enable processing of semantic markup by default:
42
+ @semantic_allowed = true
43
+
41
44
  # Enable callouts by default:
42
45
  @callouts_allowed = true
43
46
 
@@ -55,6 +58,9 @@ class DitaTopic < Asciidoctor::Converter::Base
55
58
  # Check if the author line is enabled:
56
59
  @authors_allowed = true if (node.attr 'dita-topic-authors') == 'on'
57
60
 
61
+ # Check if semantic markup is enabled:
62
+ @semantic_allowed = false if (node.attr 'dita-topic-semantic') == 'off'
63
+
58
64
  # Check if callouts are enabled:
59
65
  @callouts_allowed = false if (node.attr 'dita-topic-callouts') == 'off'
60
66
 
@@ -463,8 +469,8 @@ class DitaTopic < Asciidoctor::Converter::Base
463
469
  # Set the default element value:
464
470
  element = 'codeph'
465
471
 
466
- # Check if the role is provided:
467
- if node.role
472
+ # Check if semantic markup is enabled and the role is provided:
473
+ if @semantic_allowed and node.role
468
474
  # Define supported roles:
469
475
  semantic_markup = {
470
476
  'command' => 'cmdname',
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.8
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: 3.6.9
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: []