asciidoctor-dita-topic 1.5.1 → 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/lib/dita-topic/cli.rb +4 -0
- data/lib/dita-topic/version.rb +1 -1
- data/lib/dita-topic.rb +29 -6
- 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/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">)
|
|
@@ -1087,6 +1093,23 @@ class DitaTopic < Asciidoctor::Converter::Base
|
|
|
1087
1093
|
end
|
|
1088
1094
|
end
|
|
1089
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
|
+
|
|
1090
1113
|
def extract_attributes text
|
|
1091
1114
|
# Extract metadata attributes from an empty ph element:
|
|
1092
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: []
|