diff --git a/lib/kramdown/converter/kramdown.rb b/lib/kramdown/converter/kramdown.rb index 7209391b..71e65298 100644 --- a/lib/kramdown/converter/kramdown.rb +++ b/lib/kramdown/converter/kramdown.rb @@ -87,8 +87,8 @@ def convert_text(el, opts) def convert_p(el, opts) w = @options[:line_width] - opts[:indent].to_s.to_i - first, second, *rest = inner(el, opts).strip.gsub(/(.{1,#{w}})( +|$\n?)/, "\\1\n").split("\n") - first&.gsub!(/^(?:(#|>)|(\d+)\.|([+-]\s))/) { $1 || $3 ? "\\#{$1 || $3}" : "#{$2}\\." } + first, second, *rest = inner(el, opts).strip.gsub(/(.{1,#{w}})( +|$\n?)/, "\\1\n").split(/\n/) + first&.gsub!(/^(?:(#|>)|(\d+)\.([\s\z])|([+-]\s))/) { $1 || $4 ? "\\#{$1 || $4}" : "#{$2}\\.#{$3}" } second&.gsub!(/^([=-]+\s*?)$/, "\\\1") res = [first, second, *rest].compact.join("\n") + "\n" res.gsub!(/^ {0,3}:/, "\\:") diff --git a/test/testcases/block/08_list/escaping.html b/test/testcases/block/08_list/escaping.html index afc795c6..039f11d8 100644 --- a/test/testcases/block/08_list/escaping.html +++ b/test/testcases/block/08_list/escaping.html @@ -14,4 +14,6 @@
1984. Was great!
+1984.5 is not a book.
+- This too!
diff --git a/test/testcases/block/08_list/escaping.text b/test/testcases/block/08_list/escaping.text index c3b1c598..4dd6befb 100644 --- a/test/testcases/block/08_list/escaping.text +++ b/test/testcases/block/08_list/escaping.text @@ -14,4 +14,6 @@ I have read the book 1984. 1984\. Was great! +1984.5 is not a book. + \- This too!