A better version might be:
--------------------------------------------------------------
input = File.open("baselayout_test.rb")
output = File.new( "baselayout_test.html" , "w+" )
input.each_byte{ |c|
c=c.chr
c.gsub!(/\n/ , "<br>\n" ) and output.write( c ) and next if( c=~/\n/ )
c.gsub!(/\s/ , " " ) and output.write( c ) and next if( c=~/\s/ )
c.gsub!(/\t/ , " " ) and output.write( c )
and next if( c=~/\t/ )
output.write( c ) }
Zach Dennis wrote:
> A quick and dirty way might be:
>
> #!/usr/bin/ruby
>
> input = File.open( "file.rb" , "r" )
> output = File.new( "file.html" , "w+" )
>
> input.each_byte{ |c|
> case c.chr!
> when "\n"
> output.write( "<br>\n" )
> when "\s"
> output.write( " " )
> when "\t"
> output.write( 4.times{ "nbsp;" } )
> else
> output.write( c )
> end }
>
>
> Zach
>
>
>