Sha256: 5c2f7f0e857d488e1eac333cfa29139b94ad25a993b40d7b3b1bab083af58793
Contents?: true
Size: 1.01 KB
Versions: 9
Compression:
Stored size: 1.01 KB
Contents
#!/usr/bin/env ruby require 'methadone' require 'rmultimarkdown' require_relative '../lib/htmltoword' include Methadone::Main include Methadone::CLILogging main do |input, output| puts "Converting #{input} to #{output}" if options[:verbose] markup = File.read input if options[:format] == 'markdown' markup = markdown2html(markup) end Htmltoword::Document.create_and_save(markup, output, options[:template_name], options[:extras]) puts "Done" if options[:verbose] end def markdown2html(text) MultiMarkdown.new(text.to_s).to_html end version Htmltoword::VERSION description 'Convert simple html input (or markdown) to MS Word (docx)' arg :input, :required arg :output, :required on('--verbose', '-v', 'Be verbose') on('--extras', '-e', 'Use extra formatting features') on('--template', '-t', 'Use custom word base template (.docx file)') on('-f FORMAT', '--format', 'Format', /markdown|html/) # options['ip-address'] = '127.0.0.1' # on('-i IP_ADDRESS', '--ip-address', 'IP Address', /^\d+\.\d+\.\d+\.\d+$/) go!
Version data entries
9 entries across 9 versions & 3 rubygems