diff options
author | John MacFarlane <jgm@berkeley.edu> | 2020-11-01 10:37:12 -0800 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2020-11-01 10:48:47 -0800 |
commit | 6051c751cef3cec46253bdb4a615d0ee3944f01f (patch) | |
tree | 26557b34b93fb7f23b907927a471f16187875b64 | |
parent | 01f2d811683ccae5677233c8f5d9067671619e0b (diff) | |
download | pandoc-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.
-rw-r--r-- | src/Text/Pandoc/Citeproc.hs | 26 | ||||
-rw-r--r-- | test/command/pandoc-citeproc-chicago-fullnote-bibliography.md | 2 |
2 files changed, 19 insertions, 9 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. diff --git a/test/command/pandoc-citeproc-chicago-fullnote-bibliography.md b/test/command/pandoc-citeproc-chicago-fullnote-bibliography.md index 71f6c47c7..4dfa091c0 100644 --- a/test/command/pandoc-citeproc-chicago-fullnote-bibliography.md +++ b/test/command/pandoc-citeproc-chicago-fullnote-bibliography.md @@ -114,7 +114,7 @@ Sam Smith. Oxford: Oxford University Press, 2007. Roe, "Why Water Is Wet," in *Third Book*, ed. Sam Smith (Oxford: Oxford University Press, 2007)](#ref-пункт3). -[^7]: [Doe and Roe](#ref-пункт3) (["Why Water Is Wet," 12](#ref-пункт3)) +[^7]: [Doe and Roe](#ref-пункт3), ["Why Water Is Wet," 12](#ref-пункт3) and a citation without locators ([Doe and Roe, "Why Water Is Wet"](#ref-пункт3)). |