From cae3f8edbaac60e16152c87b93f0da317c1952f9 Mon Sep 17 00:00:00 2001
From: John MacFarlane <jgm@berkeley.edu>
Date: Sat, 27 Nov 2010 10:44:35 -0800
Subject: [PATCH] Fixed spacing problems in textile nested lists.

---
 src/Text/Pandoc/Writers/Textile.hs | 6 ++++--
 tests/writer.textile               | 6 ------
 2 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/src/Text/Pandoc/Writers/Textile.hs b/src/Text/Pandoc/Writers/Textile.hs
index 8dd2288c9..05acb5e8b 100644
--- a/src/Text/Pandoc/Writers/Textile.hs
+++ b/src/Text/Pandoc/Writers/Textile.hs
@@ -176,9 +176,10 @@ blockToTextile opts x@(BulletList items) = do
         return $ " <ul>\n" ++ vcat contents ++ " </ul>\n"
      else do
         modify $ \s -> s { stListLevel = stListLevel s ++ "*" }
+        level <- get >>= return . length . stListLevel
         contents <- mapM (listItemToTextile opts) items
         modify $ \s -> s { stListLevel = init (stListLevel s) }
-        return $ vcat contents ++ "\n"
+        return $ vcat contents ++ (if level > 1 then "" else "\n")
 
 blockToTextile opts x@(OrderedList attribs items) = do
   oldUseTags <- liftM stUseTags get
@@ -190,9 +191,10 @@ blockToTextile opts x@(OrderedList attribs items) = do
                    " </ol>\n"
      else do
         modify $ \s -> s { stListLevel = stListLevel s ++ "#" }
+        level <- get >>= return . length . stListLevel
         contents <- mapM (listItemToTextile opts) items
         modify $ \s -> s { stListLevel = init (stListLevel s) }
-        return $ vcat contents ++ "\n"
+        return $ vcat contents ++ (if level > 1 then "" else "\n")
 
 blockToTextile opts (DefinitionList items) = do
   contents <- withUseTags $ mapM (definitionListItemToTextile opts) items
diff --git a/tests/writer.textile b/tests/writer.textile
index f864e71f2..7fcda539d 100644
--- a/tests/writer.textile
+++ b/tests/writer.textile
@@ -172,8 +172,6 @@ h2. Nested
 ** Tab
 *** Tab
 
-
-
 Here's another:
 
 # First
@@ -181,7 +179,6 @@ Here's another:
 #* Fee
 #* Fie
 #* Foe
-
 # Third
 
 Same thing but with paragraphs:
@@ -191,7 +188,6 @@ Same thing but with paragraphs:
 #* Fee
 #* Fie
 #* Foe
-
 # Third
 
 h2. Tabs and spaces
@@ -201,7 +197,6 @@ h2. Tabs and spaces
 ** this is an example list item indented with tabs
 ** this is an example list item indented with spaces
 
-
 h2. Fancy list markers
 
  <ol start="2" style="list-style-type: decimal;">
@@ -237,7 +232,6 @@ Autonumbering:
 # More.
 ## Nested.
 
-
 Should not be a list item:
 
 M.A. 2007