asciidoctor-dita-topic 1.0.9 → 1.1.0
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/LICENSE +1 -1
- data/README.adoc +17 -3
- data/lib/dita-topic.rb +75 -18
- 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: 134df897545adafba05f060ea22079c3fa927204b47fff2eec8ffbc8ae5ef84a
|
4
|
+
data.tar.gz: 354b8abadd320b9a4c63b3c170a85974a2231836da07851e1cde58da06aafff3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4b7e9fcd688f450a2e05effca4c30d5969db15d7056cd23b6c1829d6f65de79cc95e0208f5dc543b5bd2f87117aa972f49dcff76963ef8b67879f5a40a97af6f
|
7
|
+
data.tar.gz: 05122aac651d614082cc4cb350197bdbb897d2b7436189eb225a230ffc3f8ad2f3ee5d66f1b882f78bab39d4fd38d18caaeba0d1b5dd965c98ccd7f52a530f97
|
data/LICENSE
CHANGED
data/README.adoc
CHANGED
@@ -80,10 +80,22 @@ $ **asciidoctor -r dita-topic -b dita-topic -a ProductNumber=2 *.adoc**
|
|
80
80
|
....
|
81
81
|
====
|
82
82
|
|
83
|
+
[#authors]
|
84
|
+
=== Enabling author lines
|
85
|
+
|
86
|
+
AsciiDoc topics are expected to be included in other files and therefore should not contain link:https://docs.asciidoctor.org/asciidoc/latest/document/author-line/[author line] definitions. In most cases, lines that directly follow the topic title are intended as first paragraphs. For this reason, author lines are disabled by default. To avoid losing content during conversion, as a workaround, the `dita-topic` converter interprets the raw content of the author line as a paragraph and issues a warning.
|
87
|
+
|
88
|
+
To enable processing of author lines as metadata, set the value of the `dita-topic-authors` to `on`:
|
89
|
+
|
90
|
+
[literal,subs="+quotes"]
|
91
|
+
....
|
92
|
+
$ **asciidoctor -r dita-topic -b dita-topic -a dita-topic-authors=on _your_file_.adoc**
|
93
|
+
....
|
94
|
+
|
83
95
|
[#titles]
|
84
96
|
=== Disabling floating titles
|
85
97
|
|
86
|
-
Unlike AsciiDoc, DITA does not support floating titles and only allows titles to be assigned to a limited number of elements. To avoid losing content during
|
98
|
+
Unlike AsciiDoc, DITA does not support floating titles and only allows titles to be assigned to a limited number of elements. To avoid losing content during conversion, as a workaround, the `dita-topic` converter uses the following markup by default:
|
87
99
|
|
88
100
|
[source,xml]
|
89
101
|
----
|
@@ -100,7 +112,7 @@ $ **asciidoctor -r dita-topic -b dita-topic -a dita-topic-titles=off _your_file_
|
|
100
112
|
[#callouts]
|
101
113
|
=== Disabling callouts
|
102
114
|
|
103
|
-
Unlike AsciiDoc, DITA does not support callouts as a method to add annotations to specific lines in verbatim blocks. To avoid losing content during
|
115
|
+
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.
|
104
116
|
|
105
117
|
To disable this behavior, set the value of the `dita-topic-callouts` to `off`:
|
106
118
|
|
@@ -136,6 +148,8 @@ Admonition titles not supported in DITA:: AsciiDoc allows you to add a custom ti
|
|
136
148
|
|
137
149
|
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.
|
138
150
|
|
151
|
+
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.
|
152
|
+
|
139
153
|
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.
|
140
154
|
|
141
155
|
Callouts not supported in DITA:: AsciiDoc allows you to use `<1>`, `<2>`, `<3>` and so on in verbatim blocks to add annotations to the specific lines. Unlike AsciiDoc, DITA does not provide a direct equivalent for this functionality. `dita-topic` issues this warning when the `-a dita-topic-callouts=off` option is specified and these annotations are present in the converted AsciiDoc file.
|
@@ -161,6 +175,6 @@ Video macro not supported:: AsciiDoc allows you to embed video content in your d
|
|
161
175
|
[#copyright]
|
162
176
|
== Copyright
|
163
177
|
|
164
|
-
Copyright (C) 2024 Jaromir Hradilek
|
178
|
+
Copyright (C) 2024, 2025 Jaromir Hradilek
|
165
179
|
|
166
180
|
This program is free software, released under the terms of the link:LICENSE[MIT license]. It is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
data/lib/dita-topic.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# A custom AsciiDoc converter that generates individual DITA topics
|
2
|
-
# Copyright (C) 2024 Jaromir Hradilek
|
2
|
+
# Copyright (C) 2024, 2025 Jaromir Hradilek
|
3
3
|
|
4
4
|
# MIT License
|
5
5
|
#
|
@@ -33,34 +33,70 @@ class DitaTopic < Asciidoctor::Converter::Base
|
|
33
33
|
super
|
34
34
|
outfilesuffix '.dita'
|
35
35
|
|
36
|
-
#
|
37
|
-
@
|
36
|
+
# Disable the author line by default:
|
37
|
+
@authors_allowed = false
|
38
38
|
|
39
39
|
# Enable callouts by default:
|
40
40
|
@callouts_allowed = true
|
41
|
+
|
42
|
+
# Enable floating and block titles by default:
|
43
|
+
@titles_allowed = true
|
41
44
|
end
|
42
45
|
|
43
46
|
def convert_document node
|
44
|
-
# Check if
|
45
|
-
@
|
47
|
+
# Check if the author line is enabled:
|
48
|
+
@authors_allowed = true if (node.attr 'dita-topic-authors') == 'on'
|
46
49
|
|
47
50
|
# Check if callouts are enabled:
|
48
51
|
@callouts_allowed = false if (node.attr 'dita-topic-callouts') == 'off'
|
49
52
|
|
53
|
+
# Check if floating and block titles are enabled:
|
54
|
+
@titles_allowed = false if (node.attr 'dita-topic-titles') == 'off'
|
55
|
+
|
50
56
|
# Check if the modular documentation content type is specified:
|
51
|
-
outputclass =
|
57
|
+
outputclass = ''
|
58
|
+
outputclass = %( outputclass="#{(node.attr '_content-type').downcase}") if node.attr? '_content-type'
|
59
|
+
outputclass = %( outputclass="#{(node.attr '_mod-docs-content-type').downcase}") if node.attr? '_mod-docs-content-type'
|
60
|
+
|
61
|
+
# Open the document:
|
62
|
+
result = ["<?xml version='1.0' encoding='utf-8' ?>"]
|
63
|
+
result << %(<!DOCTYPE topic PUBLIC "-//OASIS//DTD DITA Topic//EN" "topic.dtd">)
|
64
|
+
result << %(<topic#{compose_id (node.id or node.attributes['docname'])}#{outputclass}>)
|
65
|
+
result << %(<title>#{node.doctitle}</title>)
|
66
|
+
|
67
|
+
# Check if the author line is enabled and defined:
|
68
|
+
if @authors_allowed && !node.authors.empty?
|
69
|
+
# Open the prolog:
|
70
|
+
result << %(<prolog>)
|
71
|
+
|
72
|
+
# Process individual author names:
|
73
|
+
node.authors.each do |author|
|
74
|
+
result << %(<author>#{compose_author author, node}</author>)
|
75
|
+
end
|
76
|
+
|
77
|
+
# Close the prolog:
|
78
|
+
result << %(</prolog>)
|
79
|
+
end
|
80
|
+
|
81
|
+
# Open the document body:
|
82
|
+
result << %(<body>)
|
83
|
+
|
84
|
+
# Check if the author line defined while disabled:
|
85
|
+
if !@authors_allowed && !node.authors.empty?
|
86
|
+
# Issue a warning as inline content is not going to be processed:
|
87
|
+
logger.warn "#{NAME}: Author lines not enabled for topics"
|
88
|
+
|
89
|
+
# Process the author line as a plain paragraph:
|
90
|
+
result << %(<p>#{node.authors.map {|author| compose_author author, node}.join('; ')}</p>)
|
91
|
+
end
|
92
|
+
|
93
|
+
# Close the document body:
|
94
|
+
result << node.content
|
95
|
+
result << %(</body>)
|
96
|
+
result << %(</topic>)
|
52
97
|
|
53
98
|
# Return the XML output:
|
54
|
-
|
55
|
-
<?xml version='1.0' encoding='utf-8' ?>
|
56
|
-
<!DOCTYPE topic PUBLIC "-//OASIS//DTD DITA Topic//EN" "topic.dtd">
|
57
|
-
<topic#{compose_id (node.id or node.attributes['docname'])}#{outputclass}>
|
58
|
-
<title>#{node.doctitle}</title>
|
59
|
-
<body>
|
60
|
-
#{node.content}
|
61
|
-
</body>
|
62
|
-
</topic>
|
63
|
-
EOF
|
99
|
+
result.join LF
|
64
100
|
end
|
65
101
|
|
66
102
|
def convert_admonition node
|
@@ -434,9 +470,24 @@ class DitaTopic < Asciidoctor::Converter::Base
|
|
434
470
|
add_block_title (result.join LF), node.title
|
435
471
|
end
|
436
472
|
|
437
|
-
# FIXME: This is not the top priority.
|
438
473
|
def convert_open node
|
439
|
-
|
474
|
+
# NOTE: Although DITA provides an <abstract> element that is intended
|
475
|
+
# for this purpose, it is placed alongside the <body> element and not
|
476
|
+
# inside of ot. As there is no clean way to place it there, I use
|
477
|
+
# a workaround.
|
478
|
+
|
479
|
+
# Determine the node type:
|
480
|
+
if node.style == 'partintro'
|
481
|
+
node.content
|
482
|
+
elsif node.content_model == :compound
|
483
|
+
<<~EOF.chomp
|
484
|
+
<div#{(node.style == 'abstract') ? ' outputclass="abstract"' : ''}>
|
485
|
+
#{compose_floating_title node.title}#{node.content}
|
486
|
+
</div>
|
487
|
+
EOF
|
488
|
+
else
|
489
|
+
%(#{compose_floating_title node.title}<p#{(node.style == 'abstract') ? ' outputclass="abstract"' : ''}>#{node.content}</p>)
|
490
|
+
end
|
440
491
|
end
|
441
492
|
|
442
493
|
def convert_page_break node
|
@@ -787,6 +838,12 @@ class DitaTopic < Asciidoctor::Converter::Base
|
|
787
838
|
EOF
|
788
839
|
end
|
789
840
|
|
841
|
+
def compose_author author, node
|
842
|
+
name = node.sub_replacements author.name
|
843
|
+
mail = %( <#{node.sub_replacements author.email}>) if author.email
|
844
|
+
return %(#{name}#{mail})
|
845
|
+
end
|
846
|
+
|
790
847
|
def compose_floating_title title
|
791
848
|
# NOTE: Unlike AsciiDoc, DITA does not support floating titles or
|
792
849
|
# titles assigned to certain block elements. As a workaround, I decided
|
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.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jaromir Hradilek
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-02-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: asciidoctor
|