Skip to content

feature request: Convert file to file #51

@DcsMarionDickten

Description

@DcsMarionDickten

How about something like

def Pandoc.convert_file(inputfile, outputfile, *kwargs, **options)
    # use it like Pandoc.convert_file(myinputfile.md, myoutputfile.pdf, '--pdf-engine pdfroff', from: 'markdown')
    target = options[:to].present? ? options[:to] : outputfile.split('.')[-1] # only needed if file extension != name of output type
    source = options[:from].present? ? options[:from] : inputfile.split('.')[-1] # only needed if file extension != name of input type
    if kwargs.empty?
      return PandocRuby.new([inputfile], '-s', options, from: source, o: outputfile).send("to_#{target}")
    elsif options.empty?
      PandocRuby.new([inputfile], kwargs, '-s', from: source, o: outputfile).send("to_#{target}")
    else
      PandocRuby.new([inputfile], kwargs, '-s', options, from: source, o: outputfile).send("to_#{target}")
    end
  end

to directly convert from file to file without the kwargs (as far as that is possible)? This code is very elementary and probably won't work in many cases, but it's the first thing I wrote to integrate PandocRuby better with my code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions