From 6051c751cef3cec46253bdb4a615d0ee3944f01f Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sun, 1 Nov 2020 10:37:12 -0800 Subject: 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. --- src/Text/Pandoc/Citeproc.hs | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) (limited to 'src/Text') 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. -- cgit v1.2.3