pandocomatic 0.2.5.0.alpha → 0.2.5.0.betaa

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
  SHA256:
3
- metadata.gz: e0830abb917ca87c8d072ee5a4f88fee1f2f2d8da6359f14e74f9160614b23f9
4
- data.tar.gz: 68f2dbf9325b3ccaeeeae4c2c99b3de4486ff00a2e6c1951a6b14f3f4260232a
3
+ metadata.gz: 33cabeb7b49bddf1b107c44ebf448f07c1f8f33503d620c8d68eac2d23b216dd
4
+ data.tar.gz: 39f12455e1105aca31e552ec8d3fac810a4aa60a5041c11c84fb5088dde94dde
5
5
  SHA512:
6
- metadata.gz: e8c034acc735d84f56c95765a070a129bb522bfe2b6536d407dc067c86f954fad64c7679cb561551689f837d1c54186a9e6c69e7f9fa192eaf548dc948395a0b
7
- data.tar.gz: a625b92f99fdccfc5786cb8e2e234b572f4157f4efc894bdc6ed2be39eaad54cb4d33895014e410abfc37e3e983fa9bb6b9de805fa693fa5e1bab54a1f0cebf0
6
+ metadata.gz: 677152a5dde3f7359a75b44a4c678673a45d64bc917770d9bccbe9d43d70ff8fd25cb18b1a567b2fb095d52c969ef264c91eb4c49a9cf188c342da01d9dd51d2
7
+ data.tar.gz: fccd7849c1cd7de73d3310b13785228bc91df4e89372c0f0bdc8aed52ed1355133032280d61f322217e76472cc39269d5555e5d1e8cb3a3ce16dbae7799f448b
@@ -22,7 +22,6 @@ module Pandocomatic
22
22
  require_relative './error/cli_error.rb'
23
23
  require_relative './configuration.rb'
24
24
 
25
-
26
25
  ##
27
26
  # Command line options parser for pandocomatic using optimist.
28
27
  #
@@ -75,7 +75,7 @@ module Pandocomatic
75
75
  @input = if input.nil? or input.empty? then
76
76
  nil
77
77
  elsif 1 < input.size then
78
- MultipleFilesInput.new(input)
78
+ MultipleFilesInput.new(input, self)
79
79
  else
80
80
  Input.new(input)
81
81
  end
@@ -347,7 +347,6 @@ module Pandocomatic
347
347
  @settings.has_key? 'match-files' and 'first' == @settings['match-files']
348
348
  end
349
349
 
350
-
351
350
  # Set the extension of the destination file given this Confguration,
352
351
  # template, and metadata
353
352
  #
@@ -386,22 +385,13 @@ module Pandocomatic
386
385
  end
387
386
  end
388
387
 
389
- destination = nil
390
- rename_script = nil
391
-
392
- # Output option in pandoc property has precedence
393
- if metadata.has_pandocomatic?
394
- pandocomatic = metadata.pandocomatic
395
- if pandocomatic.has_key? "pandoc"
396
- pandoc = pandocomatic["pandoc"]
397
- destination = determine_output_in_pandoc.call pandoc
398
- rename_script = pandoc["rename"]
399
- end
400
- end
388
+ # Output options in pandoc property have precedence
389
+ destination = determine_output_in_pandoc.call metadata.pandoc_options
390
+ rename_script = metadata.pandoc_options["rename"]
401
391
 
402
392
  # Output option in template's pandoc property is next
403
393
  if destination.nil? and not template_name.nil? and not template_name.empty? then
404
- if @templates[template_name].has_key? "pandoc"
394
+ if @templates[template_name].has_key? "pandoc" and not @templates[template_name]["pandoc"].nil?
405
395
  pandoc = @templates[template_name]["pandoc"]
406
396
  destination = determine_output_in_pandoc.call pandoc
407
397
  rename_script ||= pandoc["rename"]
@@ -445,21 +435,14 @@ module Pandocomatic
445
435
  end
446
436
 
447
437
  if template_name.nil? or template_name.empty? then
448
- if metadata.has_pandocomatic?
449
- pandocomatic = metadata.pandocomatic
450
- if pandocomatic.has_key? "pandoc"
451
- pandoc = pandocomatic["pandoc"]
452
-
453
- ext = use_extension.call pandoc
454
- if not ext.nil?
455
- extension = ext
456
- elsif pandoc.has_key? "to"
457
- extension = strip_extensions.call(pandoc["to"])
458
- end
459
- end
460
- end
438
+ ext = use_extension.call metadata.pandoc_options
439
+ if not ext.nil?
440
+ extension = ext
441
+ elsif metadata.pandoc_options.has_key? "to"
442
+ extension = strip_extensions.call(metadata.pandoc_options["to"])
443
+ end
461
444
  else
462
- if @templates[template_name].has_key? "pandoc"
445
+ if @templates[template_name].has_key? "pandoc" and not @templates[template_name]["pandoc"].nil?
463
446
  pandoc = @templates[template_name]["pandoc"]
464
447
  ext = use_extension.call pandoc
465
448
 
@@ -885,6 +868,5 @@ module Pandocomatic
885
868
 
886
869
  path
887
870
  end
888
-
889
871
  end
890
872
  end
@@ -28,8 +28,9 @@ module Pandocomatic
28
28
  # is created as well containing the content of all the files in input.
29
29
  #
30
30
  # @param input [String[]] a list with input files
31
- def initialize(input)
31
+ def initialize(input, config)
32
32
  super(input)
33
+ @config = config
33
34
  create_temp_file
34
35
  end
35
36
 
@@ -69,10 +70,25 @@ module Pandocomatic
69
70
  # Concatenate all input files into one (temporary) input file
70
71
  # created in the same directory as the first input file
71
72
  @tmp_file = Tempfile.new(@input_files.first, File.dirname(self.absolute_path))
72
-
73
+
74
+ # Read first file and its metadata
75
+ metadata = PandocMetadata.load_file @input_files.first
76
+
77
+ strip_metadata =
78
+ "markdown" == if metadata.pandoc_options.has_key? "from" then
79
+ metadata.pandoc_options["from"]
80
+ else
81
+ template = @config.determine_template @input_files.first
82
+ if not template.nil? and not template.dig("pandoc", "from").nil? then
83
+ template["pandoc"]["from"]
84
+ else
85
+ "unknown"
86
+ end
87
+ end
88
+
73
89
  @input_files.each_with_index do |filename, index|
74
90
  input = File.read File.absolute_path(filename)
75
- input = if 0 === index then input else PandocMetadata.remove_metadata(input) end
91
+ input = if 0 == index or not strip_metadata then input else PandocMetadata.remove_metadata(input) end
76
92
  @tmp_file.write input
77
93
  end
78
94
 
@@ -170,7 +170,7 @@ module Pandocomatic
170
170
  # @return [Boolean] True if there is a pandoc options property in this
171
171
  # PandocMetadata object. False otherwise.
172
172
  def has_pandoc_options?()
173
- has_pandocomatic? and pandocomatic.has_key? 'pandoc'
173
+ has_pandocomatic? and pandocomatic.has_key? 'pandoc' and not pandocomatic['pandoc'].nil?
174
174
  end
175
175
 
176
176
  end
@@ -47,8 +47,8 @@ module Pandocomatic
47
47
  ERROR_STATUS = 1266 # This is the sum of the ascii values of the characters in 'pandocomatic'
48
48
 
49
49
  # Pandocomatic's current version
50
- VERSION = [0, 2, 5, 0, "α"]
51
-
50
+ VERSION = [0, 2, 5, 0, "beta"]
51
+
52
52
  # Run pandocomatic given options
53
53
  #
54
54
  # @param args [String[]] list of options to configure pandocomatic
@@ -40,7 +40,7 @@ module Pandocomatic
40
40
 
41
41
  # Calculate the duration of the whole conversion process
42
42
  #
43
- # @erturn [Number]
43
+ # @return [Number]
44
44
  def duration()
45
45
  seconds = @end_time - @start_time
46
46
  if seconds > MINUTE
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pandocomatic
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5.0.alpha
4
+ version: 0.2.5.0.betaa
5
5
  platform: ruby
6
6
  authors:
7
7
  - Huub de Beer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-03-09 00:00:00.000000000 Z
11
+ date: 2019-03-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: paru
@@ -56,28 +56,28 @@ dependencies:
56
56
  requirements:
57
57
  - - "~>"
58
58
  - !ruby/object:Gem::Version
59
- version: '0'
59
+ version: '1.3'
60
60
  type: :development
61
61
  prerelease: false
62
62
  version_requirements: !ruby/object:Gem::Requirement
63
63
  requirements:
64
64
  - - "~>"
65
65
  - !ruby/object:Gem::Version
66
- version: '0'
66
+ version: '1.3'
67
67
  - !ruby/object:Gem::Dependency
68
68
  name: yard
69
69
  requirement: !ruby/object:Gem::Requirement
70
70
  requirements:
71
71
  - - "~>"
72
72
  - !ruby/object:Gem::Version
73
- version: 0.9.8
73
+ version: 0.9.18
74
74
  type: :development
75
75
  prerelease: false
76
76
  version_requirements: !ruby/object:Gem::Requirement
77
77
  requirements:
78
78
  - - "~>"
79
79
  - !ruby/object:Gem::Version
80
- version: 0.9.8
80
+ version: 0.9.18
81
81
  description: Pandocomatic is a tool to automate using pandoc (<http://pandoc.org>).
82
82
  With pandocomatic you can express common patterns of using pandoc for generating
83
83
  your documents. Applied to a directory, pandocomatic can act as a static site generator.