Sha256: d495f553718b04ab0800162fe254383ca11a18f00f4c61f14d9c6f9078e320a7

Contents?: true

Size: 1.59 KB

Versions: 6

Compression:

Stored size: 1.59 KB

Contents

#!/usr/bin/env ruby
# frozen_string_literal: true

require "rubygems"
require "bundler/setup"

require "word-to-markdown"
require "optparse"
require "coradoc"

ARGV.push("-h") if ARGV.empty?

config = {
  input_options: input_options = {},
  input_processor: :docx,
  output_options: output_options = {},
  output_processor: :adoc,
}
destination = nil

OptionParser.new do |opts|
  opts.banner = "Usage: w2a [options] <file>"
  opts.on("-m", "--mathml2asciimath", "Convert MathML to AsciiMath") do |_v|
    input_options[:mathml2asciimath] = true
  end

  opts.on("-oFILENAME", "--output=FILENAME", "Output file to write to") do |v|
    destination = File.expand_path(v)
    # puts "output goes to #{Coradoc::Input::HTML.config.destination}"
  end

  opts.on("-e", "--external-images", "Export images if data URI") do |_v|
    input_options[:external_images] = true
  end

  opts.on("-v", "--version", "Version information") do |_v|
    puts "Coradoc: v#{Coradoc::VERSION}"
    puts "[dependency] WordToMarkdown: v#{WordToMarkdown::VERSION}"
    if Gem.win_platform?
      puts "[dependency] LibreOffice: version not available on Windows"
    else
      puts "[dependency] LibreOffice: v#{WordToMarkdown.soffice.version}"
    end
    exit
  end

  opts.on("-h", "--help", "Prints this help") do
    puts opts
    exit
  end
end.parse!

filename = ARGV.pop
raise "Please provide an input file to process. Exiting." unless filename

if input_options[:external_images] && destination.nil?
  raise "The -e | --external-images feature must be used with -o | --output. Exiting."
end

Coradoc::Converter.(filename, destination, **config)

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
coradoc-1.1.6 exe/w2a
coradoc-1.1.5 exe/w2a
coradoc-1.1.4 exe/w2a
coradoc-1.1.3 exe/w2a
coradoc-1.1.2 exe/w2a
coradoc-1.1.1 exe/w2a