asciidoctor-dita-topic 1.5.0 → 1.5.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 +9 -5
- data/lib/dita-topic/cli.rb +4 -0
- data/lib/dita-topic/version.rb +1 -1
- data/lib/dita-topic.rb +39 -8
- 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: b79eb2b45f900b9cbee57c173d9aa79db84d7f04a53bbe7deb6ecc43f9c8bf18
|
|
4
|
+
data.tar.gz: 54894c1f9bd28473f96dc1e2918753851243c4b27f56e333c8fb7d1e2c48e7c3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2e800a3d97ddff033a24fa183a76ba10418053477417486156cf41887d958de4f315e1e67caaaec4315d507377e14d62cb6eca5fdc2c1bc44585ef142c26d2ef
|
|
7
|
+
data.tar.gz: 7f989fe3f2704b87240446362e9bba85fe3eb6f03d25cc478e4bd17494101dc2314d6c9e6a96f2a6305d7792e44bca4960e078123cc54e5b99413229233d42ae
|
data/README.adoc
CHANGED
|
@@ -312,19 +312,23 @@ DITA provides four metadata attributes that can be used for conditional processi
|
|
|
312
312
|
| DITA Attribute
|
|
313
313
|
| Description
|
|
314
314
|
|
|
315
|
-
| `platform:__value__`
|
|
315
|
+
| `platform:__value__` +
|
|
316
|
+
`pl:__value__`
|
|
316
317
|
| `platform="_value_"`
|
|
317
318
|
| Operating system or hardware architecture.
|
|
318
319
|
|
|
319
|
-
| `product:__value__`
|
|
320
|
+
| `product:__value__` +
|
|
321
|
+
`pr:__value__`
|
|
320
322
|
| `product="_value_"`
|
|
321
323
|
| Product name.
|
|
322
324
|
|
|
323
|
-
| `audience:__value__`
|
|
325
|
+
| `audience:__value__` +
|
|
326
|
+
`au:__value__`
|
|
324
327
|
| `audience="_value_"`
|
|
325
328
|
| Target audience.
|
|
326
329
|
|
|
327
|
-
| `otherprops:__value__`
|
|
330
|
+
| `otherprops:__value__` +
|
|
331
|
+
`op:__value__`
|
|
328
332
|
| `otherprops="_value_"`
|
|
329
333
|
| Additional properties.
|
|
330
334
|
|===
|
|
@@ -333,7 +337,7 @@ For example, to indicate that a particular paragraph is relevant for Linux and m
|
|
|
333
337
|
|
|
334
338
|
[source,asciidoc]
|
|
335
339
|
----
|
|
336
|
-
[role="
|
|
340
|
+
[role="pl:linux pl:mac au:beginner"]
|
|
337
341
|
For more information, see the *bash*(1) manual page.
|
|
338
342
|
----
|
|
339
343
|
|
data/lib/dita-topic/cli.rb
CHANGED
|
@@ -103,6 +103,10 @@ module AsciidoctorDitaTopic
|
|
|
103
103
|
@attr.append 'dita-topic-titles=off'
|
|
104
104
|
end
|
|
105
105
|
|
|
106
|
+
opt.on('-B', '--no-spaces', 'disable non-breaking spaces in titles') do
|
|
107
|
+
@attr.append 'dita-topic-spaces=off'
|
|
108
|
+
end
|
|
109
|
+
|
|
106
110
|
opt.separator ''
|
|
107
111
|
|
|
108
112
|
opt.on('-h', '--help', 'display this help and exit') do
|
data/lib/dita-topic/version.rb
CHANGED
data/lib/dita-topic.rb
CHANGED
|
@@ -52,6 +52,9 @@ class DitaTopic < Asciidoctor::Converter::Base
|
|
|
52
52
|
|
|
53
53
|
# Disable propagating the content type to sections by default:
|
|
54
54
|
@type_allowed = false
|
|
55
|
+
|
|
56
|
+
# Enable non-breaking spaces in titles by default:
|
|
57
|
+
@spaces_allowed = true
|
|
55
58
|
end
|
|
56
59
|
|
|
57
60
|
def convert_document node
|
|
@@ -73,6 +76,9 @@ class DitaTopic < Asciidoctor::Converter::Base
|
|
|
73
76
|
# Check if propagating the content type to sections is enabled:
|
|
74
77
|
@type_allowed = true if (node.attr 'dita-topic-type') == 'on'
|
|
75
78
|
|
|
79
|
+
# Check if non-breaking spaces in titles are enabled:
|
|
80
|
+
@spaces_allowed = false if (node.attr 'dita-topic-spaces') == 'off'
|
|
81
|
+
|
|
76
82
|
# Check if the file name is available (it is not for standard input):
|
|
77
83
|
if node.attr? 'docname'
|
|
78
84
|
file_name = node.attr 'docname'
|
|
@@ -87,7 +93,7 @@ class DitaTopic < Asciidoctor::Converter::Base
|
|
|
87
93
|
result = ["<?xml version='1.0' encoding='utf-8' ?>"]
|
|
88
94
|
result << %(<!DOCTYPE topic PUBLIC "-//OASIS//DTD DITA Topic//EN" "topic.dtd">)
|
|
89
95
|
result << %(<topic#{compose_id (node.id or node.attributes['docname'] or 'topic-'+SecureRandom.uuid)}#{outputclass}>)
|
|
90
|
-
result << %(<title>#{node.doctitle}</title>)
|
|
96
|
+
result << %(<title>#{replace_spaces node.doctitle}</title>)
|
|
91
97
|
|
|
92
98
|
# Check if the author line is enabled and defined:
|
|
93
99
|
if @authors_allowed && !node.authors.empty?
|
|
@@ -252,7 +258,7 @@ class DitaTopic < Asciidoctor::Converter::Base
|
|
|
252
258
|
# Return the XML output:
|
|
253
259
|
<<~EOF.chomp
|
|
254
260
|
<example#{compose_id node.id}#{compose_metadata node.role}>
|
|
255
|
-
#{node.title ? %(<title>#{node.title}</title>\n) : ''}#{node.content}
|
|
261
|
+
#{node.title ? %(<title>#{replace_spaces node.title}</title>\n) : ''}#{node.content}
|
|
256
262
|
</example>
|
|
257
263
|
EOF
|
|
258
264
|
end
|
|
@@ -286,7 +292,7 @@ class DitaTopic < Asciidoctor::Converter::Base
|
|
|
286
292
|
if node.title?
|
|
287
293
|
<<~EOF.chomp
|
|
288
294
|
<fig#{compose_id node.id}#{compose_metadata node.role}>
|
|
289
|
-
<title>#{node.title}</title>
|
|
295
|
+
<title>#{replace_spaces node.title}</title>
|
|
290
296
|
<image href="#{node.image_uri(node.attr 'target')}"#{width}#{height}#{scale} placement="break">
|
|
291
297
|
<alt>#{node.alt}</alt>
|
|
292
298
|
</image>
|
|
@@ -645,7 +651,7 @@ class DitaTopic < Asciidoctor::Converter::Base
|
|
|
645
651
|
# Return the XML output:
|
|
646
652
|
<<~EOF.chomp
|
|
647
653
|
<section#{compose_id node.id}#{outputclass}#{compose_metadata node.role}>
|
|
648
|
-
<title>#{node.title}</title>
|
|
654
|
+
<title>#{replace_spaces node.title}</title>
|
|
649
655
|
#{node.content}
|
|
650
656
|
</section>
|
|
651
657
|
EOF
|
|
@@ -688,7 +694,7 @@ class DitaTopic < Asciidoctor::Converter::Base
|
|
|
688
694
|
result = [%(<table#{compose_id node.id}#{compose_metadata node.role}>)]
|
|
689
695
|
|
|
690
696
|
# Check if the title is specified:
|
|
691
|
-
result << %(<title>#{node.title}</title>) if node.title?
|
|
697
|
+
result << %(<title>#{replace_spaces node.title}</title>) if node.title?
|
|
692
698
|
|
|
693
699
|
# Define the table properties and open the tgroup:
|
|
694
700
|
result << %(<tgroup cols="#{node.attr 'colcount'}">)
|
|
@@ -902,7 +908,7 @@ class DitaTopic < Asciidoctor::Converter::Base
|
|
|
902
908
|
result = [%(<table outputclass="horizontal-dlist"#{compose_id node.id}#{compose_metadata node.role}>)]
|
|
903
909
|
|
|
904
910
|
# Check if the title is specified:
|
|
905
|
-
result << %(<title>#{node.title}</title>) if node.title?
|
|
911
|
+
result << %(<title>#{replace_spaces node.title}</title>) if node.title?
|
|
906
912
|
|
|
907
913
|
# Define the table properties and open the tgroup:
|
|
908
914
|
result << %(<tgroup cols="2">)
|
|
@@ -1050,7 +1056,12 @@ class DitaTopic < Asciidoctor::Converter::Base
|
|
|
1050
1056
|
result = {}
|
|
1051
1057
|
|
|
1052
1058
|
# Define supported metadata attributes:
|
|
1053
|
-
valid =
|
|
1059
|
+
valid = {
|
|
1060
|
+
'pl' => 'platform',
|
|
1061
|
+
'pr' => 'product',
|
|
1062
|
+
'au' => 'audience',
|
|
1063
|
+
'op' => 'otherprops'
|
|
1064
|
+
}
|
|
1054
1065
|
|
|
1055
1066
|
# Process each role:
|
|
1056
1067
|
roles.split.each do |role|
|
|
@@ -1060,8 +1071,11 @@ class DitaTopic < Asciidoctor::Converter::Base
|
|
|
1060
1071
|
# Separate the attribute name from its value:
|
|
1061
1072
|
attribute, value = role.split ':'
|
|
1062
1073
|
|
|
1074
|
+
# Expand the short attribute variant:
|
|
1075
|
+
attribute = valid[attribute] if valid.key? attribute
|
|
1076
|
+
|
|
1063
1077
|
# Ignore unsupported attribute names:
|
|
1064
|
-
next unless valid.
|
|
1078
|
+
next unless valid.value? attribute
|
|
1065
1079
|
|
|
1066
1080
|
# Append the value to the attribute:
|
|
1067
1081
|
if result.key? attribute
|
|
@@ -1079,6 +1093,23 @@ class DitaTopic < Asciidoctor::Converter::Base
|
|
|
1079
1093
|
end
|
|
1080
1094
|
end
|
|
1081
1095
|
|
|
1096
|
+
def replace_spaces text
|
|
1097
|
+
# Return the original value if no text is supplied
|
|
1098
|
+
return text unless text
|
|
1099
|
+
|
|
1100
|
+
# Check if non-breaking spaces are allowd:
|
|
1101
|
+
if @spaces_allowed
|
|
1102
|
+
return text
|
|
1103
|
+
end
|
|
1104
|
+
|
|
1105
|
+
# Replace unsupported non-breaking spaces:
|
|
1106
|
+
return text.
|
|
1107
|
+
gsub(/&(?:nbsp|#160);/, ' '). # Non-breaking space
|
|
1108
|
+
gsub(/&(?:thinsp|ThinSpace|#8201);/, ' '). # Thin space
|
|
1109
|
+
gsub(/&(?:ZeroWidthSpace|#8203);/, ''). # Zero-width space
|
|
1110
|
+
gsub(/&(?:NoBreak|#8288);/, '') # Word joiner
|
|
1111
|
+
end
|
|
1112
|
+
|
|
1082
1113
|
def extract_attributes text
|
|
1083
1114
|
# Extract metadata attributes from an empty ph element:
|
|
1084
1115
|
if /^\s*<ph(?<attributes> [^>]+)><\/ph>\s*/ =~ text
|
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.5.
|
|
4
|
+
version: 1.5.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Jaromir Hradilek
|
|
@@ -140,7 +140,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
140
140
|
- !ruby/object:Gem::Version
|
|
141
141
|
version: '0'
|
|
142
142
|
requirements: []
|
|
143
|
-
rubygems_version: 4.0.
|
|
143
|
+
rubygems_version: 4.0.17
|
|
144
144
|
specification_version: 4
|
|
145
145
|
summary: A custom AsciiDoc converter that generates individual DITA topics
|
|
146
146
|
test_files: []
|