git.iko.soy/typeable/pandoc
on master help sign in
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

commit743f7216de98556a316301ac72b8606bafc2deee authorAlbert Krewinkel <albert@zeitkraut.de> dateThu 18 Feb 2021, 21:53 (6 years ago) parentef741f3
2 files changed+41−1
src/Text/Pandoc/Readers/Org/Inlines.hs+1−1 test/Tests/Readers/Org/Inline/Citation.hs+40
src/Text/Pandoc/Readers/Org/Inlines.hs+1−1
@@ -322,7 +322,7 @@ linkLikeOrgRefCite = try $ do
322322-- from the `org-ref-cite-re` variable in `org-ref.el`.
323323orgRefCiteKey :: PandocMonad m => OrgParser m Text
324324orgRefCiteKey =
325− let citeKeySpecialChars = "-_:\\./," :: String
325+ let citeKeySpecialChars = "-_:\\./" :: String
326326 isCiteKeySpecialChar c = c `elem` citeKeySpecialChars
327327 isCiteKeyChar c = isAlphaNum c || isCiteKeySpecialChar c
328328 endOfCitation = try $ do
test/Tests/Readers/Org/Inline/Citation.hs+40
@@ -116,6 +116,46 @@ tests =
116116 }
117117 in (para $ cite [citation] "citep:pandoc")
118118
119+ , "multiple simple citations" =:
120+ "citep:picard,riker" =?>
121+ let picard = Citation
122+ { citationId = "picard"
123+ , citationPrefix = mempty
124+ , citationSuffix = mempty
125+ , citationMode = NormalCitation
126+ , citationNoteNum = 0
127+ , citationHash = 0
128+ }
129+ riker = Citation
130+ { citationId = "riker"
131+ , citationPrefix = mempty
132+ , citationSuffix = mempty
133+ , citationMode = NormalCitation
134+ , citationNoteNum = 0
135+ , citationHash = 0
136+ }
137+ in (para $ cite [picard,riker] "citep:picard,riker")
138+
139+ , "multiple simple citations succeeded by comma" =:
140+ "citep:picard,riker," =?>
141+ let picard = Citation
142+ { citationId = "picard"
143+ , citationPrefix = mempty
144+ , citationSuffix = mempty
145+ , citationMode = NormalCitation
146+ , citationNoteNum = 0
147+ , citationHash = 0
148+ }
149+ riker = Citation
150+ { citationId = "riker"
151+ , citationPrefix = mempty
152+ , citationSuffix = mempty
153+ , citationMode = NormalCitation
154+ , citationNoteNum = 0
155+ , citationHash = 0
156+ }
157+ in (para $ cite [picard,riker] "citep:picard,riker" <> str ",")
158+
119159 , "extended citation" =:
120160 "[[citep:Dominik201408][See page 20::, for example]]" =?>
121161 let citation = Citation