Org reader: fix bug in org-ref citation parsing.

The org-ref syntax allows to list multiple citations separated by comma.
This fixes a bug that accepted commas as part of the citation id, so all
citation lists were parsed as one single citation.

Fixes: #7101
This commit is contained in:
Albert Krewinkel 2021-02-18 21:53:19 +01:00
parent ef741f3842
commit 743f7216de
No known key found for this signature in database
GPG key ID: 388DC0B21F631124
2 changed files with 41 additions and 1 deletions

View file

@ -322,7 +322,7 @@ linkLikeOrgRefCite = try $ do
-- from the `org-ref-cite-re` variable in `org-ref.el`.
orgRefCiteKey :: PandocMonad m => OrgParser m Text
orgRefCiteKey =
let citeKeySpecialChars = "-_:\\./," :: String
let citeKeySpecialChars = "-_:\\./" :: String
isCiteKeySpecialChar c = c `elem` citeKeySpecialChars
isCiteKeyChar c = isAlphaNum c || isCiteKeySpecialChar c
endOfCitation = try $ do

View file

@ -116,6 +116,46 @@ tests =
}
in (para $ cite [citation] "citep:pandoc")
, "multiple simple citations" =:
"citep:picard,riker" =?>
let picard = Citation
{ citationId = "picard"
, citationPrefix = mempty
, citationSuffix = mempty
, citationMode = NormalCitation
, citationNoteNum = 0
, citationHash = 0
}
riker = Citation
{ citationId = "riker"
, citationPrefix = mempty
, citationSuffix = mempty
, citationMode = NormalCitation
, citationNoteNum = 0
, citationHash = 0
}
in (para $ cite [picard,riker] "citep:picard,riker")
, "multiple simple citations succeeded by comma" =:
"citep:picard,riker," =?>
let picard = Citation
{ citationId = "picard"
, citationPrefix = mempty
, citationSuffix = mempty
, citationMode = NormalCitation
, citationNoteNum = 0
, citationHash = 0
}
riker = Citation
{ citationId = "riker"
, citationPrefix = mempty
, citationSuffix = mempty
, citationMode = NormalCitation
, citationNoteNum = 0
, citationHash = 0
}
in (para $ cite [picard,riker] "citep:picard,riker" <> str ",")
, "extended citation" =:
"[[citep:Dominik201408][See page 20::, for example]]" =?>
let citation = Citation