lib/kramdown/converter/kramdown.rb in kramdown-0.14.0 vs lib/kramdown/converter/kramdown.rb in kramdown-0.14.1

- old
+ new

@@ -159,25 +159,26 @@ "#{sym}#{text}" end end def convert_dd(el, opts) - sym, width = ": ", (el.children.first.type == :codeblock ? 4 : 2) + sym, width = ": ", (el.children.first && el.children.first.type == :codeblock ? 4 : 2) if ial = ial_for_element(el) sym << ial << " " end opts[:indent] += width text = inner(el, opts) newlines = text.scan(/\n*\Z/).first first, *last = text.split(/\n/) last = last.map {|l| " "*width + l}.join("\n") - text = first + (last.empty? ? "" : "\n") + last + newlines + text = first.to_s + (last.empty? ? "" : "\n") + last + newlines text.chomp! if text =~ /\n\n\Z/ && opts[:next] && opts[:next].type == :dd - text << "\n" if text !~ /\n\n\Z/ && opts[:next] && opts[:next].type == :dt - if el.children.first.type == :p && !el.children.first.options[:transparent] + text << "\n" if (text !~ /\n\n\Z/ && opts[:next] && opts[:next].type == :dt) + text << "\n" if el.children.empty? + if el.children.first && el.children.first.type == :p && !el.children.first.options[:transparent] "\n#{sym}#{text}" - elsif el.children.first.type == :codeblock + elsif el.children.first && el.children.first.type == :codeblock "#{sym}\n #{text}" else "#{sym}#{text}" end end