diff options
author | John MacFarlane <jgm@berkeley.edu> | 2021-12-18 12:13:06 -0800 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2021-12-18 12:13:06 -0800 |
commit | 4b220d592c163efb0bf5a0e1db2ed7d6be9c69e7 (patch) | |
tree | 2773cc26efe3f8ab49141a4d2aa94b527cc30ff8 /src/Text/Pandoc | |
parent | 6b0a560ae71b5ca7c2439d7470bed7b02c362a64 (diff) | |
download | pandoc-4b220d592c163efb0bf5a0e1db2ed7d6be9c69e7.tar.gz |
Citeproc: avoid adding comma before an author-in-text citation...
...in a note if it begins with a title (no author).
Closes #7761.
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r-- | src/Text/Pandoc/Citeproc.hs | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/src/Text/Pandoc/Citeproc.hs b/src/Text/Pandoc/Citeproc.hs index f235f6e01..03a15e9f6 100644 --- a/src/Text/Pandoc/Citeproc.hs +++ b/src/Text/Pandoc/Citeproc.hs @@ -543,7 +543,7 @@ deNote (Note bs) = addParens [] = [] addParens (Cite (c:cs) ils : zs) | citationMode c == AuthorInText - = Cite (c:cs) (concatMap (noteAfterComma (needsPeriod zs)) ils) : + = Cite (c:cs) (addCommas (needsPeriod zs) ils) : addParens zs | otherwise = Cite (c:cs) (concatMap noteInParens ils) : addParens zs @@ -564,13 +564,19 @@ deNote (Note bs) = removeFinalPeriod ils ++ [Str ")"] noteInParens x = [x] - noteAfterComma needsPer (Span ("",["csl-note"],[]) ils) - | not (null ils) - = Str "," : Space : - if needsPer - then ils - else removeFinalPeriod ils - noteAfterComma _ x = [x] + -- We want to add a comma before a CSL note citation, but not + -- before the author name, and not before the first citation + -- if it doesn't begin with an author name. + addCommas = addCommas' True -- boolean == "at beginning" + + addCommas' _ _ [] = [] + addCommas' atBeginning needsPer + (Span ("",["csl-note"],[]) ils : rest) + | not (null ils) + = (if atBeginning then id else ([Str "," , Space] ++)) $ + (if needsPer then ils else removeFinalPeriod ils) ++ + addCommas' False needsPer rest + addCommas' _ needsPer (il : rest) = il : addCommas' False needsPer rest deNote x = x |