My Ruby Cookbook: #1 Textile Convertor

written by edavis on January 2nd, 2006 @ 12:37 PM

#!/usr/bin/env ruby
# Used to generate a HTML-ized file from a textile marked up file
#

require 'rubygems'
require 'redcloth'

ARGV.each { |file|
  a = File.open(file, "r")
  lines = a.readlines
  a.close

  contents = Array.new()
  lines.each { |line|
      contents << line
  }
  html_file = File.new(file +".html", "w")
  html_file.puts(RedCloth.new(contents.join()).to_html)
  html_file.close

}

Eric Davis

Post a comment