Sha256: 87c3cd3e2c7d9525f6f5f1a831618ee48ad2ffdc28239df9193152e32a1f230a

Contents?: true

Size: 649 Bytes

Versions: 1

Compression:

Stored size: 649 Bytes

Contents

require 'nkf'

module ReVIEW
  module TextUtils
    def detab(str, ts = 8)
      add = 0
      len = nil
      str.gsub("\t") do
        len = ts - ($`.size + add) % ts
        add += len - 1
        ' ' * len
      end
    end

    def split_paragraph(lines)
      pre = pre_paragraph
      post = post_paragraph

      blocked_lines = [[]]
      lines.each do |element|
        if element.empty?
          blocked_lines << [] if blocked_lines.last != []
        else
          blocked_lines.last << element
        end
      end

      blocked_lines.map! { |i| [pre] + i + [post] } if pre && post
      blocked_lines.map(&:join)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
review-2.4.0 lib/review/textutils.rb