class Pandocomatic::Processor

Generic class for processors used to preprocess, postproces, setup, and cleanup with external scripts or programs during the conversion process.

For preprocessors and postprocessors it is assumed that the input is the contents of the file to convert and the output the processed input. In the end, the output will be put through pandoc.

Public Class Methods

run(script, input) click to toggle source

Run script on input and return captured output

@param script [String] path to script to run @param input [String] input to process in the script

@return [String] output of script.

# File lib/pandocomatic/processor.rb, line 38
def self.run(script, input)
  output, error, status = Open3.capture3(script, stdin_data: input)
  warn error unless error.empty?

  if status.exitstatus.positive?
    raise ProcessorError.new(:error_processing_script, StandardError.new(error), [script, input])
  end

  output
end