asciidoctor-dita-topic 1.1.8 → 1.1.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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.adoc +53 -12
  3. data/lib/dita-topic.rb +21 -8
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 555374cce6e4fb24f49f9c756f93c5198dad77e11ca2b936e74d785cd0dfdc46
4
- data.tar.gz: 5b58e29874ab9a538f78450ac7c705f074ac5edc2bb32755d98f94c691950821
3
+ metadata.gz: 38849b62e13e55fe22459cab2c4a7aab8d47286e94cb5d573eeed98c175381ce
4
+ data.tar.gz: 440406834354a1a70c87be6026b763f95c920de0d924d5f9a2cdb2aee5842a1f
5
5
  SHA512:
6
- metadata.gz: 5877a348c87c911a141d66a6dd83879b3fdd2e614d5d106d1d30bfe75dcb685bdcc1ad641bb3e62151ea4e93e20dfbfad693fed011c4720c1f72bfb4f1d7fbd1
7
- data.tar.gz: e03de5af2e3ef13a6364cca3a3f00b257eabc542403cf422a30178049269031873c6c88e95b3f32b72bf57e15b745f5e7d683311d7da334bba95ecbf4c77a317
6
+ metadata.gz: cb1ee4720a5c4580557cf96bba10e93aa70e3ea1d3c976e0a2968f329a4e9eab7c04f3a60b8c791fa524089f0096c07e6624d170ffe8acc987f56add7992cab3
7
+ data.tar.gz: 26fe19f12366806c508b6c11218c6a78aa3d522032260d135e5b344bad150c91cdbe159d75b81b6ff1adcf0f58a3e52e440bee41c0563f785f4be70e0a92671a
data/README.adoc CHANGED
@@ -144,18 +144,6 @@ To disable this behavior, set the value of the `dita-topic-callouts` to `off`:
144
144
  $ **asciidoctor -r dita-topic -b dita-topic -a dita-topic-callouts=off _your_file_.adoc**
145
145
  ....
146
146
 
147
- [#abstracts]
148
- === Disable abstracts
149
-
150
- By default, the `dita-topic` converter recognizes a paragraph preceded by the `[role="_abstract"]` attribute list and preserves this information by adding the `outputclass="abstract"` attribute to it in DITA. The link:https://github.com/jhradilek/dita-custom-xslt#installation[dita-convert Python package] uses this attribute to populate the `<shortdesc>` element during conversion to a specialized DITA concept, reference, or task.
151
-
152
- To disable this behavior, set the value of the `dita-topic-abstracts` to `off`:
153
-
154
- [literal,subs="+quotes"]
155
- ....
156
- $ **asciidoctor -r dita-topic -b dita-topic -a dita-topic-abstracts=off _your_file_.adoc**
157
- ....
158
-
159
147
  [#includes]
160
148
  === Disabling include directives
161
149
 
@@ -166,6 +154,59 @@ By default, Asciidoctor resolves all `include` directives before converting the
166
154
  $ **asciidoctor -r dita-topic -b dita-topic -S secure _your_file_.adoc**
167
155
  ....
168
156
 
157
+ [#abstracts]
158
+ === Adding short descriptions
159
+
160
+ DITA provides the `<shortdesc>` element which allows the user to describe the purpose of the topic and is often used as preview text in search results. To replicate this behavior, the `dita-topic` converter recognizes a paragraph preceded by the `[role="_abstract"]` attribute list and adds the `outputclass="abstract"` attribute to it. The link:https://github.com/jhradilek/dita-custom-xslt#installation[dita-convert Python package] transforms such a paragraph to `<shortdesc>` during conversion to a specialized DITA concept, reference, or task.
161
+
162
+ For example, to designate a paragraph as a short description, use the following AsciiDoc markup:
163
+
164
+ [source,asciidoc]
165
+ ----
166
+ [id="topic-id"]
167
+ = Procedure title
168
+
169
+ [role="_abstract"]
170
+ A short description of the procedure module and what it helps the
171
+ user accomplish.
172
+
173
+ An introductory paragraph.
174
+ ----
175
+
176
+ [#semantics]
177
+ === Adding semantic markup
178
+
179
+ Unlike AsciiDoc, DITA provides a number of semantic elements for software components such as file names, commands, or command-line options. To replicate this behavior, the `dita-topic` converter recognizes the following link:https://docs.asciidoctor.org/asciidoc/latest/attributes/role/#assign-roles-to-formatted-inline-elements[roles] assigned to monospace (```) inline text:
180
+
181
+ [cols="1,1"]
182
+ |===
183
+ | AsciiDoc Role
184
+ | DITA Element
185
+
186
+ | command
187
+ | `<cmdname>`
188
+
189
+ | directory
190
+ | `<filepath>`
191
+
192
+ | filename
193
+ | `<filepath>`
194
+
195
+ | option
196
+ | `<option>`
197
+
198
+ | variable
199
+ | `<varname>`
200
+ |===
201
+
202
+ For example, to describe a file name, use the following AsciiDoc markup:
203
+
204
+ [source,asciidoc]
205
+ ----
206
+ Read the [filename]`/etc/passwd` file to see the complete list of
207
+ available user accounts.
208
+ ----
209
+
169
210
  [#warnings]
170
211
  == Warnings
171
212
 
data/lib/dita-topic.rb CHANGED
@@ -38,9 +38,6 @@ class DitaTopic < Asciidoctor::Converter::Base
38
38
  # Disable the author line by default:
39
39
  @authors_allowed = false
40
40
 
41
- # Enable abstract paragraphs by default:
42
- @abstracts_allowed = true
43
-
44
41
  # Enable callouts by default:
45
42
  @callouts_allowed = true
46
43
 
@@ -55,9 +52,6 @@ class DitaTopic < Asciidoctor::Converter::Base
55
52
  # Check if the author line is enabled:
56
53
  @authors_allowed = true if (node.attr 'dita-topic-authors') == 'on'
57
54
 
58
- # Check if abstract paragraphs are enabled:
59
- @abstracts_allowed = false if (node.attr 'dita-topic-abstracts') == 'off'
60
-
61
55
  # Check if callouts are enabled:
62
56
  @callouts_allowed = false if (node.attr 'dita-topic-callouts') == 'off'
63
57
 
@@ -450,7 +444,26 @@ class DitaTopic < Asciidoctor::Converter::Base
450
444
  when :strong
451
445
  %(<b>#{node.text}</b>)
452
446
  when :monospaced
453
- %(<tt>#{node.text}</tt>)
447
+ # Check whether a role is provided:
448
+ if node.role
449
+ # Define supported roles:
450
+ semantic_markup = {
451
+ 'command' => 'cmdname',
452
+ 'directory' => 'filepath',
453
+ 'filename' => 'filepath',
454
+ 'option' => 'option',
455
+ 'variable' => 'varname'
456
+ }
457
+
458
+ # Select the appropriate semantic element:
459
+ element = (semantic_markup.key? node.role) ? semantic_markup[node.role] : 'tt'
460
+ else
461
+ # Use the teletype element by default:
462
+ element = 'tt'
463
+ end
464
+
465
+ # Return the result:
466
+ %(<#{element}>#{node.text}</#{element}>)
454
467
  when :superscript
455
468
  %(<sup>#{node.text}</sup>)
456
469
  when :subscript
@@ -557,7 +570,7 @@ class DitaTopic < Asciidoctor::Converter::Base
557
570
  end
558
571
 
559
572
  def convert_paragraph node
560
- if @abstracts_allowed and (node.attr 'role') == '_abstract'
573
+ if (node.attr 'role') == '_abstract'
561
574
  add_block_title %(<p outputclass="abstract">#{node.content}</p>), node.title
562
575
  else
563
576
  add_block_title %(<p>#{node.content}</p>), node.title
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: asciidoctor-dita-topic
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.8
4
+ version: 1.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jaromir Hradilek
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-05-27 00:00:00.000000000 Z
10
+ date: 2025-06-07 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: asciidoctor