require 'optparse' require 'RedCloth' module Slideshow def Slideshow.create_slideshow( fn ) header = < Slideshow EOS footer = < EOS basename = File.basename( fn, '.*' ) extname = File.extname( fn ) extname = ".textile" if extname.eql?("") inname = "#{basename}#{extname}" outname = "#{basename}.html" puts "Preparing slidshow '#{outname}'..." content = '' slide_counter = 0 infile = File.new( inname ) infile.each { |line| if line.include?( 'h1.' ) then content << "\n\n" if slide_counter > 0 content << "
\n\n" slide_counter += 1 end content << line } content << "\n\n
" if slide_counter > 0 out = File.new( outname, "w+") out << header out << RedCloth.new( content ).to_html out << footer out.flush out.close puts "Done." end def Slideshow.main $options = {} opt=OptionParser.new do |opts| opts.banner = "Usage: #{$0} [options] name" # opts.on( "-s", "--style STYLE", "Select Stylesheet" ) { |s| $options[:style]=s } opts.on_tail( "-h", "--help", "Show this message" ) { puts opts.help; exit } end opt.parse! ARGV.each { |fn| Slideshow.create_slideshow( fn ) } end end