asciidoctor-dita-topic 1.2.0 → 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.
- checksums.yaml +4 -4
- data/README.adoc +17 -12
- data/lib/dita-topic.rb +60 -31
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9ef188774cec09940a4fa4f67d8f6f91f69d3e422ba7ce79550c3b2866c7793c
|
4
|
+
data.tar.gz: 359c1f98c2991ef613e8d3a96d4c83c3861a901783633ba709ac5b2f7817c2ab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d7ce10652ecbcb46ba32ccef483cf774bc5f4514bba18fc49de335007bd854fc3d86f865ce52b4475fa9853e6bbfc4efd3389d263f47af57d0d0b754a170cd80
|
7
|
+
data.tar.gz: 2c10449f2d3f5f143215afa730679a17e2bed33096062eafb090af9c928d8fd46c6fe03411b890b9c8801831c0fe2b0c1a67a54f35ef900b05aea89aa4fb2510
|
data/README.adoc
CHANGED
@@ -35,6 +35,11 @@ Install the `asciidoctor-dita-topic` Ruby gem:
|
|
35
35
|
$ *gem install asciidoctor-dita-topic*
|
36
36
|
....
|
37
37
|
|
38
|
+
[IMPORTANT]
|
39
|
+
====
|
40
|
+
On macOS, `asciidoctor` installed with Homebrew expects Ruby gems in a different directory than where `gem install` places them. To work around this issue, you can either link:https://docs.asciidoctor.org/asciidoctor/latest/install/ruby-packaging/#gem-install[install `asciidoctor` as a Ruby gem], or run `asciidoctor` with the `-r` option followed by the relative path to the `dita-topic.rb` file.
|
41
|
+
====
|
42
|
+
|
38
43
|
[#use]
|
39
44
|
== Usage
|
40
45
|
|
@@ -115,6 +120,18 @@ To enable processing of author lines as metadata, set the value of the `dita-top
|
|
115
120
|
$ **asciidoctor -r dita-topic -b dita-topic -a dita-topic-authors=on _your_file_.adoc**
|
116
121
|
....
|
117
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
|
+
|
118
135
|
[#titles]
|
119
136
|
=== Disabling floating titles
|
120
137
|
|
@@ -132,18 +149,6 @@ To disable this behavior, set the value of the `dita-topic-titles` to `off`:
|
|
132
149
|
$ **asciidoctor -r dita-topic -b dita-topic -a dita-topic-titles=off _your_file_.adoc**
|
133
150
|
....
|
134
151
|
|
135
|
-
[#callouts]
|
136
|
-
=== Disabling callouts
|
137
|
-
|
138
|
-
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.
|
139
|
-
|
140
|
-
To disable this behavior, set the value of the `dita-topic-callouts` to `off`:
|
141
|
-
|
142
|
-
[literal,subs="+quotes"]
|
143
|
-
....
|
144
|
-
$ **asciidoctor -r dita-topic -b dita-topic -a dita-topic-callouts=off _your_file_.adoc**
|
145
|
-
....
|
146
|
-
|
147
152
|
[#includes]
|
148
153
|
=== Disabling include directives
|
149
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 =
|
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 =
|
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,13 +64,18 @@ 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
|
|
64
|
-
# Check if the
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
67
|
+
# Check if propagating the content type to sections is enabled:
|
68
|
+
@type_allowed = true if (node.attr 'dita-topic-type') == 'on'
|
69
|
+
|
70
|
+
# Check if the file name is available (it is not for standard input):
|
71
|
+
if node.attr? 'docname'
|
72
|
+
file_name = node.attr 'docname'
|
73
|
+
file_suffix = (node.attr? 'docfilesuffix') ? (node.attr 'docfilesuffix') : ''
|
74
|
+
@file_name = "#{file_name}#{file_suffix}"
|
75
|
+
end
|
76
|
+
|
77
|
+
# Check if the modular documentation content type is specified:
|
78
|
+
outputclass = compose_type_outputclass node
|
71
79
|
|
72
80
|
# Open the document:
|
73
81
|
result = ["<?xml version='1.0' encoding='utf-8' ?>"]
|
@@ -95,7 +103,7 @@ class DitaTopic < Asciidoctor::Converter::Base
|
|
95
103
|
# Check if the author line defined while disabled:
|
96
104
|
if !@authors_allowed && !node.authors.empty?
|
97
105
|
# Issue a warning as inline content is not going to be processed:
|
98
|
-
logger.warn "
|
106
|
+
logger.warn format_message "Author lines not enabled for topics"
|
99
107
|
|
100
108
|
# Process the author line as a plain paragraph:
|
101
109
|
result << %(<p>#{node.authors.map {|author| compose_author author, node}.join('; ')}</p>)
|
@@ -117,7 +125,7 @@ class DitaTopic < Asciidoctor::Converter::Base
|
|
117
125
|
|
118
126
|
# Issue a warning if the admonition has a title:
|
119
127
|
if node.title?
|
120
|
-
logger.warn "
|
128
|
+
logger.warn format_message "Admonition titles not supported in DITA"
|
121
129
|
end
|
122
130
|
|
123
131
|
# Return the XML output:
|
@@ -144,7 +152,7 @@ class DitaTopic < Asciidoctor::Converter::Base
|
|
144
152
|
def convert_colist node
|
145
153
|
# Issue a warning if callouts are disabled:
|
146
154
|
unless @callouts_allowed
|
147
|
-
logger.warn "
|
155
|
+
logger.warn format_message "Callouts not supported in DITA"
|
148
156
|
return ''
|
149
157
|
end
|
150
158
|
|
@@ -231,7 +239,7 @@ class DitaTopic < Asciidoctor::Converter::Base
|
|
231
239
|
def convert_example node
|
232
240
|
# Issue a warning if the example is nested:
|
233
241
|
if (parent = node.parent.context) != :document && parent != :preamble
|
234
|
-
logger.warn "
|
242
|
+
logger.warn format_message "Examples not supported within #{parent} in DITA"
|
235
243
|
end
|
236
244
|
|
237
245
|
# Return the XML output:
|
@@ -249,7 +257,7 @@ class DitaTopic < Asciidoctor::Converter::Base
|
|
249
257
|
|
250
258
|
# Issue a warning if floating titles are disabled:
|
251
259
|
unless @titles_allowed
|
252
|
-
logger.warn "
|
260
|
+
logger.warn format_message "Floating titles not supported in DITA"
|
253
261
|
return ''
|
254
262
|
end
|
255
263
|
|
@@ -303,7 +311,7 @@ class DitaTopic < Asciidoctor::Converter::Base
|
|
303
311
|
# Determine whether the cross reference links to a file path:
|
304
312
|
if (path = node.attributes['path'])
|
305
313
|
# Issue a warning if the cross reference includes an ID:
|
306
|
-
logger.warn "
|
314
|
+
logger.warn format_message "Possible invalid reference: #{node.target}" if node.target.include? '#'
|
307
315
|
|
308
316
|
# Compose a cross reference:
|
309
317
|
return %(<xref href="#{node.target}">#{node.text || path}</xref>)
|
@@ -322,7 +330,7 @@ class DitaTopic < Asciidoctor::Converter::Base
|
|
322
330
|
end
|
323
331
|
|
324
332
|
# Issue a warning as the cross reference is unlikely to work:
|
325
|
-
logger.warn "
|
333
|
+
logger.warn format_message "Possible invalid reference: #{node.target}"
|
326
334
|
|
327
335
|
# Compose the cross reference:
|
328
336
|
node.text ? %(<xref href="#{node.target}">#{node.text}</xref>) : %(<xref href="#{node.target}" />)
|
@@ -344,7 +352,7 @@ class DitaTopic < Asciidoctor::Converter::Base
|
|
344
352
|
%(<i id="#{node.id}" />[#{node.reftext || node.id}])
|
345
353
|
else
|
346
354
|
# Issue a warning if an unknown anchor type is present:
|
347
|
-
logger.warn "
|
355
|
+
logger.warn format_message "Unknown anchor type: #{node.type}"
|
348
356
|
''
|
349
357
|
end
|
350
358
|
end
|
@@ -353,7 +361,7 @@ class DitaTopic < Asciidoctor::Converter::Base
|
|
353
361
|
# NOTE: Unlike AsciiDoc, DITA does not support inline line breaks.
|
354
362
|
|
355
363
|
# Issue a warning if an inline line break is present:
|
356
|
-
logger.warn "
|
364
|
+
logger.warn format_message "Inline breaks not supported in DITA"
|
357
365
|
|
358
366
|
# Return the XML output:
|
359
367
|
%(#{node.text}<!-- break -->)
|
@@ -366,7 +374,7 @@ class DitaTopic < Asciidoctor::Converter::Base
|
|
366
374
|
def convert_inline_callout node
|
367
375
|
# Issue a warning if callouts are disabled:
|
368
376
|
unless @callouts_allowed
|
369
|
-
logger.warn "
|
377
|
+
logger.warn format_message "Callouts not supported in DITA"
|
370
378
|
return ''
|
371
379
|
end
|
372
380
|
|
@@ -481,13 +489,13 @@ class DitaTopic < Asciidoctor::Converter::Base
|
|
481
489
|
%(‘#{node.text}’)
|
482
490
|
when :asciimath
|
483
491
|
# Issue a warning if a STEM content is present:
|
484
|
-
logger.warn "
|
492
|
+
logger.warn format_message "STEM support not implemented"
|
485
493
|
|
486
494
|
# Add comments around the STEM content:
|
487
495
|
%(<!-- asciimath start -->#{node.text}<!-- asciimath end -->)
|
488
496
|
when :latexmath
|
489
497
|
# Issue a warning if a STEM content is present:
|
490
|
-
logger.warn "
|
498
|
+
logger.warn format_message "STEM support not implemented"
|
491
499
|
|
492
500
|
# Add comments around the STEM content:
|
493
501
|
%(<!-- latexmath start -->#{node.text}<!-- latexmath end -->)
|
@@ -570,7 +578,7 @@ class DitaTopic < Asciidoctor::Converter::Base
|
|
570
578
|
# NOTE: Unlike AsciiDoc, DITA does not support page breaks.
|
571
579
|
|
572
580
|
# Issue a warning if a page break is present:
|
573
|
-
logger.warn "
|
581
|
+
logger.warn format_message "Page breaks not supported in DITA"
|
574
582
|
|
575
583
|
# Return the XML output:
|
576
584
|
%(<p outputclass="page-break"></p>)
|
@@ -623,11 +631,14 @@ class DitaTopic < Asciidoctor::Converter::Base
|
|
623
631
|
# markup.
|
624
632
|
|
625
633
|
# Issue a warning if there are nested sections:
|
626
|
-
logger.warn "
|
634
|
+
logger.warn format_message "Nesting of sections not supported in DITA" if node.level > 1
|
635
|
+
|
636
|
+
# Check if the modular documentation content type is specified:
|
637
|
+
outputclass = @type_allowed ? compose_type_outputclass(node.document) : ''
|
627
638
|
|
628
639
|
# Return the XML output:
|
629
640
|
<<~EOF.chomp
|
630
|
-
<section#{compose_id node.id}>
|
641
|
+
<section#{compose_id node.id}#{outputclass}>
|
631
642
|
<title>#{node.title}</title>
|
632
643
|
#{node.content}
|
633
644
|
</section>
|
@@ -640,7 +651,7 @@ class DitaTopic < Asciidoctor::Converter::Base
|
|
640
651
|
|
641
652
|
# Issue a warning if sidebars are disabled:
|
642
653
|
unless @sidebars_allowed
|
643
|
-
logger.warn "
|
654
|
+
logger.warn format_message "Sidebars not supported in DITA"
|
644
655
|
return ''
|
645
656
|
end
|
646
657
|
|
@@ -662,7 +673,7 @@ class DitaTopic < Asciidoctor::Converter::Base
|
|
662
673
|
|
663
674
|
def convert_stem node
|
664
675
|
# Issue a warning if a STEM content is present:
|
665
|
-
logger.warn "
|
676
|
+
logger.warn format_message "STEM support not implemented"
|
666
677
|
return ''
|
667
678
|
end
|
668
679
|
|
@@ -688,7 +699,7 @@ class DitaTopic < Asciidoctor::Converter::Base
|
|
688
699
|
|
689
700
|
# Issue a warning if a table footer is present:
|
690
701
|
if type == :foot
|
691
|
-
logger.warn "
|
702
|
+
logger.warn format_message "Table footers not supported in DITA"
|
692
703
|
next
|
693
704
|
end
|
694
705
|
|
@@ -750,7 +761,7 @@ class DitaTopic < Asciidoctor::Converter::Base
|
|
750
761
|
# NOTE: Unlike AsciiDoc, DITA does not support thematic breaks.
|
751
762
|
|
752
763
|
# Issue a warning if a thematic break is present:
|
753
|
-
logger.warn "
|
764
|
+
logger.warn format_message "Thematic breaks not supported in DITA"
|
754
765
|
|
755
766
|
# Return the XML output:
|
756
767
|
%(<p outputclass="thematic-break"></p>)
|
@@ -944,7 +955,7 @@ class DitaTopic < Asciidoctor::Converter::Base
|
|
944
955
|
|
945
956
|
# Issue a warning if block titles are disabled:
|
946
957
|
unless @titles_allowed
|
947
|
-
logger.warn "
|
958
|
+
logger.warn format_message "Block titles not supported in DITA"
|
948
959
|
return content
|
949
960
|
end
|
950
961
|
|
@@ -971,7 +982,7 @@ class DitaTopic < Asciidoctor::Converter::Base
|
|
971
982
|
|
972
983
|
# Issue a warning if floating titles are disabled:
|
973
984
|
unless @titles_allowed
|
974
|
-
logger.warn "
|
985
|
+
logger.warn format_message "Floating titles not supported in DITA"
|
975
986
|
return ''
|
976
987
|
end
|
977
988
|
|
@@ -986,7 +997,7 @@ class DitaTopic < Asciidoctor::Converter::Base
|
|
986
997
|
def compose_circled_number number
|
987
998
|
# Verify the number is in a supported range:
|
988
999
|
if number < 1 || number > 50
|
989
|
-
logger.warn "
|
1000
|
+
logger.warn format_message "Callout number not in range between 1 and 50"
|
990
1001
|
return number
|
991
1002
|
end
|
992
1003
|
|
@@ -999,5 +1010,23 @@ class DitaTopic < Asciidoctor::Converter::Base
|
|
999
1010
|
%(&##{12941 + number};)
|
1000
1011
|
end
|
1001
1012
|
end
|
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
|
+
|
1026
|
+
def format_message message
|
1027
|
+
# Compose the warning or error message:
|
1028
|
+
file_name = (defined? @file_name) ? %( #{@file_name}:) : ''
|
1029
|
+
%(#{NAME}:#{file_name} #{message})
|
1030
|
+
end
|
1002
1031
|
end
|
1003
1032
|
end
|
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.2.
|
4
|
+
version: 1.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jaromir Hradilek
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date:
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: asciidoctor
|
@@ -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.
|
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: []
|