From b7f1c97b6a6ab129fc994f2a5502a44f12bad0de Mon Sep 17 00:00:00 2001
From: John MacFarlane <jgm@berkeley.edu>
Date: Fri, 4 Feb 2022 23:28:46 -0800
Subject: [PATCH] Docx zotero/mendeley/endnote: add comma before locator in
 suffix.

---
 src/Text/Pandoc/Readers/Docx.hs          | 6 +++---
 test/docx/mendeley_citations_plus.native | 4 ++--
 test/docx/zotero_citations_plus.native   | 2 +-
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/Text/Pandoc/Readers/Docx.hs b/src/Text/Pandoc/Readers/Docx.hs
index faef5b517..5f20477d2 100644
--- a/src/Text/Pandoc/Readers/Docx.hs
+++ b/src/Text/Pandoc/Readers/Docx.hs
@@ -503,9 +503,9 @@ handleCitation citation = do
                 , citationPrefix = maybe [] (toList . text) $
                                      Citeproc.citationItemPrefix item
                 , citationSuffix = (toList . text) $
-                    maybe mempty (\x ->
-                       fromMaybe "" (Citeproc.citationItemLabel item)
-                         <> " " <> x <> " ")
+                    maybe mempty (\x -> ", " <>
+                       maybe "" (<>" ") (Citeproc.citationItemLabel item)
+                         <> x <> " ")
                      (Citeproc.citationItemLocator item)
                     <> fromMaybe mempty (Citeproc.citationItemSuffix item)
                 , citationMode = NormalCitation -- TODO for now
diff --git a/test/docx/mendeley_citations_plus.native b/test/docx/mendeley_citations_plus.native
index d3226b0c6..53867ca22 100644
--- a/test/docx/mendeley_citations_plus.native
+++ b/test/docx/mendeley_citations_plus.native
@@ -268,7 +268,7 @@ Pandoc
               { citationId = "ITEM-1"
               , citationPrefix = [ Str "prefix" ]
               , citationSuffix =
-                  [ Space , Str "123" , Space , Str "suffix" ]
+                  [ Str ",", Space , Str "123" , Space , Str "suffix" ]
               , citationMode = NormalCitation
               , citationNoteNum = 0
               , citationHash = 0
@@ -302,7 +302,7 @@ Pandoc
               { citationId = "ITEM-1"
               , citationPrefix = [ Str "prefix" ]
               , citationSuffix =
-                  [ Space , Str "10-20" , Space , Str "suffix" ]
+                  [ Str ",", Space , Str "10-20" , Space , Str "suffix" ]
               , citationMode = NormalCitation
               , citationNoteNum = 0
               , citationHash = 0
diff --git a/test/docx/zotero_citations_plus.native b/test/docx/zotero_citations_plus.native
index df8849fca..829fda8b7 100644
--- a/test/docx/zotero_citations_plus.native
+++ b/test/docx/zotero_citations_plus.native
@@ -412,7 +412,7 @@ Pandoc
               { citationId = "10"
               , citationPrefix = [ Str "prefix" ]
               , citationSuffix =
-                  [ Space , Str "2" , Space , Str "suffix" ]
+                  [ Str ",", Space , Str "2" , Space , Str "suffix" ]
               , citationMode = NormalCitation
               , citationNoteNum = 0
               , citationHash = 0