From 2ae293c3dadbe46817e1552ceea625ee137cc348 Mon Sep 17 00:00:00 2001 From: Virgil Ierubino <30758921+Convincible@users.noreply.github.com> Date: Mon, 20 Jul 2020 21:42:36 +0100 Subject: [PATCH] Enhance output of compact nested lists when converting to kramdown Nested lists don't realise they are nested, and hence newlines are added after the end of a nested list (within the main list) when this is of course unnecessary and can cause rendering issues. --- lib/kramdown/converter/kramdown.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/kramdown/converter/kramdown.rb b/lib/kramdown/converter/kramdown.rb index decef8e9..2a92c703 100644 --- a/lib/kramdown/converter/kramdown.rb +++ b/lib/kramdown/converter/kramdown.rb @@ -45,7 +45,8 @@ def convert(el, opts = {indent: 0}) elsif el.block? && ![:li, :dd, :dt, :td, :th, :tr, :thead, :tbody, :tfoot, :blank].include?(el.type) && (el.type != :html_element || @stack.last.type != :html_element) && - (el.type != :p || !el.options[:transparent]) + (el.type != :p || !el.options[:transparent]) && + !([:ul, :dl, :ol].include?(el.type) && @stack.last.type == :li) res << "\n" end res