Method: RDoc::Text#expand_tabs
- Defined in:
- lib/rdoc/text.rb
#expand_tabs(text) ⇒ Object
Expands tab characters in text to eight spaces
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/rdoc/text.rb', line 68 def text = [] text.each_line do |line| nil while line.gsub!(/(?:\G|\r)((?:.{8})*?)([^\t\r\n]{0,7})\t/) do r = "#{$1}#{$2}#{' ' * (8 - $2.size)}" r.force_encoding text.encoding if Object.const_defined? :Encoding r end << line end .join end |