Sha256: ec31bf2a7424776a87605c08eea281f47660be104eb026ac1e9d9454b7941430
Contents?: true
Size: 500 Bytes
Versions: 13
Compression:
Stored size: 500 Bytes
Contents
class String # Unfold paragrpahs. # # FIXME: Sometimes adds one too many blank lines. TEST!!! # def unfold blank = false text = '' split(/\n/).each do |line| if /\S/ !~ line text << "\n\n" blank = true else if /^(\s+|[*])/ =~ line text << (line.rstrip + "\n") else text << (line.rstrip + " ") end blank = false end end text = text.gsub(/(\n){3,}/,"\n\n") text.rstrip end end
Version data entries
13 entries across 12 versions & 1 rubygems