asciidoctor-dita-topic 1.1.1 → 1.1.3
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 +4 -4
- data/README.adoc +13 -1
- data/lib/dita-topic.rb +38 -25
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 26ce0f384369b685c43454ec161ac81cdd99c630c85bef52d16e0cff55423166
|
4
|
+
data.tar.gz: ba0257aa9f21b1f958e07103ecc9c7bd5476bf02038c0110feeb8c8c0fc36731
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bf9814f61b806557250d29b32cf5ae640cf4345a9e5657a856ce4173de9cbdbc1a2a89a4295a528a82d073f4ccae11a3b321e00902531ed9c18256f8dd6472f9
|
7
|
+
data.tar.gz: c0693f56fccd42fdc39813a676ca5475670bd7aa5e4a3a5ecb71d45e140d2bfb8861bc093fa6334af3bb4c1f20fafc143237f03557fda52f816a9b055b0b4459
|
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[
|
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
|
|
@@ -133,42 +142,36 @@ class DitaTopic < Asciidoctor::Converter::Base
|
|
133
142
|
# Reset the counter:
|
134
143
|
number = 0
|
135
144
|
|
136
|
-
# Open the
|
137
|
-
result = ['<
|
138
|
-
result << %(<tgroup cols="2">)
|
139
|
-
result << %(<colspec colwidth="15*" />)
|
140
|
-
result << %(<colspec colwidth="85*" />)
|
141
|
-
result << %(<tbody>)
|
145
|
+
# Open the definition list:
|
146
|
+
result = ['<dl outputclass="callout-list">']
|
142
147
|
|
143
148
|
# Process individual list items:
|
144
149
|
node.items.each do |item|
|
145
150
|
# Increment the counter:
|
146
151
|
number += 1
|
147
152
|
|
148
|
-
# Open the
|
149
|
-
result << %(<
|
153
|
+
# Open the definition entry:
|
154
|
+
result << %(<dlentry>)
|
150
155
|
|
151
156
|
# Compose the callout number:
|
152
|
-
result << %(<
|
157
|
+
result << %(<dt>#{compose_circled_number number}</dt>)
|
153
158
|
|
154
159
|
# Check if description contains multiple block elements:
|
155
160
|
if item.blocks
|
156
|
-
result << %(<
|
157
|
-
result <<
|
161
|
+
result << %(<dd>)
|
162
|
+
result << item.text
|
158
163
|
result << item.content
|
159
|
-
result << %(</
|
164
|
+
result << %(</dd>)
|
160
165
|
else
|
161
166
|
result << %(<entry>#{item.text}</entry>)
|
162
167
|
end
|
163
168
|
|
164
|
-
# Close the
|
165
|
-
result << %(</
|
169
|
+
# Close the definition entry:
|
170
|
+
result << %(</dlentry>)
|
166
171
|
end
|
167
172
|
|
168
|
-
# Close the
|
169
|
-
result << %(</
|
170
|
-
result << %(</tgroup>)
|
171
|
-
result << %(</table>)
|
173
|
+
# Close the definition list:
|
174
|
+
result << %(</dl>)
|
172
175
|
|
173
176
|
# Return the XML output:
|
174
177
|
result.join LF
|
@@ -239,12 +242,16 @@ class DitaTopic < Asciidoctor::Converter::Base
|
|
239
242
|
%(<p outputclass="title sect#{node.level}"><b>#{node.title}</b></p>)
|
240
243
|
end
|
241
244
|
|
242
|
-
def convert_image
|
245
|
+
def convert_image node
|
243
246
|
# Check if additional attributes are specified:
|
244
247
|
width = (node.attr? 'width') ? %( width="#{node.attr 'width'}") : ''
|
245
248
|
height = (node.attr? 'height') ? %( height="#{node.attr 'height'}") : ''
|
246
249
|
scale = (node.attr? 'scale') ? %( scale="#{(node.attr 'scale').tr('%', '')}") : ''
|
247
250
|
|
251
|
+
# Exclude width and height attributes with percentage values:
|
252
|
+
width = '' if width.include? '%'
|
253
|
+
height = '' if height.include? '%'
|
254
|
+
|
248
255
|
# Check if the image has a title specified:
|
249
256
|
if node.title?
|
250
257
|
<<~EOF.chomp
|
@@ -356,6 +363,10 @@ class DitaTopic < Asciidoctor::Converter::Base
|
|
356
363
|
width = (node.attr? 'width') ? %( width="#{node.attr 'width'}") : ''
|
357
364
|
height = (node.attr? 'height') ? %( height="#{node.attr 'height'}") : ''
|
358
365
|
|
366
|
+
# Exclude width and height attributes with percentage values:
|
367
|
+
width = '' if width.include? '%'
|
368
|
+
height = '' if height.include? '%'
|
369
|
+
|
359
370
|
# Return the XML output:
|
360
371
|
%(<image href="#{node.image_uri node.target}"#{width}#{height} placement="inline"><alt>#{node.alt}</alt></image>)
|
361
372
|
end
|
@@ -460,8 +471,7 @@ class DitaTopic < Asciidoctor::Converter::Base
|
|
460
471
|
node.items.each do |item|
|
461
472
|
# Check if the list item contains multiple block elements:
|
462
473
|
if item.blocks?
|
463
|
-
result << %(<li
|
464
|
-
result << %(<p>#{item.text}</p>)
|
474
|
+
result << %(<li>#{item.text})
|
465
475
|
result << item.content
|
466
476
|
result << %(</li>)
|
467
477
|
else
|
@@ -507,7 +517,11 @@ class DitaTopic < Asciidoctor::Converter::Base
|
|
507
517
|
end
|
508
518
|
|
509
519
|
def convert_paragraph node
|
510
|
-
|
520
|
+
if @abstracts_allowed and (node.attr 'role') == '_abstract'
|
521
|
+
add_block_title %(<p outputclass="abstract">#{node.content}</p>), node.title
|
522
|
+
else
|
523
|
+
add_block_title %(<p>#{node.content}</p>), node.title
|
524
|
+
end
|
511
525
|
end
|
512
526
|
|
513
527
|
def convert_preamble node
|
@@ -691,8 +705,7 @@ class DitaTopic < Asciidoctor::Converter::Base
|
|
691
705
|
|
692
706
|
# Check if the list item contains multiple block elements:
|
693
707
|
if item.blocks?
|
694
|
-
result << %(<li
|
695
|
-
result << %(<p>#{check_box}#{item.text}</p>)
|
708
|
+
result << %(<li>#{check_box}#{item.text})
|
696
709
|
result << item.content
|
697
710
|
result << %(</li>)
|
698
711
|
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.
|
4
|
+
version: 1.1.3
|
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-03-
|
11
|
+
date: 2025-03-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: asciidoctor
|