From 35df24e698d93d8e9a39099184e62ac0c16770a9 Mon Sep 17 00:00:00 2001
From: John MacFarlane <jgm@berkeley.edu>
Date: Fri, 15 Feb 2019 10:09:46 -0800
Subject: [PATCH] JATS reader: handle citations with multiple references.

The rid attribute can have a space-separated list of ids.

Closes #5310.
---
 src/Text/Pandoc/Readers/JATS.hs | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/src/Text/Pandoc/Readers/JATS.hs b/src/Text/Pandoc/Readers/JATS.hs
index 232bf8b96..52a18347c 100644
--- a/src/Text/Pandoc/Readers/JATS.hs
+++ b/src/Text/Pandoc/Readers/JATS.hs
@@ -470,16 +470,19 @@ parseInline (Elem e) =
         "xref" -> do
             ils <- innerInlines
             let rid = attrValue "rid" e
+            let rids = words rid
             let refType = ("ref-type",) <$> maybeAttrValue "ref-type" e
             let attr = (attrValue "id" e, [], maybeToList refType)
             return $ if refType == Just ("ref-type","bibr")
-                        then cite [Citation{
-                                         citationId = rid
-                                       , citationPrefix = []
-                                       , citationSuffix = []
-                                       , citationMode = NormalCitation
-                                       , citationNoteNum = 0
-                                       , citationHash = 0}] ils
+                        then cite
+                             (map (\id' ->
+                                     Citation{ citationId = id'
+                                             , citationPrefix = []
+                                             , citationSuffix = []
+                                             , citationMode = NormalCitation
+                                             , citationNoteNum = 0
+                                             , citationHash = 0}) rids)
+                             ils
                         else linkWith attr ('#' : rid) "" ils
         "ext-link" -> do
              ils <- innerInlines