asciidoctor-dita-topic 1.1.9 → 1.2.1
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 +5 -4
- data/lib/dita-topic.rb +79 -27
- 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: 648f69ba5e5ada330dd2f74e5b6421d37e74a5a87e74d8fcce2a06361cf4f356
|
4
|
+
data.tar.gz: 3ba982932cab3253139ec969449584214db56e638f0bce7b1893685eeded2aed
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6aed474f0fdda4e30e85ae64cd8d2c532b6646d93713584bdffef7b00e875c2b9f12c94eae7c5c00ca00a364415fcb7d6a9da581eed88b036072f010a5de6b39
|
7
|
+
data.tar.gz: 214b99142e2ca90f6e0ad5e5baf42de415127977cf585ca04017db57213c47cccbc2261a9a61a66e9f315d922210020d1c3f165233f4c904d6d1542452f270bd
|
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
|
|
@@ -222,8 +227,6 @@ This possible warning messages are as follows:
|
|
222
227
|
[horizontal]
|
223
228
|
Admonition titles not supported in DITA:: AsciiDoc allows you to add a custom title to any admonition by including `._Admonition title_` on the line above it. Unlike AsciiDoc, DITA does not allow titles for admonitions. `dita-topic` issues this warning whenever an admonition has a title defined in the converted AsciiDoc file.
|
224
229
|
|
225
|
-
Audio macro not supported:: AsciiDoc allows you to embed audio content in your documents by using the `audio::__audio_file__[]` macro. `dita-topic` does not implement this feature and issues this warning whenever the `audio` macro is present in the converted AsciiDoc file.
|
226
|
-
|
227
230
|
Author lines not enabled for topics:: AsciiDoc interprets the first line that directly follows the document title as an author line. Because topics are not expected to have author lines, `dita-topic` issues this warning when an author line is present in the converted AsciiDoc file.
|
228
231
|
|
229
232
|
Block titles not supported in DITA:: AsciiDoc allows you to include `._Block title_` on the line above most of the block elements to assign a custom title to them. Unlike AsciiDoc, DITA only allows titles to be assigned to a limited number of elements. `dita-topic` issues this warning when the `-a dita-topic-titles=off` option is specified and a block title is present in the converted AsciiDoc file.
|
@@ -250,8 +253,6 @@ Table footers not supported in DITA:: AsciiDoc allows you to set the `footer` op
|
|
250
253
|
|
251
254
|
Thematic breaks not supported in DITA:: Asciidoc allows you to use `'''`, `---`, or `\***` (the last two with possible optional spaces in between the characters) to insert a thematic break in between two blocks, most commonly represented by a horizontal line. Unlike AsciiDoc, DITA does not support thematic breaks. `dita-topic` issues this warning whenever a thematic break is present in the converted AsciiDoc file.
|
252
255
|
|
253
|
-
Video macro not supported:: AsciiDoc allows you to embed video content in your documents by using the `video::__video_file__[]` macro. `dita-topic` does not implement this feature and issues this warning whenever the `video` macro is present in the converted AsciiDoc file.
|
254
|
-
|
255
256
|
[#copyright]
|
256
257
|
== Copyright
|
257
258
|
|
data/lib/dita-topic.rb
CHANGED
@@ -61,6 +61,13 @@ class DitaTopic < Asciidoctor::Converter::Base
|
|
61
61
|
# Check if sidebars are enabled:
|
62
62
|
@sidebars_allowed = false if (node.attr 'dita-topic-sidebars') == 'off'
|
63
63
|
|
64
|
+
# Check if the file name is available (it is not for standard input):
|
65
|
+
if node.attr? 'docname'
|
66
|
+
file_name = node.attr 'docname'
|
67
|
+
file_suffix = (node.attr? 'docfilesuffix') ? (node.attr 'docfilesuffix') : ''
|
68
|
+
@file_name = "#{file_name}#{file_suffix}"
|
69
|
+
end
|
70
|
+
|
64
71
|
# Check if the modular documentation content type is specified; both
|
65
72
|
# _module-type and _content-type are deprecated, but still present in
|
66
73
|
# some modules:
|
@@ -95,7 +102,7 @@ class DitaTopic < Asciidoctor::Converter::Base
|
|
95
102
|
# Check if the author line defined while disabled:
|
96
103
|
if !@authors_allowed && !node.authors.empty?
|
97
104
|
# Issue a warning as inline content is not going to be processed:
|
98
|
-
logger.warn "
|
105
|
+
logger.warn format_message "Author lines not enabled for topics"
|
99
106
|
|
100
107
|
# Process the author line as a plain paragraph:
|
101
108
|
result << %(<p>#{node.authors.map {|author| compose_author author, node}.join('; ')}</p>)
|
@@ -117,7 +124,7 @@ class DitaTopic < Asciidoctor::Converter::Base
|
|
117
124
|
|
118
125
|
# Issue a warning if the admonition has a title:
|
119
126
|
if node.title?
|
120
|
-
logger.warn "
|
127
|
+
logger.warn format_message "Admonition titles not supported in DITA"
|
121
128
|
end
|
122
129
|
|
123
130
|
# Return the XML output:
|
@@ -129,15 +136,22 @@ class DitaTopic < Asciidoctor::Converter::Base
|
|
129
136
|
end
|
130
137
|
|
131
138
|
def convert_audio node
|
132
|
-
#
|
133
|
-
|
134
|
-
|
139
|
+
# Check if the audio macro has a title specified:
|
140
|
+
if node.title?
|
141
|
+
<<~EOF.chomp
|
142
|
+
<object data="#{node.media_uri(node.attr 'target')}">
|
143
|
+
<desc>#{node.title}</desc>
|
144
|
+
</object>
|
145
|
+
EOF
|
146
|
+
else
|
147
|
+
%(<object data="#{node.media_uri(node.attr 'target')}" />)
|
148
|
+
end
|
135
149
|
end
|
136
150
|
|
137
151
|
def convert_colist node
|
138
152
|
# Issue a warning if callouts are disabled:
|
139
153
|
unless @callouts_allowed
|
140
|
-
logger.warn "
|
154
|
+
logger.warn format_message "Callouts not supported in DITA"
|
141
155
|
return ''
|
142
156
|
end
|
143
157
|
|
@@ -224,7 +238,7 @@ class DitaTopic < Asciidoctor::Converter::Base
|
|
224
238
|
def convert_example node
|
225
239
|
# Issue a warning if the example is nested:
|
226
240
|
if (parent = node.parent.context) != :document && parent != :preamble
|
227
|
-
logger.warn "
|
241
|
+
logger.warn format_message "Examples not supported within #{parent} in DITA"
|
228
242
|
end
|
229
243
|
|
230
244
|
# Return the XML output:
|
@@ -242,7 +256,7 @@ class DitaTopic < Asciidoctor::Converter::Base
|
|
242
256
|
|
243
257
|
# Issue a warning if floating titles are disabled:
|
244
258
|
unless @titles_allowed
|
245
|
-
logger.warn "
|
259
|
+
logger.warn format_message "Floating titles not supported in DITA"
|
246
260
|
return ''
|
247
261
|
end
|
248
262
|
|
@@ -296,7 +310,7 @@ class DitaTopic < Asciidoctor::Converter::Base
|
|
296
310
|
# Determine whether the cross reference links to a file path:
|
297
311
|
if (path = node.attributes['path'])
|
298
312
|
# Issue a warning if the cross reference includes an ID:
|
299
|
-
logger.warn "
|
313
|
+
logger.warn format_message "Possible invalid reference: #{node.target}" if node.target.include? '#'
|
300
314
|
|
301
315
|
# Compose a cross reference:
|
302
316
|
return %(<xref href="#{node.target}">#{node.text || path}</xref>)
|
@@ -315,7 +329,7 @@ class DitaTopic < Asciidoctor::Converter::Base
|
|
315
329
|
end
|
316
330
|
|
317
331
|
# Issue a warning as the cross reference is unlikely to work:
|
318
|
-
logger.warn "
|
332
|
+
logger.warn format_message "Possible invalid reference: #{node.target}"
|
319
333
|
|
320
334
|
# Compose the cross reference:
|
321
335
|
node.text ? %(<xref href="#{node.target}">#{node.text}</xref>) : %(<xref href="#{node.target}" />)
|
@@ -337,7 +351,7 @@ class DitaTopic < Asciidoctor::Converter::Base
|
|
337
351
|
%(<i id="#{node.id}" />[#{node.reftext || node.id}])
|
338
352
|
else
|
339
353
|
# Issue a warning if an unknown anchor type is present:
|
340
|
-
logger.warn "
|
354
|
+
logger.warn format_message "Unknown anchor type: #{node.type}"
|
341
355
|
''
|
342
356
|
end
|
343
357
|
end
|
@@ -346,7 +360,7 @@ class DitaTopic < Asciidoctor::Converter::Base
|
|
346
360
|
# NOTE: Unlike AsciiDoc, DITA does not support inline line breaks.
|
347
361
|
|
348
362
|
# Issue a warning if an inline line break is present:
|
349
|
-
logger.warn "
|
363
|
+
logger.warn format_message "Inline breaks not supported in DITA"
|
350
364
|
|
351
365
|
# Return the XML output:
|
352
366
|
%(#{node.text}<!-- break -->)
|
@@ -359,7 +373,7 @@ class DitaTopic < Asciidoctor::Converter::Base
|
|
359
373
|
def convert_inline_callout node
|
360
374
|
# Issue a warning if callouts are disabled:
|
361
375
|
unless @callouts_allowed
|
362
|
-
logger.warn "
|
376
|
+
logger.warn format_message "Callouts not supported in DITA"
|
363
377
|
return ''
|
364
378
|
end
|
365
379
|
|
@@ -474,13 +488,13 @@ class DitaTopic < Asciidoctor::Converter::Base
|
|
474
488
|
%(‘#{node.text}’)
|
475
489
|
when :asciimath
|
476
490
|
# Issue a warning if a STEM content is present:
|
477
|
-
logger.warn "
|
491
|
+
logger.warn format_message "STEM support not implemented"
|
478
492
|
|
479
493
|
# Add comments around the STEM content:
|
480
494
|
%(<!-- asciimath start -->#{node.text}<!-- asciimath end -->)
|
481
495
|
when :latexmath
|
482
496
|
# Issue a warning if a STEM content is present:
|
483
|
-
logger.warn "
|
497
|
+
logger.warn format_message "STEM support not implemented"
|
484
498
|
|
485
499
|
# Add comments around the STEM content:
|
486
500
|
%(<!-- latexmath start -->#{node.text}<!-- latexmath end -->)
|
@@ -563,7 +577,7 @@ class DitaTopic < Asciidoctor::Converter::Base
|
|
563
577
|
# NOTE: Unlike AsciiDoc, DITA does not support page breaks.
|
564
578
|
|
565
579
|
# Issue a warning if a page break is present:
|
566
|
-
logger.warn "
|
580
|
+
logger.warn format_message "Page breaks not supported in DITA"
|
567
581
|
|
568
582
|
# Return the XML output:
|
569
583
|
%(<p outputclass="page-break"></p>)
|
@@ -616,7 +630,7 @@ class DitaTopic < Asciidoctor::Converter::Base
|
|
616
630
|
# markup.
|
617
631
|
|
618
632
|
# Issue a warning if there are nested sections:
|
619
|
-
logger.warn "
|
633
|
+
logger.warn format_message "Nesting of sections not supported in DITA" if node.level > 1
|
620
634
|
|
621
635
|
# Return the XML output:
|
622
636
|
<<~EOF.chomp
|
@@ -633,7 +647,7 @@ class DitaTopic < Asciidoctor::Converter::Base
|
|
633
647
|
|
634
648
|
# Issue a warning if sidebars are disabled:
|
635
649
|
unless @sidebars_allowed
|
636
|
-
logger.warn "
|
650
|
+
logger.warn format_message "Sidebars not supported in DITA"
|
637
651
|
return ''
|
638
652
|
end
|
639
653
|
|
@@ -655,7 +669,7 @@ class DitaTopic < Asciidoctor::Converter::Base
|
|
655
669
|
|
656
670
|
def convert_stem node
|
657
671
|
# Issue a warning if a STEM content is present:
|
658
|
-
logger.warn "
|
672
|
+
logger.warn format_message "STEM support not implemented"
|
659
673
|
return ''
|
660
674
|
end
|
661
675
|
|
@@ -681,7 +695,7 @@ class DitaTopic < Asciidoctor::Converter::Base
|
|
681
695
|
|
682
696
|
# Issue a warning if a table footer is present:
|
683
697
|
if type == :foot
|
684
|
-
logger.warn "
|
698
|
+
logger.warn format_message "Table footers not supported in DITA"
|
685
699
|
next
|
686
700
|
end
|
687
701
|
|
@@ -743,7 +757,7 @@ class DitaTopic < Asciidoctor::Converter::Base
|
|
743
757
|
# NOTE: Unlike AsciiDoc, DITA does not support thematic breaks.
|
744
758
|
|
745
759
|
# Issue a warning if a thematic break is present:
|
746
|
-
logger.warn "
|
760
|
+
logger.warn format_message "Thematic breaks not supported in DITA"
|
747
761
|
|
748
762
|
# Return the XML output:
|
749
763
|
%(<p outputclass="thematic-break"></p>)
|
@@ -795,9 +809,41 @@ class DitaTopic < Asciidoctor::Converter::Base
|
|
795
809
|
end
|
796
810
|
|
797
811
|
def convert_video node
|
798
|
-
#
|
799
|
-
|
800
|
-
|
812
|
+
# Check if additional attributes are specified:
|
813
|
+
width = (node.attr? 'width') ? %( width="#{node.attr 'width'}") : ''
|
814
|
+
height = (node.attr? 'height') ? %( height="#{node.attr 'height'}") : ''
|
815
|
+
|
816
|
+
# Check if the video is a Vimeo or YouTube video:
|
817
|
+
if (provider = (node.attr 'poster')) == 'youtube'
|
818
|
+
# Separate a playlist from the target:
|
819
|
+
target, list = (node.attr 'target').split '/', 2
|
820
|
+
|
821
|
+
# Check if the playlist is provided as an attribute:
|
822
|
+
if node.attr 'list' and not list
|
823
|
+
list = node.attr 'list'
|
824
|
+
end
|
825
|
+
|
826
|
+
# Compose the playlist URL fragment:
|
827
|
+
list = list ? %(?list=#{list}) : ''
|
828
|
+
|
829
|
+
# Compose the target URL:
|
830
|
+
target_url = %(https://www.youtube.com/embed/#{target}#{list})
|
831
|
+
elsif provider == 'vimeo'
|
832
|
+
target_url = %(https://player.vimeo.com/video/#{node.attr 'target'})
|
833
|
+
else
|
834
|
+
target_url = node.media_uri(node.attr 'target')
|
835
|
+
end
|
836
|
+
|
837
|
+
# Check if the audio macro has a title specified:
|
838
|
+
if node.title?
|
839
|
+
<<~EOF.chomp
|
840
|
+
<object data="#{target_url}"#{width}#{height}>
|
841
|
+
<desc>#{node.title}</desc>
|
842
|
+
</object>
|
843
|
+
EOF
|
844
|
+
else
|
845
|
+
%(<object data="#{target_url}"#{width}#{height} />)
|
846
|
+
end
|
801
847
|
end
|
802
848
|
|
803
849
|
def compose_qanda_dlist node
|
@@ -905,7 +951,7 @@ class DitaTopic < Asciidoctor::Converter::Base
|
|
905
951
|
|
906
952
|
# Issue a warning if block titles are disabled:
|
907
953
|
unless @titles_allowed
|
908
|
-
logger.warn "
|
954
|
+
logger.warn format_message "Block titles not supported in DITA"
|
909
955
|
return content
|
910
956
|
end
|
911
957
|
|
@@ -932,7 +978,7 @@ class DitaTopic < Asciidoctor::Converter::Base
|
|
932
978
|
|
933
979
|
# Issue a warning if floating titles are disabled:
|
934
980
|
unless @titles_allowed
|
935
|
-
logger.warn "
|
981
|
+
logger.warn format_message "Floating titles not supported in DITA"
|
936
982
|
return ''
|
937
983
|
end
|
938
984
|
|
@@ -947,7 +993,7 @@ class DitaTopic < Asciidoctor::Converter::Base
|
|
947
993
|
def compose_circled_number number
|
948
994
|
# Verify the number is in a supported range:
|
949
995
|
if number < 1 || number > 50
|
950
|
-
logger.warn "
|
996
|
+
logger.warn format_message "Callout number not in range between 1 and 50"
|
951
997
|
return number
|
952
998
|
end
|
953
999
|
|
@@ -960,5 +1006,11 @@ class DitaTopic < Asciidoctor::Converter::Base
|
|
960
1006
|
%(&##{12941 + number};)
|
961
1007
|
end
|
962
1008
|
end
|
1009
|
+
|
1010
|
+
def format_message message
|
1011
|
+
# Compose the warning or error message:
|
1012
|
+
file_name = (defined? @file_name) ? %( #{@file_name}:) : ''
|
1013
|
+
%(#{NAME}:#{file_name} #{message})
|
1014
|
+
end
|
963
1015
|
end
|
964
1016
|
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.1
|
4
|
+
version: 1.2.1
|
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.7
|
107
107
|
specification_version: 4
|
108
108
|
summary: A custom AsciiDoc converter that generates individual DITA topics
|
109
109
|
test_files: []
|