aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2020-11-01 10:37:12 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2020-11-01 10:48:47 -0800
commit6051c751cef3cec46253bdb4a615d0ee3944f01f (patch)
tree26557b34b93fb7f23b907927a471f16187875b64 /src/Text/Pandoc
parent01f2d811683ccae5677233c8f5d9067671619e0b (diff)
downloadpandoc-6051c751cef3cec46253bdb4a615d0ee3944f01f.tar.gz
Citeproc: use comma for in-text citations inside footnotes.
When an author-in-text citation like `@foo` occurs in a footnote, we now render it with: `AUTHOR NAME + COMMA + SPACE + REST`. Previously we rendered: `AUTHOR NAME + SPACE + "(" + REST + ")"`. This gives better results. Note that normal citations are still rendered in parentheses.
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r--src/Text/Pandoc/Citeproc.hs26
1 files changed, 18 insertions, 8 deletions
diff --git a/src/Text/Pandoc/Citeproc.hs b/src/Text/Pandoc/Citeproc.hs
index 75cbe6991..8976ae560 100644
--- a/src/Text/Pandoc/Citeproc.hs
+++ b/src/Text/Pandoc/Citeproc.hs
@@ -524,16 +524,26 @@ capitalizeNoteCitation (Cite cs [Note [Para ils]]) =
$ B.fromList ils]]
capitalizeNoteCitation x = x
-deNote :: Inline -> Inline
-deNote (Note bs) = Note $ walk go bs
+deNote :: [Inline] -> [Inline]
+deNote [] = []
+deNote (Note bs:rest) =
+ Note (walk go bs) : deNote rest
where
- go (Cite cs ils) = Cite cs (concatMap removeNote ils)
+ go (Cite (c:cs) ils)
+ | citationMode c == AuthorInText
+ = Cite cs (concatMap noteAfterComma ils)
+ | otherwise
+ = Cite cs (concatMap noteInParens ils)
go x = x
- removeNote (Note bs')
- = Space : Str "(" : (removeFinalPeriod
- (blocksToInlines bs')) ++ [Str ")"]
- removeNote x = [x]
-deNote x = x
+ noteInParens (Note bs')
+ = Space : Str "(" :
+ removeFinalPeriod (blocksToInlines bs') ++ [Str ")"]
+ noteInParens x = [x]
+ noteAfterComma (Note bs')
+ = Str "," : Space :
+ removeFinalPeriod (blocksToInlines bs')
+ noteAfterComma x = [x]
+deNote (x:xs) = x : deNote xs
-- Note: we can't use dropTextWhileEnd indiscriminately,
-- because this would remove the final period on abbreviations like Ibid.