lib/review/textutils.rb in review-2.4.0 vs lib/review/textutils.rb in review-2.5.0
- old
+ new
@@ -13,20 +13,29 @@
end
def split_paragraph(lines)
pre = pre_paragraph
post = post_paragraph
+ trimmed_lines = trim_lines(lines)
blocked_lines = [[]]
- lines.each do |element|
+ trimmed_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
+
+ private
+
+ def trim_lines(lines)
+ new_lines = lines.dup
+ new_lines.pop while new_lines[-1] && new_lines[-1].strip.empty?
+ new_lines
end
end
end