File: redcloth

package info (click to toggle)
ruby-redcloth 4.3.4-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 708 kB
  • sloc: ruby: 1,233; ansic: 201; makefile: 25
file content (28 lines) | stat: -rwxr-xr-x 852 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/bin/env ruby
$:.unshift(File.dirname(__FILE__) + '/../lib/')
require 'optparse'
require 'redcloth'

if %w(--version -v).include? ARGV.first
  puts "#{RedCloth::NAME} #{RedCloth::VERSION}"
  exit(0)
end

output_as = "html"
opts = OptionParser.new do |opts|
    opts.banner = "Usage: redcloth [options] [redcloth_formatted.txt]"
    opts.separator "If no file specified, STDIN will be used. If you are typing input, you can send an EOF by pressing ^D (^Z on Windows)"
    opts.separator ""
    opts.on("-o", "--output STYLE", "Output format (defaults to #{output_as})") do |o|
        output_as = o
    end
end
opts.parse! ARGV

red = RedCloth.new( ARGF.read )
out_meth = "to_#{ output_as }"
if red.respond_to? out_meth
    puts red.method( out_meth ).call
else
    abort "** No to_#{ output_as } method found for the `#{ output_as }' format"
end