pandocomatic 0.2.5.0.betaa → 0.2.5.0.betac

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 33cabeb7b49bddf1b107c44ebf448f07c1f8f33503d620c8d68eac2d23b216dd
4
- data.tar.gz: 39f12455e1105aca31e552ec8d3fac810a4aa60a5041c11c84fb5088dde94dde
3
+ metadata.gz: 83da5ac4d9f87c0b60d2ec6275604fbc8c840448a0d4b2e8bcd3d814f43851a1
4
+ data.tar.gz: 6c2aa725f3476c529b743a337b26e19c3135440e6972a5d8121c100cd8c95202
5
5
  SHA512:
6
- metadata.gz: 677152a5dde3f7359a75b44a4c678673a45d64bc917770d9bccbe9d43d70ff8fd25cb18b1a567b2fb095d52c969ef264c91eb4c49a9cf188c342da01d9dd51d2
7
- data.tar.gz: fccd7849c1cd7de73d3310b13785228bc91df4e89372c0f0bdc8aed52ed1355133032280d61f322217e76472cc39269d5555e5d1e8cb3a3ce16dbae7799f448b
6
+ metadata.gz: 142b4f1a64096eb3ae1b7311d2639020d6af74af98c0cc28acf90fe6018dcdb9b7685408114452ba4b50f54acbc8629afb1a40ebf64a886e0f7bdaf4a388b8aa
7
+ data.tar.gz: 1aa6c6e996c8c667f738ce40b09d5dafc2251536a1b2481502dca6627262fe2c84ca16597c0f62afcefec86b513e44bfaae2ec35926765b64f01d9f0061a6701
@@ -61,6 +61,8 @@ module Pandocomatic
61
61
  # A Configuration object models a pandocomatic configuration.
62
62
  class Configuration
63
63
 
64
+ attr_reader :input
65
+
64
66
  # Pandocomatic's default configuration file
65
67
  CONFIG_FILE = 'pandocomatic.yaml'
66
68
 
@@ -265,7 +267,7 @@ module Pandocomatic
265
267
  # Get the input file name
266
268
  #
267
269
  # @return [String]
268
- def input()
270
+ def input_file()
269
271
  if @input.nil? then
270
272
  nil
271
273
  else
@@ -458,6 +460,15 @@ module Pandocomatic
458
460
  extension
459
461
  end
460
462
 
463
+ def is_markdown_file?(filename)
464
+ if filename.nil? then
465
+ false
466
+ else
467
+ ext = File.extname(filename).delete_prefix(".");
468
+ "markdown" == DEFAULT_EXTENSION.key(ext)
469
+ end
470
+ end
471
+
461
472
  # Is there a template with template_name in this Configuration?
462
473
  #
463
474
  # @param template_name [String] a template's name
@@ -61,7 +61,19 @@ module Pandocomatic
61
61
  #
62
62
  # @return String
63
63
  def to_s()
64
- @input_files.join(" + ")
64
+ input_string = @input_files.first
65
+ previous_dir = File.dirname @input_files.first
66
+ @input_files.slice(1..-1).each do |f|
67
+ current_dir = File.dirname f
68
+ if current_dir == previous_dir
69
+ input_string += " + #{File.basename f}"
70
+ else
71
+ previous_dir = current_dir
72
+ input_string += " + #{f}"
73
+ end
74
+ end
75
+
76
+ input_string
65
77
  end
66
78
 
67
79
  private
@@ -82,13 +94,21 @@ module Pandocomatic
82
94
  if not template.nil? and not template.dig("pandoc", "from").nil? then
83
95
  template["pandoc"]["from"]
84
96
  else
85
- "unknown"
97
+ if @config.is_markdown_file? @input_files.first then
98
+ "markdown"
99
+ else
100
+ "unknown"
101
+ end
86
102
  end
87
103
  end
88
104
 
89
105
  @input_files.each_with_index do |filename, index|
90
106
  input = File.read File.absolute_path(filename)
91
- input = if 0 == index or not strip_metadata then input else PandocMetadata.remove_metadata(input) end
107
+ input = if 0 == index or not strip_metadata or not @config.is_markdown_file? filename then
108
+ input
109
+ else
110
+ PandocMetadata.remove_metadata(input)
111
+ end
92
112
  @tmp_file.write input
93
113
  end
94
114
 
@@ -72,9 +72,9 @@ module Pandocomatic
72
72
  # Pandocomatic has two modes: converting a directory tree or
73
73
  # converting a single file. The mode is selected by the input.
74
74
  if configuration.directory?
75
- command = ConvertDirCommand.new(configuration, configuration.input, configuration.output)
75
+ command = ConvertDirCommand.new(configuration, configuration.input_file, configuration.output)
76
76
  else
77
- command = ConvertFileMultipleCommand.new(configuration, configuration.input, configuration.output)
77
+ command = ConvertFileMultipleCommand.new(configuration, configuration.input_file, configuration.output)
78
78
  command.make_quiet unless command.subcommands.size > 1
79
79
  end
80
80
 
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.betaa
4
+ version: 0.2.5.0.betac
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-15 00:00:00.000000000 Z
11
+ date: 2019-03-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: paru
@@ -147,7 +147,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
147
147
  requirements:
148
148
  - - ">="
149
149
  - !ruby/object:Gem::Version
150
- version: '0'
150
+ version: 2.4.4
151
151
  required_rubygems_version: !ruby/object:Gem::Requirement
152
152
  requirements:
153
153
  - - ">"