Hello. I was wondering...Is it possible to format text in Ruby besides using the string literals like \n or \t? For example, can you make text bold?
on 2008-11-09 22:54
on 2008-11-10 00:57
Carter Davis wrote: > Hello. I was wondering...Is it possible to format text in Ruby besides > using the string literals like \n or \t? For example, can you make text > bold? Not sure I understand your question correctly. If you mean the source-code then you're looking for a syntax highlighting editor which doesn't touch the text at all but just highlights it. If you mean when outputting e.g. via puts then it entirely depends on your output device. If it is a terminal that supports ANSII escape sequences then you can use them. Look for the Term::ANSIColor gem on rubyforge for a convenient way to do that. Plain it is like this: puts "\e[1mBold\e[0m" puts "\e[31mRed\e[0m" With the gem you can do it like this: puts "Bold".bold puts "Red".red (iirc) Regards Stefan