aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Text/Pandoc/Readers/Org/Inlines.hs31
-rw-r--r--tests/Tests/Readers/Org.hs12
2 files changed, 28 insertions, 15 deletions
diff --git a/src/Text/Pandoc/Readers/Org/Inlines.hs b/src/Text/Pandoc/Readers/Org/Inlines.hs
index 5f3df8d3e..56e3777c3 100644
--- a/src/Text/Pandoc/Readers/Org/Inlines.hs
+++ b/src/Text/Pandoc/Readers/Org/Inlines.hs
@@ -198,21 +198,22 @@ orgRefCite = try $ choice
normalOrgRefCite :: OrgParser (F [Citation])
normalOrgRefCite = try $ do
mode <- orgRefCiteMode
- sequence <$> sepBy1 (orgRefCiteList mode) (char ',')
- where
- -- | A list of org-ref style citation keys, parsed as citation of the given
- -- citation mode.
- orgRefCiteList :: CitationMode -> OrgParser (F Citation)
- orgRefCiteList citeMode = try $ do
- key <- orgRefCiteKey
- returnF $ Citation
- { citationId = key
- , citationPrefix = mempty
- , citationSuffix = mempty
- , citationMode = citeMode
- , citationNoteNum = 0
- , citationHash = 0
- }
+ -- | org-ref style citation key, parsed into a citation of the given mode
+ let orgRefCiteItem :: OrgParser (F Citation)
+ orgRefCiteItem = try $ do
+ key <- orgRefCiteKey
+ returnF $ Citation
+ { citationId = key
+ , citationPrefix = mempty
+ , citationSuffix = mempty
+ , citationMode = mode
+ , citationNoteNum = 0
+ , citationHash = 0
+ }
+ firstCitation <- orgRefCiteItem
+ moreCitations <- many (try $ char ',' *> orgRefCiteItem)
+ return . sequence $ firstCitation : moreCitations
+ where
-- | Read an Berkeley-style Org-mode citation. Berkeley citation style was
-- develop and adjusted to Org-mode style by John MacFarlane and Richard
diff --git a/tests/Tests/Readers/Org.hs b/tests/Tests/Readers/Org.hs
index 4462d81cc..0518f6932 100644
--- a/tests/Tests/Readers/Org.hs
+++ b/tests/Tests/Readers/Org.hs
@@ -334,6 +334,18 @@ tests =
}
in (para $ cite [citation] "cite:pandoc")
+ , "Org-ref simple citation succeeded by comma" =:
+ "cite:pandoc," =?>
+ let citation = Citation
+ { citationId = "pandoc"
+ , citationPrefix = mempty
+ , citationSuffix = mempty
+ , citationMode = AuthorInText
+ , citationNoteNum = 0
+ , citationHash = 0
+ }
+ in (para $ cite [citation] "cite:pandoc" <> str ",")
+
, "Org-ref simple citep citation" =:
"citep:pandoc" =?>
let citation = Citation