diff --git a/lib/kramdown/converter/kramdown.rb b/lib/kramdown/converter/kramdown.rb index 32e0c2d2..b1efbb56 100644 --- a/lib/kramdown/converter/kramdown.rb +++ b/lib/kramdown/converter/kramdown.rb @@ -146,7 +146,7 @@ def convert_li(el, opts) if el.children.first && el.children.first.type == :p && !el.children.first.options[:transparent] res = +"#{sym}#{text}" res << "^\n" if el.children.size == 1 && @stack.last.children.last == el && - (@stack.last.children.any? {|c| c.children.first.type != :p } || @stack.last.children.size == 1) + (@stack.last.children.any? {|c| c.children.first && c.children.first.type != :p } || @stack.last.children.size == 1) res elsif el.children.first && el.children.first.type == :codeblock "#{sym}\n #{text}" diff --git a/test/test_converter_kramdown.rb b/test/test_converter_kramdown.rb new file mode 100644 index 00000000..98ee3d94 --- /dev/null +++ b/test/test_converter_kramdown.rb @@ -0,0 +1,37 @@ +# -*- coding: utf-8; frozen_string_literal: true -*- +# +#-- +# Copyright (C) 2009-2019 Thomas Leitner +# +# This file is part of kramdown which is licensed under the MIT. +#++ +# + +require 'minitest/autorun' +require 'kramdown/converter/kramdown' + +describe Kramdown::Converter::Kramdown do + it "converts weird html to kramdown" do + html = <<~HTML + + HTML + doc, = Kramdown::Parser::Html.parse(html) + md, = Kramdown::Converter::Kramdown.convert(doc) + expected = <<~MD +* +* one + +* two + + MD + assert_equal expected, md + end +end