asciidoctor-dita-topic 1.4.7 → 1.4.9

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: aa49c2e77c20ed32770fa37f0a286ca5a5aa808c5fef1e11c70bce3ac5fc3f74
4
- data.tar.gz: 698164a21ee241367c0ebc3d029759e546618514ac91d93e7076abe0eea58ca7
3
+ metadata.gz: 54897b731c29e283e7a3f6813b8399e583435343d5c480cb2f802e392ad07dfc
4
+ data.tar.gz: bb7ebe60820497be880333fa56b0e56b85c0713073314bef65f1fd33237fb0ad
5
5
  SHA512:
6
- metadata.gz: 6ddefc4aec275a5ce85990ca28bdcffe0d2a8033834112c5eea7c225f0420af2de96f952661799a17b3c2134739001ccf7f6323b7f8953a191f4dc9dcfb18ada
7
- data.tar.gz: 1088e887c924235e473b9f23aa04e4e3a41e3f8f307857342f7f852b2de5791e2917d7b69c74ff8f487e1c82098d62cbe993f1b8fd9c9f72f127e7284dd14fe1
6
+ metadata.gz: 87eb3816ce0a31a524c758abefdc15bec4c364654928d974b79baf8cbb88d9ef4bfe2975fb77fec8e7f9564045269ba8d8482796c7507af2d9958544608e8256
7
+ data.tar.gz: fbe4b750cba7a0745c45165b337b1ad466874371c3a13d211348e58b12430a035f88f188120c025bf5d4f4f1f10dc06fd037303c6728a44d20b70ef8a0891949
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
  ....
@@ -261,6 +261,20 @@ Read the [filename]`/etc/passwd` file to see the complete list of
261
261
  available user accounts.
262
262
  ----
263
263
 
264
+ 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:
265
+
266
+ [literal,subs="+quotes"]
267
+ ....
268
+ $ **dita-topic -M _your_file_.adoc**
269
+ ....
270
+
271
+ If you prefer to use Asciidoctor directly, set the value of the `dita-topic-semantic` attribute to `off`:
272
+
273
+ [literal,subs="+quotes"]
274
+ ....
275
+ $ **asciidoctor -r dita-topic -b dita-topic -a dita-topic-semantic=off _your_file_.adoc**
276
+ ....
277
+
264
278
  [#metadata]
265
279
  === Adding metadata
266
280
 
@@ -341,6 +355,6 @@ Thematic breaks not supported in DITA:: Asciidoc allows you to use `'''`, `---`,
341
355
  [#copyright]
342
356
  == Copyright
343
357
 
344
- Copyright (C) 2024, 2025 Jaromir Hradilek
358
+ Copyright (C) 2024–2026 Jaromir Hradilek
345
359
 
346
360
  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.
@@ -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
  #
@@ -34,7 +34,6 @@ module AsciidoctorDitaTopic
34
34
  @opts = {
35
35
  :output => false,
36
36
  :standalone => true,
37
- :map => false,
38
37
  :no_includes => 0
39
38
  }
40
39
  @prep = []
@@ -61,10 +60,6 @@ module AsciidoctorDitaTopic
61
60
 
62
61
  opt.separator ''
63
62
 
64
- opt.on('-m', '--dita-map', 'generate a DITA map instead of a topic; this functionality is experimental and not yet fully tested') do
65
- @opts[:map] = true
66
- end
67
-
68
63
  opt.on('-p', '--prepend-file FILE', 'prepend a file to all input files; can be supplied multiple times') do |file|
69
64
  raise OptionParser::InvalidArgument, "not a file: #{file}" unless File.exist? file and File.file? file
70
65
  raise OptionParser::InvalidArgument, "file not readable: #{file}" unless File.readable? file
@@ -90,6 +85,10 @@ module AsciidoctorDitaTopic
90
85
  @attr.append 'dita-topic-callouts=off'
91
86
  end
92
87
 
88
+ opt.on('-M', '--no-semantic-markup', 'disable processing of semantic markup') do
89
+ @attr.append 'dita-topic-semantic=off'
90
+ end
91
+
93
92
  opt.on('-S', '--no-sidebars', 'disable processing of sidebars') do
94
93
  @attr.append 'dita-topic-sidebars=off'
95
94
  end
@@ -125,73 +124,6 @@ module AsciidoctorDitaTopic
125
124
  return args
126
125
  end
127
126
 
128
- def convert_map file, input, base_dir
129
- if file == $stdin
130
- offset = 0
131
- else
132
- file = Pathname.new(file).sub_ext('.dita').basename
133
- offset = 1
134
- end
135
-
136
- doc = Asciidoctor.load input, backend: 'dita-topic', safe: :unsafe, attributes: @attr, base_dir: base_dir, sourcemap: true
137
- sections = doc.find_by context: :section
138
-
139
- return unless sections
140
-
141
- title = (sections.first.level == 0 and sections.first.title) ? sections.first.title : false
142
-
143
- if @opts[:standalone]
144
- result = ["<?xml version='1.0' encoding='utf-8' ?>"]
145
- result << %(<!DOCTYPE map PUBLIC "-//OASIS//DTD DITA Map//EN" "map.dtd">)
146
- result << %(<map>)
147
- result << %( <title>#{title}</title>) if title
148
- else
149
- result = []
150
- end
151
-
152
- last_level = 0
153
- last_file = ''
154
-
155
- sections.each_index do |i|
156
- section = sections[i]
157
- level = section.level
158
- title = section.title.gsub(/"|<[^>]*>|[<>]/, '')
159
- filename = section.file ? Pathname.new(section.file).sub_ext('.dita').relative_path_from(base_dir) : Pathname.new(file)
160
- current = last_level
161
-
162
- next if filename == last_file
163
-
164
- while current > level
165
- current -= 1
166
- result << ' ' * (current + offset) + %(</topicref>)
167
- end
168
-
169
- if level - last_level > 1
170
- warn "WARNING: #{filename.basename}: line #{section.lineno}: section title out of sequence: expected level #{last_level + 1}, got level #{level}"
171
- level = last_level + 1
172
- end
173
-
174
- indent = ' ' * (level + offset)
175
- parent = (sections[i + 1] and sections[i + 1].level > level) ? true : false
176
- result << indent + %(<topicref href="#{filename}" navtitle="#{title}"#{parent ? '>' : ' />'}) unless filename == $stdin
177
-
178
- last_level = level
179
- last_file = filename
180
- end
181
-
182
- while last_level > 0
183
- last_level -= 1
184
- break if last_level == 0 and file == $stdin
185
- result << ' ' * (last_level + offset) + %(</topicref>)
186
- end
187
-
188
- if @opts[:standalone]
189
- result << %(</map>)
190
- end
191
-
192
- return result.join("\n")
193
- end
194
-
195
127
  def convert_topic input, base_dir
196
128
  return Asciidoctor.convert input, backend: 'dita-topic', standalone: @opts[:standalone], safe: :unsafe, attributes: @attr, base_dir: base_dir
197
129
  end
@@ -210,21 +142,18 @@ module AsciidoctorDitaTopic
210
142
  input = $stdin.read
211
143
  output = @opts[:output] ? @opts[:output] : $stdout
212
144
  else
213
- suffix = @opts[:map] ? '.ditamap' : '.dita'
214
145
  base_dir = Pathname.new(file).dirname.expand_path
215
146
  input = File.read(file)
216
- output = @opts[:output] ? @opts[:output] : Pathname.new(file).sub_ext(suffix).to_s
147
+ output = @opts[:output] ? @opts[:output] : Pathname.new(file).sub_ext('.dita').to_s
217
148
  end
218
149
 
219
150
  prepended.gsub!(/^:_(?:mod-docs-content|content|module)-type:[ \t]+\S/, '//\&')
220
151
  prepended.gsub!(Asciidoctor::IncludeDirectiveRx, '//\&') if @opts[:no_includes] > 1
221
152
  input.gsub!(Asciidoctor::IncludeDirectiveRx, '//\&') if @opts[:no_includes] > 0
222
153
 
223
- if @opts[:map]
224
- result = convert_map file, prepended + input, base_dir
225
- else
226
- result = convert_topic prepended + input, base_dir
227
- end
154
+ result = convert_topic prepended + input, base_dir
155
+
156
+ result.gsub!(/<ph (?:(?:platform|product|audience|otherprops)="[^"]+" ?)+><\/ph> */, '')
228
157
 
229
158
  if output == $stdout
230
159
  $stdout.write result
@@ -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.7'
27
+ VERSION = '1.4.9'
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.7
4
+ version: 1.4.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jaromir Hradilek
@@ -18,7 +18,7 @@ dependencies:
18
18
  version: '2.0'
19
19
  - - ">="
20
20
  - !ruby/object:Gem::Version
21
- version: 2.0.0
21
+ version: 2.0.26
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
@@ -28,49 +28,81 @@ dependencies:
28
28
  version: '2.0'
29
29
  - - ">="
30
30
  - !ruby/object:Gem::Version
31
- version: 2.0.0
31
+ version: 2.0.26
32
32
  - !ruby/object:Gem::Dependency
33
33
  name: rake
34
34
  requirement: !ruby/object:Gem::Requirement
35
35
  requirements:
36
36
  - - "~>"
37
37
  - !ruby/object:Gem::Version
38
- version: 12.3.0
38
+ version: '13.3'
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: 13.3.1
39
42
  type: :development
40
43
  prerelease: false
41
44
  version_requirements: !ruby/object:Gem::Requirement
42
45
  requirements:
43
46
  - - "~>"
44
47
  - !ruby/object:Gem::Version
45
- version: 12.3.0
48
+ version: '13.3'
49
+ - - ">="
50
+ - !ruby/object:Gem::Version
51
+ version: 13.3.1
46
52
  - !ruby/object:Gem::Dependency
47
53
  name: minitest
48
54
  requirement: !ruby/object:Gem::Requirement
49
55
  requirements:
50
56
  - - "~>"
51
57
  - !ruby/object:Gem::Version
52
- version: 5.22.0
58
+ version: '6.0'
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: 6.0.2
53
62
  type: :development
54
63
  prerelease: false
55
64
  version_requirements: !ruby/object:Gem::Requirement
56
65
  requirements:
57
66
  - - "~>"
58
67
  - !ruby/object:Gem::Version
59
- version: 5.22.0
68
+ version: '6.0'
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ version: 6.0.2
72
+ - !ruby/object:Gem::Dependency
73
+ name: minitest-mock
74
+ requirement: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - "~>"
77
+ - !ruby/object:Gem::Version
78
+ version: '5.27'
79
+ type: :development
80
+ prerelease: false
81
+ version_requirements: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - "~>"
84
+ - !ruby/object:Gem::Version
85
+ version: '5.27'
60
86
  - !ruby/object:Gem::Dependency
61
87
  name: rexml
62
88
  requirement: !ruby/object:Gem::Requirement
63
89
  requirements:
64
90
  - - "~>"
65
91
  - !ruby/object:Gem::Version
66
- version: 3.2.6
92
+ version: '3.4'
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: 3.4.4
67
96
  type: :development
68
97
  prerelease: false
69
98
  version_requirements: !ruby/object:Gem::Requirement
70
99
  requirements:
71
100
  - - "~>"
72
101
  - !ruby/object:Gem::Version
73
- version: 3.2.6
102
+ version: '3.4'
103
+ - - ">="
104
+ - !ruby/object:Gem::Version
105
+ version: 3.4.4
74
106
  description: An extension for AsciiDoctor that converts a single AsciiDoc file to
75
107
  a DITA topic.
76
108
  email: jhradilek@gmail.com