Skip to content

Instantly share code, notes, and snippets.

@ayumin
Created July 16, 2010 14:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ayumin/478447 to your computer and use it in GitHub Desktop.
Save ayumin/478447 to your computer and use it in GitHub Desktop.
require 'kconv'
text = ""
wrap = false
ARGF.each do |line|
line.gsub!(/\t/,' ')
line.gsub!(/ +/,' ')
line.gsub!(%r{\"},%q{\\\"})
line.gsub!(%r{\'},%q{"})
if line =~ /\/\/(.*)$/
line = "/*" + $1 + "*/"
end
if line =~ /\/\*\*/
text += "\n" + line
wrap = true
elsif (wrap and line !~ /\*\//)
text += line
elsif (wrap and line =~ /\*\//)
text += line
wrap = false
else
text += line.chomp
end
end
puts text
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment