asciidoctor-dita-topic 1.4.4 → 1.4.6
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 +20 -24
- 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: 7690eaba37e895e876771c847da1ed9bdbed1a6c697c843a4ab6c2b68e76e7b6
|
|
4
|
+
data.tar.gz: c4661d29f5dd07245e438e9f44446bfee3030b885d4b38d4d39964ef5031872e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 05ae4c5ca74d8b200ef763026171a1d82cc63c8fbd1a3492d6f5c53e5c5ecf525a72422b974c52093812ab76497167234042a44cb753b8dec7814678a6b6dde8
|
|
7
|
+
data.tar.gz: 238cb4a1a4f9f037f13ac8686ff9766d0100621044df8d0990374cc59c77743edb3fa888b07d23147a20678d660659e36c452348956027634a15eef86c15f7e4
|
data/lib/dita-topic/cli.rb
CHANGED
|
@@ -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
|
|
|
@@ -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,21 +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
|
|
202
|
-
|
|
203
|
-
base_dir = Pathname.new(Dir.pwd).expand_path
|
|
204
|
-
else
|
|
205
|
-
base_dir = Pathname.new(file).dirname.expand_path
|
|
206
|
-
end
|
|
207
|
-
|
|
208
|
-
Asciidoctor.convert input, backend: 'dita-topic', standalone: @opts[:standalone], safe: :unsafe, attributes: @attr, to_file: output, base_dir: base_dir
|
|
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
|
|
209
197
|
end
|
|
210
198
|
|
|
211
199
|
def run
|
|
@@ -218,20 +206,28 @@ module AsciidoctorDitaTopic
|
|
|
218
206
|
|
|
219
207
|
@args.each do |file|
|
|
220
208
|
if file == $stdin
|
|
221
|
-
|
|
222
|
-
|
|
209
|
+
base_dir = Pathname.new(Dir.pwd).expand_path
|
|
210
|
+
input = $stdin.read
|
|
211
|
+
output = @opts[:output] ? @opts[:output] : $stdout
|
|
223
212
|
else
|
|
224
|
-
suffix
|
|
225
|
-
|
|
226
|
-
|
|
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
|
|
227
217
|
end
|
|
228
218
|
|
|
229
219
|
input.gsub!(Asciidoctor::IncludeDirectiveRx, '//\&') unless @opts[:includes]
|
|
230
220
|
|
|
231
221
|
if @opts[:map]
|
|
232
|
-
convert_map file, prepended + input,
|
|
222
|
+
result = convert_map file, prepended + input, base_dir
|
|
223
|
+
else
|
|
224
|
+
result = convert_topic prepended + input, base_dir
|
|
225
|
+
end
|
|
226
|
+
|
|
227
|
+
if output == $stdout
|
|
228
|
+
$stdout.write result
|
|
233
229
|
else
|
|
234
|
-
|
|
230
|
+
File.write output, result
|
|
235
231
|
end
|
|
236
232
|
end
|
|
237
233
|
end
|
data/lib/dita-topic/version.rb
CHANGED