git.iko.soy/typeable/pandoc
on master help sign in
Org reader: accept org-ref citations followed by commas

Bugfix for an issue which, whenever the citation was immediately followed by a comma, prevented correct parsing of org-ref citations.

commit4ca420e937471c568e6d14e8017e184d0959ae09 authorAlbert Krewinkel <albert@zeitkraut.de> dateFri 6 Jan 2017, 17:52 (10 years ago) parent21e6ca1
2 files changed+28−15
src/Text/Pandoc/Readers/Org/Inlines.hs+16−15 tests/Tests/Readers/Org.hs+12
src/Text/Pandoc/Readers/Org/Inlines.hs+16−15
@@ -198,21 +198,22 @@ orgRefCite = try $ choice
198198normalOrgRefCite :: OrgParser (F [Citation])
199199normalOrgRefCite = try $ do
200200 mode <- orgRefCiteMode
201− sequence <$> sepBy1 (orgRefCiteList mode) (char ',')
202− where
203− -- | A list of org-ref style citation keys, parsed as citation of the given
204− -- citation mode.
205− orgRefCiteList :: CitationMode -> OrgParser (F Citation)
206− orgRefCiteList citeMode = try $ do
207− key <- orgRefCiteKey
208− returnF $ Citation
209− { citationId = key
210− , citationPrefix = mempty
211− , citationSuffix = mempty
212− , citationMode = citeMode
213− , citationNoteNum = 0
214− , citationHash = 0
215− }
201+ -- | org-ref style citation key, parsed into a citation of the given mode
202+ let orgRefCiteItem :: OrgParser (F Citation)
203+ orgRefCiteItem = try $ do
204+ key <- orgRefCiteKey
205+ returnF $ Citation
206+ { citationId = key
207+ , citationPrefix = mempty
208+ , citationSuffix = mempty
209+ , citationMode = mode
210+ , citationNoteNum = 0
211+ , citationHash = 0
212+ }
213+ firstCitation <- orgRefCiteItem
214+ moreCitations <- many (try $ char ',' *> orgRefCiteItem)
215+ return . sequence $ firstCitation : moreCitations
216+ where
216217
217218-- | Read an Berkeley-style Org-mode citation. Berkeley citation style was
218219-- develop and adjusted to Org-mode style by John MacFarlane and Richard
tests/Tests/Readers/Org.hs+12
@@ -334,6 +334,18 @@ tests =
334334 }
335335 in (para $ cite [citation] "cite:pandoc")
336336
337+ , "Org-ref simple citation succeeded by comma" =:
338+ "cite:pandoc," =?>
339+ let citation = Citation
340+ { citationId = "pandoc"
341+ , citationPrefix = mempty
342+ , citationSuffix = mempty
343+ , citationMode = AuthorInText
344+ , citationNoteNum = 0
345+ , citationHash = 0
346+ }
347+ in (para $ cite [citation] "cite:pandoc" <> str ",")
348+
337349 , "Org-ref simple citep citation" =:
338350 "citep:pandoc" =?>
339351 let citation = Citation