Skip to main content
The Kai Way

txt2html Script

一个把Markdown或(和)Textile的文本转化为Html的脚本,使用RedCloth,简单轻便。。。

#!/usr/bin/ruby -w # txt2html.rb # Usege: # run commands like: ruby txt2html.rb the_file_you_want_to_do_covert require "rubygems" require "redcloth" filename = ARGV.first contents = '' open("#{filename}") { |f| contents = f.read } open("#{filename[0, filename.length-4]}.html",'w') { |f| f<<RedCloth.new(contents).to_html }