pandocomatic 0.1.4.16 → 0.1.4.17

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5c02545012823b03faea6b75bd1eefe4f0321f87
4
- data.tar.gz: e20c1f0fb820d2372a549bdeae47b8ef97207e9c
3
+ metadata.gz: 669fe6e3844e2170de209386538ff5909cac12d8
4
+ data.tar.gz: 6b41c8276434a97794aefaee5d794169c45d7faf
5
5
  SHA512:
6
- metadata.gz: dffc42a133303448e4e0fb8c2921231b5c59de5b50b2506e1babdc8b4499f11d724e48615f60cd0449206e26bf6dbc69d97933bea6efd195a1c8b16445dc9598
7
- data.tar.gz: c7f3608f963daa702eeec4f3203bf8eba373f31aae316fafe9bdee1d3bd4cbccbff00137c6cb2758e24ddfd82512e0feca30143b766dc1bc3ff286dd3cbb9794
6
+ metadata.gz: 6689d68e033804995c5dd2acd1640eedd58bd2fcf520d18fa57bfebb5c5623d1120fc2bd5dee5d26307744760837f7041baca2e0266118d3071c5e9ad133407d
7
+ data.tar.gz: 3e1d7b12546a38a39b55e1c6a3c4b0b3045a7a2c048a2b9f9b444fa639c0e8bf48278132bf61626c577bc3761dc2f8479040add8b11318aab508f8afb2df39d5
@@ -102,16 +102,7 @@ module Pandocomatic
102
102
  raise ConfigurationError.new(:no_such_template, nil, @template_name) unless @config.has_template? @template_name
103
103
  template = @config.get_template @template_name
104
104
 
105
- pandoc_options = (template['pandoc'] || {}).merge(pandoc_options) do |key, oldval, newval|
106
- # Options that can occur more than once, such as 'filter' or
107
- # 'metadata' are merged, not replaced like options that can occur
108
- # only once, such as 'toc' or 'from'
109
- if oldval.is_a? Array
110
- oldval + newval
111
- else
112
- newval
113
- end
114
- end
105
+ pandoc_options = Configuration.extend_value(pandoc_options, template['pandoc'])
115
106
  end
116
107
 
117
108
  # Run setup scripts
@@ -195,7 +186,7 @@ module Pandocomatic
195
186
 
196
187
  # There is no "pdf" output format; change it to latex but keep the
197
188
  # extension.
198
- value = "latex" if option == "to" and value == "pdf"
189
+ value = determine_output_for_pdf(options) if option == "to" and value == "pdf"
199
190
 
200
191
  begin
201
192
  # Pandoc multi-word options can have the multiple words separated by
@@ -265,5 +256,32 @@ module Pandocomatic
265
256
  input
266
257
  end
267
258
  end
259
+
260
+ private
261
+
262
+
263
+ # Pandoc version 2 supports multiple pdf engines. Determine which
264
+ # to use given the options.
265
+ #
266
+ # @param options [Hash] the options to a paru pandoc converter
267
+ # @return [String] the output format for the pdf engine to use.
268
+ def determine_output_for_pdf(options)
269
+ if options.has_key? 'pdf-engine'
270
+ engine = options['pdf-engine']
271
+ case engine
272
+ when 'context'
273
+ 'context'
274
+ when 'pdfroff'
275
+ 'ms'
276
+ when 'wkhtmltopdf', 'weasyprint', 'prince'
277
+ 'html'
278
+ else
279
+ 'latex'
280
+ end
281
+ else
282
+ # According to pandoc's manual, the default is LaTeX
283
+ 'latex'
284
+ end
285
+ end
268
286
  end
269
287
  end
@@ -34,7 +34,8 @@ module Pandocomatic
34
34
  'markdown_github' => 'md',
35
35
  'html5' => 'html',
36
36
  'docx' => 'docx',
37
- 'latex' => 'tex'
37
+ 'latex' => 'tex',
38
+ 'context' => 'tex'
38
39
  }
39
40
 
40
41
  # A Configuration object models a pandocomatic configuration.
@@ -258,7 +259,7 @@ module Pandocomatic
258
259
  def update_path(path, src_dir, check_executable = false)
259
260
  updated_path = path
260
261
  if path.start_with? './'
261
- # refers to a local (to file) dir
262
+ # refers to a local dir
262
263
  updated_path = File.join src_dir, path
263
264
  else
264
265
  if path.start_with? '/'
@@ -278,68 +279,6 @@ module Pandocomatic
278
279
  updated_path
279
280
  end
280
281
 
281
- private
282
-
283
- # Reset the settings for pandocomatic based on a new settings Hash
284
- #
285
- # @param settings [Hash] the new settings to use to reset the settings in
286
- # this Configuration with.
287
- def reset_settings(settings)
288
- settings.each do |setting, value|
289
- case setting
290
- when 'skip'
291
- @settings['skip'] = @settings['skip'].concat(value).uniq
292
- when 'data-dir'
293
- next # skip data-dir setting; is set once in initialization
294
- else
295
- @settings[setting] = value
296
- end
297
- end
298
- end
299
-
300
- # Deep copy a template
301
- #
302
- # @param template [Hash] the template to clone
303
- # @return [Hash]
304
- def clone_template(template)
305
- Marshal.load(Marshal.dump(template))
306
- end
307
-
308
- # Merge two templates
309
- #
310
- # @param base_template [Hash] the base template
311
- # @param mixin_template [Hash] the template to mixin into the base template
312
- # @return [Hash] the merged templates
313
- def merge(base_template, mixin_template)
314
- if mixin_template['extends'] and mixin_template['extends'].is_a? String
315
- mixin_template['extends'] = [mixin_template['extends']]
316
- end
317
-
318
- fields = [
319
- 'glob',
320
- 'metadata',
321
- 'setup',
322
- 'preprocessors',
323
- 'pandoc',
324
- 'postprocessors',
325
- 'cleanup'
326
- ]
327
-
328
- fields.each do |field|
329
- parent = base_template[field]
330
- current = mixin_template[field]
331
- extended_value = extend_value current, parent
332
-
333
- if extended_value.nil?
334
- base_template.delete field
335
- else
336
- base_template[field] = extended_value
337
- end
338
- end
339
-
340
- base_template
341
- end
342
-
343
282
  # Extend the current value with the parent value. Depending on the
344
283
  # value and type of the current and parent values, the extension
345
284
  # differs.
@@ -357,7 +296,7 @@ module Pandocomatic
357
296
  # @param current [Object] the current value
358
297
  # @param parent [Object] the parent value the current might extend
359
298
  # @return [Object] the extended value
360
- def extend_value(current, parent)
299
+ def self.extend_value(current, parent)
361
300
  if parent.nil?
362
301
  # If no parent value is specified, the current takes
363
302
  # precedence
@@ -374,7 +313,7 @@ module Pandocomatic
374
313
  # Mixin current and parent values
375
314
  parent.each_pair do |property, value|
376
315
  if current.has_key? property
377
- extended_value = extend_value(current[property], value)
316
+ extended_value = Configuration.extend_value(current[property], value)
378
317
  if extended_value.nil?
379
318
  current.delete property
380
319
  else
@@ -426,6 +365,68 @@ module Pandocomatic
426
365
  end
427
366
  end
428
367
 
368
+ private
369
+
370
+ # Reset the settings for pandocomatic based on a new settings Hash
371
+ #
372
+ # @param settings [Hash] the new settings to use to reset the settings in
373
+ # this Configuration with.
374
+ def reset_settings(settings)
375
+ settings.each do |setting, value|
376
+ case setting
377
+ when 'skip'
378
+ @settings['skip'] = @settings['skip'].concat(value).uniq
379
+ when 'data-dir'
380
+ next # skip data-dir setting; is set once in initialization
381
+ else
382
+ @settings[setting] = value
383
+ end
384
+ end
385
+ end
386
+
387
+ # Deep copy a template
388
+ #
389
+ # @param template [Hash] the template to clone
390
+ # @return [Hash]
391
+ def clone_template(template)
392
+ Marshal.load(Marshal.dump(template))
393
+ end
394
+
395
+ # Merge two templates
396
+ #
397
+ # @param base_template [Hash] the base template
398
+ # @param mixin_template [Hash] the template to mixin into the base template
399
+ # @return [Hash] the merged templates
400
+ def merge(base_template, mixin_template)
401
+ if mixin_template['extends'] and mixin_template['extends'].is_a? String
402
+ mixin_template['extends'] = [mixin_template['extends']]
403
+ end
404
+
405
+ fields = [
406
+ 'glob',
407
+ 'metadata',
408
+ 'setup',
409
+ 'preprocessors',
410
+ 'pandoc',
411
+ 'postprocessors',
412
+ 'cleanup'
413
+ ]
414
+
415
+ fields.each do |field|
416
+ parent = base_template[field]
417
+ current = mixin_template[field]
418
+ extended_value = Configuration.extend_value current, parent
419
+
420
+ if extended_value.nil?
421
+ base_template.delete field
422
+ else
423
+ base_template[field] = extended_value
424
+ end
425
+ end
426
+
427
+ base_template
428
+ end
429
+
429
430
  # Resolve the templates the templates extends and mixes them in, in
430
431
  # order of occurrence.
431
432
  #
@@ -50,7 +50,7 @@ module Pandocomatic
50
50
  ERROR_STATUS = 1266 # This is the sum of the ascii values of the characters in 'pandocomatic'
51
51
 
52
52
  # Pandocomatic's current version
53
- VERSION = [0, 1, 4, 16]
53
+ VERSION = [0, 1, 4, 17]
54
54
 
55
55
  # Pandocomatic's default configuration file
56
56
  CONFIG_FILE = 'pandocomatic.yaml'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pandocomatic
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4.16
4
+ version: 0.1.4.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - Huub de Beer
@@ -154,7 +154,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
154
154
  requirements:
155
155
  - pandoc, a universal document converer <http://pandoc.org>
156
156
  rubyforge_project:
157
- rubygems_version: 2.5.2
157
+ rubygems_version: 2.6.11
158
158
  signing_key:
159
159
  specification_version: 4
160
160
  summary: Automating the use of pandoc