Sha256: cc056335e89dcb9766d510a39fbde1689a0458176e214ee13be13f5b28b74601

Contents?: true

Size: 466 Bytes

Versions: 5

Compression:

Stored size: 466 Bytes

Contents

# TODO: Replace with facets/string/unfold

class String

  #
  def unfold_paragraphs
    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\n\n","\n\n")
    return text
  end

end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
detroit-0.4.0 lib/detroit/core_ext/unfold_paragraphs.rb
detroit-0.3.0 lib/detroit/tool/core_ext/unfold_paragraphs.rb
detroit-0.2.0 lib/detroit/tool/core_ext/unfold_paragraphs.rb
detroit-0.1.0 lib/detroit/tool/core_ext/unfold_paragraphs.rb
ratch-1.2.0 lib/ratch/core_ext/unfold_paragraphs.rb