script/txt2html in random_data-1.3.1 vs script/txt2html in random_data-1.5.0

- old
+ new

@@ -1,23 +1,20 @@ #!/usr/bin/env ruby -require 'rubygems' -begin - require 'newgem' -rescue LoadError - puts "\n\nGenerating the website requires the newgem RubyGem" - puts "Install: gem install newgem\n\n" - exit(1) -end +load File.dirname(__FILE__) + "/../Rakefile" +require 'rubyforge' require 'redcloth' require 'syntax/convertors/html' require 'erb' -require File.dirname(__FILE__) + '/../lib/random_data/version.rb' -version = RandomData::VERSION::STRING -download = 'http://rubyforge.org/projects/random_data' +download = "http://rubyforge.org/projects/#{$hoe.rubyforge_name}" +version = $hoe.version +def rubyforge_project_id + RubyForge.new.configure.autoconfig["group_ids"][$hoe.rubyforge_name] +end + class Fixnum def ordinal # teens return 'th' if (10..19).include?(self % 100) # others @@ -40,23 +37,23 @@ return Syntax::Convertors::HTML.for_syntax(syntax).convert(source).gsub(%r!^<pre>|</pre>$!,'') end if ARGV.length >= 1 src, template = ARGV - template ||= File.join(File.dirname(__FILE__), '/../website/template.rhtml') - + template ||= File.join(File.dirname(__FILE__), '/../website/template.html.erb') else - puts("Usage: #{File.split($0).last} source.txt [template.rhtml] > output.html") + puts("Usage: #{File.split($0).last} source.txt [template.html.erb] > output.html") exit! end template = ERB.new(File.open(template).read) title = nil body = nil File.open(src) do |fsrc| title_text = fsrc.readline - body_text = fsrc.read + body_text_template = fsrc.read + body_text = ERB.new(body_text_template).result(binding) syntax_items = [] body_text.gsub!(%r!<(pre|code)[^>]*?syntax=['"]([^'"]+)[^>]*>(.*?)</\1>!m){ ident = syntax_items.length element, syntax, source = $1, $2, $3 syntax_items << "<#{element} class='syntax'>#{convert_syntax(syntax, source)}</#{element}>"