From a331c69b4935b03d42f88f5346b700c795e09346 Mon Sep 17 00:00:00 2001
From: John MacFarlane <jgm@berkeley.edu>
Date: Thu, 24 Sep 2020 10:03:04 -0700
Subject: [PATCH] Slight improvement to last commit.

We now add a space only if there isn't already one.
(Some styles add a space at the end of the left-margin
div.)
---
 src/Text/Pandoc/Citeproc.hs | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/Text/Pandoc/Citeproc.hs b/src/Text/Pandoc/Citeproc.hs
index 71331a4a2..66b1cf74f 100644
--- a/src/Text/Pandoc/Citeproc.hs
+++ b/src/Text/Pandoc/Citeproc.hs
@@ -165,7 +165,10 @@ insertSpace ils =
       case Seq.lookup 0 rest of
         Just (Span ("",["csl-right-inline"],[]) _) ->
           Many $
-            Span ("",["csl-left-margin"],[]) (xs ++ [Space]) Seq.<| rest
+            Span ("",["csl-left-margin"],[]) (xs ++ case lastMay xs of
+                                                      Just Space -> []
+                                                      _          -> [Space])
+            Seq.<| rest
         _ -> ils
     _ -> ils