pandocomatic 0.2.7.8 → 1.0.1

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.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/lib/pandocomatic/cli.rb +81 -64
  3. data/lib/pandocomatic/command/command.rb +37 -35
  4. data/lib/pandocomatic/command/convert_dir_command.rb +44 -46
  5. data/lib/pandocomatic/command/convert_file_command.rb +314 -286
  6. data/lib/pandocomatic/command/convert_file_multiple_command.rb +56 -53
  7. data/lib/pandocomatic/command/convert_list_command.rb +31 -34
  8. data/lib/pandocomatic/command/copy_file_command.rb +14 -15
  9. data/lib/pandocomatic/command/create_link_command.rb +24 -27
  10. data/lib/pandocomatic/command/skip_command.rb +12 -15
  11. data/lib/pandocomatic/configuration.rb +682 -867
  12. data/lib/pandocomatic/default_configuration.yaml +4 -0
  13. data/lib/pandocomatic/error/cli_error.rb +30 -26
  14. data/lib/pandocomatic/error/configuration_error.rb +10 -9
  15. data/lib/pandocomatic/error/io_error.rb +13 -13
  16. data/lib/pandocomatic/error/pandoc_error.rb +10 -9
  17. data/lib/pandocomatic/error/pandocomatic_error.rb +15 -14
  18. data/lib/pandocomatic/error/processor_error.rb +9 -9
  19. data/lib/pandocomatic/error/template_error.rb +50 -0
  20. data/lib/pandocomatic/input.rb +53 -54
  21. data/lib/pandocomatic/multiple_files_input.rb +79 -72
  22. data/lib/pandocomatic/output.rb +29 -0
  23. data/lib/pandocomatic/pandoc_metadata.rb +193 -181
  24. data/lib/pandocomatic/pandocomatic.rb +101 -97
  25. data/lib/pandocomatic/pandocomatic_yaml.rb +70 -0
  26. data/lib/pandocomatic/path.rb +171 -0
  27. data/lib/pandocomatic/printer/command_printer.rb +7 -5
  28. data/lib/pandocomatic/printer/configuration_errors_printer.rb +7 -6
  29. data/lib/pandocomatic/printer/error_printer.rb +12 -7
  30. data/lib/pandocomatic/printer/finish_printer.rb +11 -10
  31. data/lib/pandocomatic/printer/help_printer.rb +8 -6
  32. data/lib/pandocomatic/printer/printer.rb +34 -34
  33. data/lib/pandocomatic/printer/summary_printer.rb +39 -33
  34. data/lib/pandocomatic/printer/version_printer.rb +8 -8
  35. data/lib/pandocomatic/printer/views/cli_error.txt +5 -0
  36. data/lib/pandocomatic/printer/views/configuration_error.txt +2 -1
  37. data/lib/pandocomatic/printer/views/error.txt +1 -1
  38. data/lib/pandocomatic/printer/views/finish.txt +1 -1
  39. data/lib/pandocomatic/printer/views/help.txt +27 -15
  40. data/lib/pandocomatic/printer/views/summary.txt +7 -1
  41. data/lib/pandocomatic/printer/views/template_error.txt +1 -0
  42. data/lib/pandocomatic/printer/views/version.txt +3 -3
  43. data/lib/pandocomatic/printer/views/warning.txt +1 -1
  44. data/lib/pandocomatic/printer/warning_printer.rb +21 -19
  45. data/lib/pandocomatic/processor.rb +28 -28
  46. data/lib/pandocomatic/processors/fileinfo_preprocessor.rb +35 -30
  47. data/lib/pandocomatic/processors/metadata_preprocessor.rb +23 -22
  48. data/lib/pandocomatic/template.rb +244 -0
  49. data/lib/pandocomatic/warning.rb +24 -25
  50. metadata +32 -12
@@ -1,329 +1,357 @@
1
+ # frozen_string_literal: true
2
+
1
3
  #--
2
- # Copyright 2017, Huub de Beer <Huub@heerdebeer.org>
3
- #
4
+ # Copyright 2017-2022, Huub de Beer <Huub@heerdebeer.org>
5
+ #
4
6
  # This file is part of pandocomatic.
5
- #
7
+ #
6
8
  # Pandocomatic is free software: you can redistribute it and/or modify
7
9
  # it under the terms of the GNU General Public License as published by the
8
10
  # Free Software Foundation, either version 3 of the License, or (at your
9
11
  # option) any later version.
10
- #
12
+ #
11
13
  # Pandocomatic is distributed in the hope that it will be useful, but
12
14
  # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13
15
  # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14
16
  # for more details.
15
- #
17
+ #
16
18
  # You should have received a copy of the GNU General Public License along
17
19
  # with pandocomatic. If not, see <http://www.gnu.org/licenses/>.
18
20
  #++
19
21
  module Pandocomatic
20
-
21
- require 'paru'
22
- require 'shellwords'
23
-
24
- require_relative '../pandoc_metadata.rb'
25
-
26
- require_relative '../processor.rb'
27
- require_relative '../processors/fileinfo_preprocessor'
28
- require_relative '../processors/metadata_preprocessor'
29
-
30
- require_relative '../configuration.rb'
31
-
32
- require_relative '../error/io_error.rb'
33
- require_relative '../error/configuration_error.rb'
34
- require_relative '../error/processor_error.rb'
35
-
36
- require_relative 'command.rb'
37
-
38
- # Output formats used in pandocomatic
39
- OUTPUT_FORMATS = ["docx", "pptx", "odt", "pdf", "epub", "epub3", "epub2"]
40
-
41
- # Command to convert a file
42
- #
43
- # @!attribute config
44
- # @return [Configuration] the configuration of pandocomatic used to
45
- # convert the file
46
- #
47
- # @!attribute src
48
- # @return [String] the path to the file to convert
22
+ require 'paru'
23
+ require 'shellwords'
24
+
25
+ require_relative 'command'
26
+ require_relative '../error/io_error'
27
+ require_relative '../error/configuration_error'
28
+ require_relative '../error/processor_error'
29
+ require_relative '../pandoc_metadata'
30
+ require_relative '../path'
31
+ require_relative '../processor'
32
+ require_relative '../processors/fileinfo_preprocessor'
33
+ require_relative '../processors/metadata_preprocessor'
34
+ require_relative '../template'
35
+
36
+ # Output formats used in pandocomatic
37
+ OUTPUT_FORMATS = %w[docx pptx odt pdf epub epub3 epub2].freeze
38
+
39
+ # Pandoc options that take a path as argument
40
+ PANDOC_OPTIONS_WITH_PATH = %w[
41
+ data-dir
42
+ filter
43
+ template
44
+ css
45
+ include-in-header
46
+ include-before-body
47
+ include-after-body
48
+ reference-odt
49
+ reference-docx
50
+ epub-stylesheet
51
+ epub-cover-image
52
+ epub-metadata
53
+ epub-embed-font
54
+ epub-subdirectory
55
+ bibliography
56
+ csl
57
+ syntax-definition
58
+ reference-doc
59
+ lua-filter
60
+ extract-media
61
+ resource-path
62
+ citation-abbreviations
63
+ abbreviations
64
+ log
65
+ resource-path
66
+ ].freeze
67
+
68
+ # rubocop:disable Metrics
69
+
70
+ # Command to convert a file
71
+ #
72
+ # @!attribute config
73
+ # @return [Configuration] the configuration of pandocomatic used to
74
+ # convert the file
75
+ #
76
+ # @!attribute src
77
+ # @return [String] the path to the file to convert
78
+ #
79
+ # @!attribute dst
80
+ # @return [String] the path to the output file
81
+ class ConvertFileCommand < Command
82
+ attr_reader :config, :src, :dst
83
+
84
+ # Create a new ConvertFileCommand
49
85
  #
50
- # @!attribute dst
51
- # @return [String] the path to the output file
52
- class ConvertFileCommand < Command
53
-
54
- attr_reader :config, :src, :dst
55
-
56
- # Create a new ConvertFileCommand
57
- #
58
- # @param config [Configuration] pandocomatic's configuration
59
- # @param src [String] the path to the file to convert
60
- # @param dst [String] the path to save the output of the conversion
61
- # @param template_name [String = nil] the template to use while converting
62
- # this file
63
- def initialize(config, src, dst, template_name = nil)
64
- super()
65
-
66
- @config = config
67
- @src = src
68
- @dst = dst
69
-
70
- if template_name.nil? or template_name.empty?
71
- @template_name = @config.determine_template @src
72
- else
73
- @template_name = template_name
74
- end
75
-
76
- @metadata = PandocMetadata.load_file @src
77
- @dst = @config.set_destination @dst, @template_name, @metadata
86
+ # @param config [Configuration] pandocomatic's configuration
87
+ # @param src [String] the path to the file to convert
88
+ # @param dst [String] the path to save the output of the conversion
89
+ # @param template_name [String = nil] the template to use while converting
90
+ # this file
91
+ def initialize(config, src, dst, template_name = nil)
92
+ super()
93
+
94
+ @config = config
95
+ @src = src
96
+ @dst = dst
97
+
98
+ @template_name = if template_name.nil? || template_name.empty?
99
+ @config.determine_template @src
100
+ else
101
+ template_name
102
+ end
103
+
104
+ @metadata = PandocMetadata.load_file @src
105
+ @dst = @config.set_destination @dst, @template_name, @metadata
106
+
107
+ @errors.push IOError.new(:file_does_not_exist, nil, @src) unless File.exist? @src
108
+ @errors.push IOError.new(:file_is_not_a_file, nil, @src) unless File.file? @src
109
+ @errors.push IOError.new(:file_is_not_readable, nil, @src) unless File.readable? @src
110
+ end
78
111
 
79
- @errors.push IOError.new(:file_does_not_exist, nil, @src) unless File.exist? @src
80
- @errors.push IOError.new(:file_is_not_a_file, nil, @src) unless File.file? @src
81
- @errors.push IOError.new(:file_is_not_readable, nil, @src) unless File.readable? @src
82
- end
112
+ # Execute this ConvertFileCommand
113
+ def run
114
+ convert_file
115
+ end
83
116
 
84
- # Execute this ConvertFileCommand
85
- def run
86
- convert_file
87
- end
117
+ # Create a string representation of this ConvertFileCommand
118
+ #
119
+ # @return [String]
120
+ def to_s
121
+ str = "convert #{File.basename @src} #{"-> #{File.basename @dst}" unless @dst.nil?}"
122
+ unless @metadata.unique?
123
+ str += "\n\t encountered multiple YAML metadata blocks with a pandocomatic property."\
124
+ ' Only the pandocomatic property in the first YAML metadata block is being used;'\
125
+ ' the others are discarded.'
126
+ end
127
+ str
128
+ end
88
129
 
89
- # Create a string representation of this ConvertFileCommand
90
- #
91
- # @return [String]
92
- def to_s
93
- str = "convert #{File.basename @src} #{"-> #{File.basename @dst}" unless @dst.nil?}"
94
- str += "\n\t encountered multiple YAML metadata blocks with a pandocomatic propertie. Only the pandocomatic property in the first YAML metadata block is being used; the others are discarded." unless @metadata.unique?
95
- str
96
- end
130
+ private
97
131
 
98
- private
132
+ INTERNAL_TEMPLATE = 'internal template'
99
133
 
100
- def convert_file
101
- pandoc_options = @metadata.pandoc_options || {}
102
- template = {}
134
+ def convert_file
135
+ pandoc_options = @metadata.pandoc_options || {}
136
+ template = nil
103
137
 
104
- # Determine the actual options and settings to use when converting this
105
- # file.
106
- if not @template_name.nil? and not @template_name.empty?
107
- raise ConfigurationError.new(:no_such_template, nil, @template_name) unless @config.has_template? @template_name
108
- template = @config.get_template @template_name
138
+ # Determine the actual options and settings to use when converting this
139
+ # file.
140
+ if !@template_name.nil? && !@template_name.empty?
141
+ unless @config.template? @template_name
142
+ raise ConfigurationError.new(:no_such_template, nil,
143
+ @template_name)
144
+ end
109
145
 
110
- pandoc_options = Configuration.extend_value(pandoc_options, template['pandoc'])
111
- end
112
-
113
- # Write out the results of the conversion process to file.
114
- if @dst.to_s.empty? and @metadata.pandoc_options.has_key? 'output'
115
- @dst = @metadata.pandoc_options['output']
146
+ template = @config.get_template @template_name
147
+ pandoc_options = Template.extend_value(pandoc_options, template.pandoc)
148
+ else
149
+ template = Template.new INTERNAL_TEMPLATE
150
+ end
151
+
152
+ # Ignore the `--verbose` option, and warn about ignoring it
153
+ if pandoc_options.key? 'verbose'
154
+ pandoc_options.delete 'verbose'
155
+ warn 'WARNING: Ignoring the pandoc option --verbose because it'\
156
+ ' might interfere with the working of pandocomatic.'
157
+ end
158
+
159
+ template.merge! Template.new(INTERNAL_TEMPLATE, @metadata.pandocomatic) if @metadata.pandocomatic?
160
+
161
+ # Write out the results of the conversion process to file.
162
+ @dst = @metadata.pandoc_options['output'] if @dst.to_s.empty? && @metadata.pandoc_options.key?('output')
163
+
164
+ # Run setup scripts
165
+ setup template
166
+
167
+ # Read in the file to convert
168
+ input = File.read @src
169
+
170
+ # Run the default preprocessors to mix-in information about the file
171
+ # that is being converted and mix-in the template's metadata section as
172
+ # well
173
+ input = FileInfoPreprocessor.run input, @src, src_root, pandoc_options
174
+ input = MetadataPreprocessor.run input, template.metadata if template.metadata?
175
+
176
+ # Convert the file by preprocessing it, run pandoc on it, and
177
+ # postprocessing the output
178
+ input = preprocess input, template
179
+ input = pandoc input, pandoc_options, File.dirname(@src)
180
+ output = postprocess input, template
181
+
182
+ begin
183
+ # Either output to file or to STDOUT.
184
+
185
+ if @config.stdout?
186
+ puts output
187
+ @dst.close!
188
+ else
189
+ unless use_output_option @dst
190
+ File.open(@dst, 'w') do |file|
191
+ raise IOError.new(:file_is_not_a_file, nil, @dst) unless File.file? @dst
192
+ raise IOError.new(:file_is_not_writable, nil, @dst) unless File.writable? @dst
193
+
194
+ file << output
116
195
  end
117
-
118
- template = Configuration.extend_value(@metadata.pandocomatic, template) if @metadata.has_pandocomatic?
119
-
120
- # Run setup scripts
121
- setup template
122
-
123
- # Read in the file to convert
124
- input = File.read @src
125
-
126
- # Run the default preprocessors to mix-in information about the file
127
- # that is being converted and mix-in the template's metadata section as
128
- # well
129
- input = FileInfoPreprocessor.run input, @src, src_root, pandoc_options
130
- input = MetadataPreprocessor.run input, template['metadata'] if template.has_key? 'metadata' and not template['metadata'].empty?
131
-
132
- # Convert the file by preprocessing it, run pandoc on it, and
133
- # postprocessing the output
134
- input = preprocess input, template
135
- input = pandoc input, pandoc_options, File.dirname(@src)
136
- output = postprocess input, template
137
-
138
- begin
139
- unless use_output_option @dst then
140
- File.open(@dst, 'w') do |file|
141
- raise IOError.new(:file_is_not_a_file, nil, @dst) unless File.file? @dst
142
- raise IOError.new(:file_is_not_writable, nil, @dst) unless File.writable? @dst
143
- file << output
144
- end
145
- end
146
- rescue StandardError => e
147
- raise IOError.new(:error_writing_file, e, @dst)
148
- end
149
-
150
- # run cleanup scripts
151
- cleanup template
196
+ end
152
197
  end
198
+ rescue StandardError => e
199
+ raise IOError.new(:error_writing_file, e, @dst)
200
+ end
153
201
 
154
- PANDOC_OPTIONS_WITH_PATH = [
155
- 'data-dir',
156
- 'filter',
157
- 'template',
158
- 'css',
159
- 'include-in-header',
160
- 'include-before-body',
161
- 'include-after-body',
162
- 'reference-odt',
163
- 'reference-docx',
164
- 'epub-stylesheet',
165
- 'epub-cover-image',
166
- 'epub-metadata',
167
- 'epub-embed-font',
168
- 'epub-subdirectory',
169
- 'bibliography',
170
- 'csl',
171
- 'syntax-definition',
172
- 'reference-doc',
173
- 'lua-filter',
174
- 'extract-media',
175
- 'resource-path',
176
- 'citation-abbreviations',
177
- 'abbreviations',
178
- 'log',
179
- 'resource-path'
180
- ]
181
-
182
- def pandoc(input, options, src_dir)
183
- absolute_dst = File.expand_path @dst
184
- Dir.chdir(src_dir) do
185
- converter = Paru::Pandoc.new
186
- options.each do |option, value|
187
- if PANDOC_OPTIONS_WITH_PATH.include? option
188
- is_executable = option == "filter"
189
- if value.is_a? Array
190
- value = value.map {|v| @config.update_path(v, src_dir, absolute_dst, is_executable)}
191
- else
192
- value = @config.update_path(value, src_dir, @dst, is_executable)
193
- end
194
- end
202
+ # run cleanup scripts
203
+ cleanup template
204
+ end
195
205
 
196
- # There is no "pdf" output format; change it to latex but keep the
197
- # extension.
198
- value = determine_output_for_pdf(options) if option == "to" and value == "pdf"
199
-
200
- begin
201
- # Pandoc multi-word options can have the multiple words separated by
202
- # both underscore (_) and dash (-).
203
- option = option.gsub "-", "_"
204
- converter.send option, value unless
205
- option == 'output' or
206
- option == 'use_extension' or
207
- option == 'rename'
208
- # don't let pandoc write the output to enable postprocessing
209
- rescue
210
- warn "The pandoc option '#{option}' (with value '#{value}') is not recognized by paru. This option is skipped." if debug?
206
+ def pandoc(input, options, src_dir)
207
+ absolute_dst = File.expand_path @dst
208
+ Dir.chdir(src_dir) do
209
+ converter = Paru::Pandoc.new
210
+ options.each do |option, value|
211
+ # Options come from a YAML string. In YAML, properties without a value get value nil.
212
+ # Interpret these empty properties as "skip this property"
213
+ next if value.nil?
214
+
215
+ if PANDOC_OPTIONS_WITH_PATH.include? option
216
+ executable = option == 'filter'
217
+ value = if value.is_a? Array
218
+ value.map { |v| Path.update_path(@config, v, absolute_dst, check_executable: executable) }
219
+ else
220
+ Path.update_path(@config, value, @dst, check_executable: executable)
211
221
  end
212
- end
213
-
214
- converter.send "output", absolute_dst if use_output_option absolute_dst
215
-
216
- begin
217
- puts converter.to_command if debug?
218
- converter << input
219
- rescue Paru::Error => e
220
- raise PandocError.new(:error_running_pandoc, e, input)
221
- end
222
+ end
223
+
224
+ # There is no "pdf" output format; change it to latex but keep the
225
+ # extension.
226
+ value = determine_output_for_pdf(options) if (option == 'to') && (value == 'pdf')
227
+
228
+ begin
229
+ # Pandoc multi-word options can have the multiple words separated by
230
+ # both underscore (_) and dash (-).
231
+ option = option.gsub '-', '_'
232
+ converter.send option, value unless
233
+ (option == 'output') ||
234
+ (option == 'use_extension') ||
235
+ (option == 'rename')
236
+ # don't let pandoc write the output to enable postprocessing
237
+ rescue StandardError
238
+ if debug?
239
+ warn "WARNING: The pandoc option '#{option}' (with value '#{value}')"\
240
+ ' is not recognized by paru. This option is skipped.'
222
241
  end
242
+ end
223
243
  end
224
244
 
225
- # Preprocess the input
226
- #
227
- # @param input [String] the input to preprocess
228
- # @param config [Hash] template
229
- #
230
- # @return [String] the generated output
231
- def preprocess(input, config = {})
232
- process input, 'preprocessors', config
233
- end
234
-
235
- # Postprocess the input
236
- #
237
- # @param input [String] the input to postprocess
238
- # @param config [Hash] template
239
- #
240
- # @return [String] the generated output
241
- def postprocess(input, config = {})
242
- process input, 'postprocessors', config
243
- end
245
+ converter.send 'output', absolute_dst if use_output_option absolute_dst
244
246
 
245
- # Run setup scripts
246
- #
247
- # @param config [Hash] template
248
- def setup(config = {})
249
- process "", 'setup', config
250
- end
251
-
252
- # Run cleanup scripts
253
- #
254
- # @param config [Hash] template
255
- def cleanup(config = {})
256
- process "", 'cleanup', config
247
+ begin
248
+ puts converter.to_command if debug?
249
+ converter << input
250
+ rescue Paru::Error => e
251
+ raise PandocError.new(:error_running_pandoc, e, input)
257
252
  end
253
+ end
254
+ end
258
255
 
259
- # Run the input string through a list of filters called processors. There
260
- # are various types: preprocessors and postprocessors, setup and
261
- # cleanup, and rename
262
- def process(input, type, config = {})
263
- if config.has_key? type then
264
- processors = config[type]
265
- output = input
266
- processors.each do |processor|
267
- script = if @config.is_local_path? processor
268
- processor
269
- else
270
- @config.update_path(processor, File.dirname(@src), @dst, true)
271
- end
272
-
273
- command, *parameters = script.shellsplit # split on spaces unless it is preceded by a backslash
274
-
275
- if not File.exists? command
276
- command = Configuration.which(command)
277
- script = "#{command} #{parameters.join(' ')}"
278
-
279
- raise ProcessorError.new(:script_does_not_exist, nil, command) if command.nil?
280
- end
256
+ # Preprocess the input
257
+ #
258
+ # @param input [String] the input to preprocess
259
+ # @param template [Template] template
260
+ #
261
+ # @return [String] the generated output
262
+ def preprocess(input, template)
263
+ process input, Template::PREPROCESSORS, template
264
+ end
281
265
 
282
- raise ProcessorError.new(:script_is_not_executable, nil, command) unless File.executable? command
266
+ # Postprocess the input
267
+ #
268
+ # @param input [String] the input to postprocess
269
+ # @param template [Template] template
270
+ #
271
+ # @return [String] the generated output
272
+ def postprocess(input, template)
273
+ process input, Template::POSTPROCESSORS, template
274
+ end
283
275
 
284
- begin
285
- output = Processor.run(script, output)
286
- rescue StandardError => e
287
- ProcessorError.new(:error_processing_script, e, [script, @src])
288
- end
289
- end
290
- output
291
- else
292
- input
293
- end
294
- end
276
+ # Run setup scripts
277
+ #
278
+ # @param template [Template] template
279
+ def setup(template)
280
+ process '', Template::SETUP, template
281
+ end
295
282
 
296
- private
283
+ # Run cleanup scripts
284
+ #
285
+ # @param template [Template] template
286
+ def cleanup(template)
287
+ process '', Template::CLEANUP, template
288
+ end
297
289
 
298
- def run_processor
290
+ # Run the input string through a list of filters called processors. There
291
+ # are various types: preprocessors and postprocessors, setup and
292
+ # cleanup, and rename
293
+ def process(input, type, template)
294
+ if template.send "#{type}?"
295
+ processors = template.send type
296
+ output = input
297
+ processors.each do |processor|
298
+ script = if Path.local_path? processor
299
+ processor
300
+ else
301
+ Path.update_path(@config, processor, @dst, check_executable: true)
302
+ end
303
+
304
+ command, *parameters = script.shellsplit # split on spaces unless it is preceded by a backslash
305
+
306
+ unless File.exist? command
307
+ command = Path.which(command)
308
+ script = "#{command} #{parameters.join(' ')}"
309
+
310
+ raise ProcessorError.new(:script_does_not_exist, nil, command) if command.nil?
311
+ end
312
+
313
+ raise ProcessorError.new(:script_is_not_executable, nil, command) unless File.executable? command
314
+
315
+ begin
316
+ output = Processor.run(script, output)
317
+ rescue StandardError => e
318
+ ProcessorError.new(:error_processing_script, e, [script, @src])
319
+ end
299
320
  end
321
+ output
322
+ else
323
+ input
324
+ end
325
+ end
300
326
 
301
- def use_output_option(dst)
302
- OUTPUT_FORMATS.include?(File.extname(dst).slice(1..-1))
303
- end
327
+ def use_output_option(dst)
328
+ OUTPUT_FORMATS.include?(File.extname(dst).slice(1..-1))
329
+ end
304
330
 
305
- # Pandoc version 2 supports multiple pdf engines. Determine which
306
- # to use given the options.
307
- #
308
- # @param options [Hash] the options to a paru pandoc converter
309
- # @return [String] the output format for the pdf engine to use.
310
- def determine_output_for_pdf(options)
311
- if options.has_key? 'pdf-engine'
312
- engine = options['pdf-engine']
313
- case engine
314
- when 'context'
315
- 'context'
316
- when 'pdfroff'
317
- 'ms'
318
- when 'wkhtmltopdf', 'weasyprint', 'prince'
319
- 'html'
320
- else
321
- 'latex'
322
- end
323
- else
324
- # According to pandoc's manual, the default is LaTeX
325
- 'latex'
326
- end
331
+ # Pandoc version 2 supports multiple pdf engines. Determine which
332
+ # to use given the options.
333
+ #
334
+ # @param options [Hash] the options to a paru pandoc converter
335
+ # @return [String] the output format for the pdf engine to use.
336
+ def determine_output_for_pdf(options)
337
+ if options.key? 'pdf-engine'
338
+ engine = options['pdf-engine']
339
+ case engine
340
+ when 'context'
341
+ 'context'
342
+ when 'pdfroff'
343
+ 'ms'
344
+ when 'wkhtmltopdf', 'weasyprint', 'prince'
345
+ 'html'
346
+ else
347
+ 'latex'
327
348
  end
349
+ else
350
+ # According to pandoc's manual, the default is LaTeX
351
+ 'latex'
352
+ end
328
353
  end
354
+ end
355
+
356
+ # rubocop:enable Metrics
329
357
  end