I just got a simple script working that will parse a text file that is marked up in “Textile”:http://textism.com/tools/textile/ and turn it into HTML(Hyper Text Markup Language). It is a simple “Ruby”:http://www.ruby-lang.org script that requires RubyGems and “RedCloth”:http://www.whytheluckystiff.net/ruby/redcloth/.
Just run
<typo:code>
ruby textilize.rb myfile.txt another_file.txt
</typo:code>
and it will create a myfile.txt.html and another_file.txt.html. This is great for those who want to write in textile for their website but want to test it before it goes live.
h3. The Code
#!/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