#!/usr/bin/env ruby
#
# This file was generated by RubyGems.
#
# The application 'reverse_markdown' is installed as part of a gem, and
# this file is here to facilitate running it.
#

require 'rubygems'

Gem.use_gemdeps

version = ">= 0.a"

str = ARGV.first
if str
  str = str.b[/\A_(.*)_\z/, 1]
  if str and Gem::Version.correct?(str)
    version = str
    ARGV.shift
  end
end

path =
  if Gem.respond_to?(:activate_bin_path)
    Gem.activate_bin_path('reverse_markdown', 'reverse_markdown', version)
  else
    gem "reverse_markdown", version
    Gem.bin_path("reverse_markdown", "reverse_markdown", version)
  end

if __FILE__ == path
#!/usr/bin/env ruby
# Usage: reverse_markdown [FILE]...
# Usage: cat FILE | reverse_markdown
require 'reverse_markdown'
require 'optparse'

options = {}
OptionParser.new do |opts|
  opts.banner = "Usage: reverse_markdown [options] <file>"

  opts.on('-u', '--unknown_tags [pass_through, drop, bypass, raise]', 'Unknown tag handling (default: pass_through)') { |v| ReverseMarkdown.config.unknown_tags = v }
  opts.on('-g', '--github_flavored bool', 'use github flavored markdown (default: false)') { |v| ReverseMarkdown.config.github_flavored = v }
end.parse!

puts ReverseMarkdown.convert(ARGF.read)

else
  load(path)
end
