asciidoctor-dita-topic 1.4.5 → 1.4.7
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 +27 -23
- data/lib/dita-topic/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: aa49c2e77c20ed32770fa37f0a286ca5a5aa808c5fef1e11c70bce3ac5fc3f74
|
|
4
|
+
data.tar.gz: 698164a21ee241367c0ebc3d029759e546618514ac91d93e7076abe0eea58ca7
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6ddefc4aec275a5ce85990ca28bdcffe0d2a8033834112c5eea7c225f0420af2de96f952661799a17b3c2134739001ccf7f6323b7f8953a191f4dc9dcfb18ada
|
|
7
|
+
data.tar.gz: 1088e887c924235e473b9f23aa04e4e3a41e3f8f307857342f7f852b2de5791e2917d7b69c74ff8f487e1c82098d62cbe993f1b8fd9c9f72f127e7284dd14fe1
|
data/lib/dita-topic/cli.rb
CHANGED
|
@@ -33,9 +33,9 @@ module AsciidoctorDitaTopic
|
|
|
33
33
|
@attr = ['experimental']
|
|
34
34
|
@opts = {
|
|
35
35
|
:output => false,
|
|
36
|
-
:includes => true,
|
|
37
36
|
:standalone => true,
|
|
38
|
-
:map => false
|
|
37
|
+
:map => false,
|
|
38
|
+
:no_includes => 0
|
|
39
39
|
}
|
|
40
40
|
@prep = []
|
|
41
41
|
@name = name
|
|
@@ -61,7 +61,7 @@ module AsciidoctorDitaTopic
|
|
|
61
61
|
|
|
62
62
|
opt.separator ''
|
|
63
63
|
|
|
64
|
-
opt.on('-m', '--dita-map', 'generate a DITA map instead of a topic') do
|
|
64
|
+
opt.on('-m', '--dita-map', 'generate a DITA map instead of a topic; this functionality is experimental and not yet fully tested') do
|
|
65
65
|
@opts[:map] = true
|
|
66
66
|
end
|
|
67
67
|
|
|
@@ -72,8 +72,8 @@ module AsciidoctorDitaTopic
|
|
|
72
72
|
@prep.append file
|
|
73
73
|
end
|
|
74
74
|
|
|
75
|
-
opt.on('-I', '--no-includes', 'disable processing of include directives') do
|
|
76
|
-
@opts[:
|
|
75
|
+
opt.on('-I', '--no-includes', 'disable processing of include directives; specify this option twice to also apply on prepended files') do
|
|
76
|
+
@opts[:no_includes] += 1
|
|
77
77
|
end
|
|
78
78
|
|
|
79
79
|
opt.separator ''
|
|
@@ -125,12 +125,10 @@ module AsciidoctorDitaTopic
|
|
|
125
125
|
return args
|
|
126
126
|
end
|
|
127
127
|
|
|
128
|
-
def convert_map file, input,
|
|
128
|
+
def convert_map file, input, base_dir
|
|
129
129
|
if file == $stdin
|
|
130
|
-
base_dir = Pathname.new(Dir.pwd).expand_path
|
|
131
130
|
offset = 0
|
|
132
131
|
else
|
|
133
|
-
base_dir = Pathname.new(file).dirname.expand_path
|
|
134
132
|
file = Pathname.new(file).sub_ext('.dita').basename
|
|
135
133
|
offset = 1
|
|
136
134
|
end
|
|
@@ -191,15 +189,11 @@ module AsciidoctorDitaTopic
|
|
|
191
189
|
result << %(</map>)
|
|
192
190
|
end
|
|
193
191
|
|
|
194
|
-
|
|
195
|
-
$stdout.write result.join("\n")
|
|
196
|
-
else
|
|
197
|
-
File.write output, result.join("\n")
|
|
198
|
-
end
|
|
192
|
+
return result.join("\n")
|
|
199
193
|
end
|
|
200
194
|
|
|
201
|
-
def convert_topic input,
|
|
202
|
-
Asciidoctor.convert input, backend: 'dita-topic', standalone: @opts[:standalone], safe: :unsafe, attributes: @attr,
|
|
195
|
+
def convert_topic input, base_dir
|
|
196
|
+
return Asciidoctor.convert input, backend: 'dita-topic', standalone: @opts[:standalone], safe: :unsafe, attributes: @attr, base_dir: base_dir
|
|
203
197
|
end
|
|
204
198
|
|
|
205
199
|
def run
|
|
@@ -212,20 +206,30 @@ module AsciidoctorDitaTopic
|
|
|
212
206
|
|
|
213
207
|
@args.each do |file|
|
|
214
208
|
if file == $stdin
|
|
215
|
-
|
|
216
|
-
|
|
209
|
+
base_dir = Pathname.new(Dir.pwd).expand_path
|
|
210
|
+
input = $stdin.read
|
|
211
|
+
output = @opts[:output] ? @opts[:output] : $stdout
|
|
217
212
|
else
|
|
218
|
-
suffix
|
|
219
|
-
|
|
220
|
-
|
|
213
|
+
suffix = @opts[:map] ? '.ditamap' : '.dita'
|
|
214
|
+
base_dir = Pathname.new(file).dirname.expand_path
|
|
215
|
+
input = File.read(file)
|
|
216
|
+
output = @opts[:output] ? @opts[:output] : Pathname.new(file).sub_ext(suffix).to_s
|
|
221
217
|
end
|
|
222
218
|
|
|
223
|
-
|
|
219
|
+
prepended.gsub!(/^:_(?:mod-docs-content|content|module)-type:[ \t]+\S/, '//\&')
|
|
220
|
+
prepended.gsub!(Asciidoctor::IncludeDirectiveRx, '//\&') if @opts[:no_includes] > 1
|
|
221
|
+
input.gsub!(Asciidoctor::IncludeDirectiveRx, '//\&') if @opts[:no_includes] > 0
|
|
224
222
|
|
|
225
223
|
if @opts[:map]
|
|
226
|
-
convert_map file, prepended + input,
|
|
224
|
+
result = convert_map file, prepended + input, base_dir
|
|
225
|
+
else
|
|
226
|
+
result = convert_topic prepended + input, base_dir
|
|
227
|
+
end
|
|
228
|
+
|
|
229
|
+
if output == $stdout
|
|
230
|
+
$stdout.write result
|
|
227
231
|
else
|
|
228
|
-
|
|
232
|
+
File.write output, result
|
|
229
233
|
end
|
|
230
234
|
end
|
|
231
235
|
end
|
data/lib/dita-topic/version.rb
CHANGED