asciidoctor-dita-topic 1.2.1 → 1.2.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 +12 -12
  3. data/lib/dita-topic.rb +26 -10
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 648f69ba5e5ada330dd2f74e5b6421d37e74a5a87e74d8fcce2a06361cf4f356
4
- data.tar.gz: 3ba982932cab3253139ec969449584214db56e638f0bce7b1893685eeded2aed
3
+ metadata.gz: 9ef188774cec09940a4fa4f67d8f6f91f69d3e422ba7ce79550c3b2866c7793c
4
+ data.tar.gz: 359c1f98c2991ef613e8d3a96d4c83c3861a901783633ba709ac5b2f7817c2ab
5
5
  SHA512:
6
- metadata.gz: 6aed474f0fdda4e30e85ae64cd8d2c532b6646d93713584bdffef7b00e875c2b9f12c94eae7c5c00ca00a364415fcb7d6a9da581eed88b036072f010a5de6b39
7
- data.tar.gz: 214b99142e2ca90f6e0ad5e5baf42de415127977cf585ca04017db57213c47cccbc2261a9a61a66e9f315d922210020d1c3f165233f4c904d6d1542452f270bd
6
+ metadata.gz: d7ce10652ecbcb46ba32ccef483cf774bc5f4514bba18fc49de335007bd854fc3d86f865ce52b4475fa9853e6bbfc4efd3389d263f47af57d0d0b754a170cd80
7
+ data.tar.gz: 2c10449f2d3f5f143215afa730679a17e2bed33096062eafb090af9c928d8fd46c6fe03411b890b9c8801831c0fe2b0c1a67a54f35ef900b05aea89aa4fb2510
data/README.adoc CHANGED
@@ -120,6 +120,18 @@ To enable processing of author lines as metadata, set the value of the `dita-top
120
120
  $ **asciidoctor -r dita-topic -b dita-topic -a dita-topic-authors=on _your_file_.adoc**
121
121
  ....
122
122
 
123
+ [#callouts]
124
+ === Enabling callouts
125
+
126
+ Unlike AsciiDoc, DITA does not support callouts as a method to add annotations to specific lines in verbatim blocks. For this reason, the conversion of callouts is disabled by default.
127
+
128
+ If callouts are required, the `dita-topic` converter can use XML entities for circled numbers in place of callouts. To enable this behavior, set the value of the `dita-topic-callouts` to `on`:
129
+
130
+ [literal,subs="+quotes"]
131
+ ....
132
+ $ **asciidoctor -r dita-topic -b dita-topic -a dita-topic-callouts=on _your_file_.adoc**
133
+ ....
134
+
123
135
  [#titles]
124
136
  === Disabling floating titles
125
137
 
@@ -137,18 +149,6 @@ To disable this behavior, set the value of the `dita-topic-titles` to `off`:
137
149
  $ **asciidoctor -r dita-topic -b dita-topic -a dita-topic-titles=off _your_file_.adoc**
138
150
  ....
139
151
 
140
- [#callouts]
141
- === Disabling callouts
142
-
143
- Unlike AsciiDoc, DITA does not support callouts as a method to add annotations to specific lines in verbatim blocks. To avoid losing content during conversion, as a workaround, the `dita-topic` converter uses XML entities for circled numbers.
144
-
145
- To disable this behavior, set the value of the `dita-topic-callouts` to `off`:
146
-
147
- [literal,subs="+quotes"]
148
- ....
149
- $ **asciidoctor -r dita-topic -b dita-topic -a dita-topic-callouts=off _your_file_.adoc**
150
- ....
151
-
152
152
  [#includes]
153
153
  === Disabling include directives
154
154
 
data/lib/dita-topic.rb CHANGED
@@ -39,13 +39,16 @@ class DitaTopic < Asciidoctor::Converter::Base
39
39
  @authors_allowed = false
40
40
 
41
41
  # Enable callouts by default:
42
- @callouts_allowed = true
42
+ @callouts_allowed = false
43
43
 
44
44
  # Enable floating and block titles by default:
45
45
  @titles_allowed = true
46
46
 
47
47
  # Enable sidebars by default:
48
48
  @sidebars_allowed = true
49
+
50
+ # Disable propagating the content type to sections by default:
51
+ @type_allowed = false
49
52
  end
50
53
 
51
54
  def convert_document node
@@ -53,7 +56,7 @@ class DitaTopic < Asciidoctor::Converter::Base
53
56
  @authors_allowed = true if (node.attr 'dita-topic-authors') == 'on'
54
57
 
55
58
  # Check if callouts are enabled:
56
- @callouts_allowed = false if (node.attr 'dita-topic-callouts') == 'off'
59
+ @callouts_allowed = true if (node.attr 'dita-topic-callouts') == 'on'
57
60
 
58
61
  # Check if floating and block titles are enabled:
59
62
  @titles_allowed = false if (node.attr 'dita-topic-titles') == 'off'
@@ -61,6 +64,9 @@ class DitaTopic < Asciidoctor::Converter::Base
61
64
  # Check if sidebars are enabled:
62
65
  @sidebars_allowed = false if (node.attr 'dita-topic-sidebars') == 'off'
63
66
 
67
+ # Check if propagating the content type to sections is enabled:
68
+ @type_allowed = true if (node.attr 'dita-topic-type') == 'on'
69
+
64
70
  # Check if the file name is available (it is not for standard input):
65
71
  if node.attr? 'docname'
66
72
  file_name = node.attr 'docname'
@@ -68,13 +74,8 @@ class DitaTopic < Asciidoctor::Converter::Base
68
74
  @file_name = "#{file_name}#{file_suffix}"
69
75
  end
70
76
 
71
- # Check if the modular documentation content type is specified; both
72
- # _module-type and _content-type are deprecated, but still present in
73
- # some modules:
74
- outputclass = ''
75
- outputclass = %( outputclass="#{(node.attr '_module-type').downcase}") if node.attr? '_module-type'
76
- outputclass = %( outputclass="#{(node.attr '_content-type').downcase}") if node.attr? '_content-type'
77
- outputclass = %( outputclass="#{(node.attr '_mod-docs-content-type').downcase}") if node.attr? '_mod-docs-content-type'
77
+ # Check if the modular documentation content type is specified:
78
+ outputclass = compose_type_outputclass node
78
79
 
79
80
  # Open the document:
80
81
  result = ["<?xml version='1.0' encoding='utf-8' ?>"]
@@ -632,9 +633,12 @@ class DitaTopic < Asciidoctor::Converter::Base
632
633
  # Issue a warning if there are nested sections:
633
634
  logger.warn format_message "Nesting of sections not supported in DITA" if node.level > 1
634
635
 
636
+ # Check if the modular documentation content type is specified:
637
+ outputclass = @type_allowed ? compose_type_outputclass(node.document) : ''
638
+
635
639
  # Return the XML output:
636
640
  <<~EOF.chomp
637
- <section#{compose_id node.id}>
641
+ <section#{compose_id node.id}#{outputclass}>
638
642
  <title>#{node.title}</title>
639
643
  #{node.content}
640
644
  </section>
@@ -1007,6 +1011,18 @@ class DitaTopic < Asciidoctor::Converter::Base
1007
1011
  end
1008
1012
  end
1009
1013
 
1014
+ def compose_type_outputclass node
1015
+ # NOTE: _module-type and _content-type are deprecated, but still
1016
+ # present in some modules:
1017
+ outputclass = ''
1018
+ outputclass = %( outputclass="#{(node.attr '_module-type').downcase}") if node.attr? '_module-type'
1019
+ outputclass = %( outputclass="#{(node.attr '_content-type').downcase}") if node.attr? '_content-type'
1020
+ outputclass = %( outputclass="#{(node.attr '_mod-docs-content-type').downcase}") if node.attr? '_mod-docs-content-type'
1021
+
1022
+ # Return the outputclass attribute:
1023
+ return outputclass
1024
+ end
1025
+
1010
1026
  def format_message message
1011
1027
  # Compose the warning or error message:
1012
1028
  file_name = (defined? @file_name) ? %( #{@file_name}:) : ''
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.2.1
4
+ version: 1.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jaromir Hradilek
@@ -103,7 +103,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
103
103
  - !ruby/object:Gem::Version
104
104
  version: '0'
105
105
  requirements: []
106
- rubygems_version: 3.6.7
106
+ rubygems_version: 3.6.9
107
107
  specification_version: 4
108
108
  summary: A custom AsciiDoc converter that generates individual DITA topics
109
109
  test_files: []