lib/claide/helper.rb in claide-0.6.1 vs lib/claide/helper.rb in claide-0.7.0

- old
+ new

@@ -31,13 +31,14 @@ # too wide. # def self.format_markdown(string, indent = 0, max_width = 80) paragraphs = Helper.strip_heredoc(string).split("\n\n") paragraphs = paragraphs.map do |paragraph| - unless paragraph.start_with?(' ' * 4) - full_line = paragraph.gsub("\n", ' ') - paragraph = wrap_with_indent(full_line, indent, max_width) + if paragraph.start_with?(' ' * 4) + paragraph.gsub!(/\n/, "\n#{' ' * indent}") + else + paragraph = wrap_with_indent(paragraph, indent, max_width) end paragraph.insert(0, ' ' * indent).rstrip end paragraphs.join("\n\n") end @@ -60,12 +61,13 @@ width = max_width else width = [terminal_width, max_width].min end + full_line = string.gsub("\n", ' ') available_width = width - indent space = ' ' * indent - word_wrap(string, available_width).split("\n").join("\n#{space}") + word_wrap(full_line, available_width).split("\n").join("\n#{space}") end # @return [String] Lifted straight from ActionView. Thanks guys! # def self.word_wrap(line, line_width)