asciidoctor-dita-topic 1.1.0 → 1.1.2

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 +13 -1
  3. data/lib/dita-topic.rb +29 -12
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 134df897545adafba05f060ea22079c3fa927204b47fff2eec8ffbc8ae5ef84a
4
- data.tar.gz: 354b8abadd320b9a4c63b3c170a85974a2231836da07851e1cde58da06aafff3
3
+ metadata.gz: 172e330842b5b5f390c287fd0adfe4e51a055c669145c09a0a4b07d7a85057ba
4
+ data.tar.gz: 3e76bd3a36ed2954827156500d393ac982506862395fbceb30b84c075db95e72
5
5
  SHA512:
6
- metadata.gz: 4b7e9fcd688f450a2e05effca4c30d5969db15d7056cd23b6c1829d6f65de79cc95e0208f5dc543b5bd2f87117aa972f49dcff76963ef8b67879f5a40a97af6f
7
- data.tar.gz: 05122aac651d614082cc4cb350197bdbb897d2b7436189eb225a230ffc3f8ad2f3ee5d66f1b882f78bab39d4fd38d18caaeba0d1b5dd965c98ccd7f52a530f97
6
+ metadata.gz: 4f5cc15df1b03d9198a87d9996859b067a957928375a6469c8901c3850d76dc0f06f5f3e9e3ff9eb86a8f369c55bf9d7c9a9074e2937ff5798b7b9157bb4a428
7
+ data.tar.gz: 2986bb1e278b253df0d1d0768d695e8799191253f3527c58f8ef027159ce237e7a09e517dfa78d6cc1043d0c437ff09866848c6ddbe8db7cbb7781806c342252
data/README.adoc CHANGED
@@ -1,6 +1,6 @@
1
1
  = dita-topic
2
2
 
3
- `dita-topic` is a custom converter for Asciidoctor that converts a single AsciiDoc file to a corresponding DITA topic. To convert the produced DITA topic to a specialized DITA concept, reference, or task, use the link:https://github.com/jhradilek/dita-custom-xslt[dita_convert Python package].
3
+ `dita-topic` is a custom converter for Asciidoctor that converts a single AsciiDoc file to a corresponding DITA topic. To convert the produced DITA topic to a specialized DITA concept, reference, or task, use the link:https://github.com/jhradilek/dita-custom-xslt#installation[dita-convert Python package].
4
4
 
5
5
  [#install]
6
6
  == Installation
@@ -121,6 +121,18 @@ To disable this behavior, set the value of the `dita-topic-callouts` to `off`:
121
121
  $ **asciidoctor -r dita-topic -b dita-topic -a dita-topic-callouts=off _your_file_.adoc**
122
122
  ....
123
123
 
124
+ [#abstracts]
125
+ === Disable abstracts
126
+
127
+ 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.
128
+
129
+ To disable this behavior, set the value of the `dita-topic-abstracts` to `off`:
130
+
131
+ [literal,subs="+quotes"]
132
+ ....
133
+ $ **asciidoctor -r dita-topic -b dita-topic -a dita-topic-abstracts=off _your_file_.adoc**
134
+ ....
135
+
124
136
  [#includes]
125
137
  === Disabling include directives
126
138
 
data/lib/dita-topic.rb CHANGED
@@ -36,6 +36,9 @@ class DitaTopic < Asciidoctor::Converter::Base
36
36
  # Disable the author line by default:
37
37
  @authors_allowed = false
38
38
 
39
+ # Enable abstract paragraphs by default:
40
+ @abstracts_allowed = true
41
+
39
42
  # Enable callouts by default:
40
43
  @callouts_allowed = true
41
44
 
@@ -47,14 +50,20 @@ class DitaTopic < Asciidoctor::Converter::Base
47
50
  # Check if the author line is enabled:
48
51
  @authors_allowed = true if (node.attr 'dita-topic-authors') == 'on'
49
52
 
53
+ # Check if abstract paragraphs are enabled:
54
+ @abstracts_allowed = false if (node.attr 'dita-topic-abstracts') == 'off'
55
+
50
56
  # Check if callouts are enabled:
51
57
  @callouts_allowed = false if (node.attr 'dita-topic-callouts') == 'off'
52
58
 
53
59
  # Check if floating and block titles are enabled:
54
60
  @titles_allowed = false if (node.attr 'dita-topic-titles') == 'off'
55
61
 
56
- # Check if the modular documentation content type is specified:
62
+ # Check if the modular documentation content type is specified; both
63
+ # _module-type and _content-type are deprecated, but still present in
64
+ # some modules:
57
65
  outputclass = ''
66
+ outputclass = %( outputclass="#{(node.attr '_module-type').downcase}") if node.attr? '_module-type'
58
67
  outputclass = %( outputclass="#{(node.attr '_content-type').downcase}") if node.attr? '_content-type'
59
68
  outputclass = %( outputclass="#{(node.attr '_mod-docs-content-type').downcase}") if node.attr? '_mod-docs-content-type'
60
69
 
@@ -278,20 +287,26 @@ class DitaTopic < Asciidoctor::Converter::Base
278
287
  # I do not want to process them from this script, I choose to issue a
279
288
  # warning so that the user can resolve the problem.
280
289
 
281
- # Determine whether the cross reference links to a file path or an ID:
290
+ # Determine whether the cross reference links to a file path:
282
291
  if (path = node.attributes['path'])
283
292
  # Issue a warning if the cross reference includes an ID:
284
293
  logger.warn "#{NAME}: Possible invalid reference: #{node.target}" if node.target.include? '#'
285
294
 
286
295
  # Compose a cross reference:
287
- %(<xref href="#{node.target}">#{node.text || path}</xref>)
288
- else
289
- # Issue a warning as the cross reference is unlikely to work:
290
- logger.warn "#{NAME}: Possible invalid reference: #{node.target}"
296
+ return %(<xref href="#{node.target}">#{node.text || path}</xref>)
297
+ end
291
298
 
299
+ # Determine whether the ID reference target is in this document:
300
+ if node.document.catalog[:refs].key? (target = node.target.delete_prefix '#')
292
301
  # Compose the cross reference:
293
- node.text ? %(<xref href="#{node.target}">#{node.text}</xref>) : %(<xref href="#{node.target}" />)
302
+ return node.text ? %(<xref href="#./#{target}">#{node.text}</xref>) : %(<xref href="#./#{target}" />)
294
303
  end
304
+
305
+ # Issue a warning as the cross reference is unlikely to work:
306
+ logger.warn "#{NAME}: Possible invalid reference: #{node.target}"
307
+
308
+ # Compose the cross reference:
309
+ node.text ? %(<xref href="#{node.target}">#{node.text}</xref>) : %(<xref href="#{node.target}" />)
295
310
  when :ref
296
311
  # NOTE: DITA does not have a dedicated element for inline anchors or
297
312
  # a direct equivalent of the <span> element from HTML. The solution
@@ -454,8 +469,7 @@ class DitaTopic < Asciidoctor::Converter::Base
454
469
  node.items.each do |item|
455
470
  # Check if the list item contains multiple block elements:
456
471
  if item.blocks?
457
- result << %(<li>)
458
- result << %(<p>#{item.text}</p>)
472
+ result << %(<li>#{item.text})
459
473
  result << item.content
460
474
  result << %(</li>)
461
475
  else
@@ -501,7 +515,11 @@ class DitaTopic < Asciidoctor::Converter::Base
501
515
  end
502
516
 
503
517
  def convert_paragraph node
504
- add_block_title %(<p>#{node.content}</p>), node.title
518
+ if @abstracts_allowed and (node.attr 'role') == '_abstract'
519
+ add_block_title %(<p outputclass="abstract">#{node.content}</p>), node.title
520
+ else
521
+ add_block_title %(<p>#{node.content}</p>), node.title
522
+ end
505
523
  end
506
524
 
507
525
  def convert_preamble node
@@ -685,8 +703,7 @@ class DitaTopic < Asciidoctor::Converter::Base
685
703
 
686
704
  # Check if the list item contains multiple block elements:
687
705
  if item.blocks?
688
- result << %(<li>)
689
- result << %(<p>#{check_box}#{item.text}</p>)
706
+ result << %(<li>#{check_box}#{item.text})
690
707
  result << item.content
691
708
  result << %(</li>)
692
709
  else
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: asciidoctor-dita-topic
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jaromir Hradilek
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-02-24 00:00:00.000000000 Z
11
+ date: 2025-03-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: asciidoctor