From 6ea6e4248572b1c0146bce21e9a038055df6617c Mon Sep 17 00:00:00 2001 From: SM-Mark Date: Wed, 18 Mar 2015 16:47:57 -0400 Subject: [PATCH] Output newline only for last list item --- converttomarkdown.gapps | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/converttomarkdown.gapps b/converttomarkdown.gapps index b6344de..d0ddff0 100644 --- a/converttomarkdown.gapps +++ b/converttomarkdown.gapps @@ -51,7 +51,18 @@ function ConvertToMarkdown() { } else if (inSrc) { text+=(srcIndent+escapeHTML(result.text)+"\n"); } else if (result.text && result.text.length>0) { - text+=result.text+"\n\n"; + // SM-Mark: Only insert a blank line when this is the last list item + if (child.getType()!==DocumentApp.ElementType.LIST_ITEM) { + text+=result.text+"\n\n"; + } else { + text+=result.text+"\n"; + if (i < numChildren - 1) { + var nextChild = DocumentApp.getActiveDocument().getActiveSection().getChild(i+1); + if (nextChild.getType()!==DocumentApp.ElementType.LIST_ITEM) { + text+="\n"; + } + } + } } if (result.images && result.images.length>0) { @@ -182,7 +193,7 @@ function processParagraph(index, element, inSrc, imageCounter, listCounters) { } else { prefix = findPrefix(inSrc, element, listCounters); - + var pOut = ""; for (var i=0; i