Citeproc: avoid adding comma before an author-in-text citation...
...in a note if it begins with a title (no author). Closes #7761.
This commit is contained in:
parent
6b0a560ae7
commit
4b220d592c
2 changed files with 49 additions and 8 deletions
|
@ -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
|
||||
|
||||
|
|
35
test/command/7761.md
Normal file
35
test/command/7761.md
Normal file
|
@ -0,0 +1,35 @@
|
|||
```
|
||||
% pandoc --citeproc --csl command/chicago-fullnote-bibliography.csl -t plain
|
||||
---
|
||||
references:
|
||||
- id: noauthor
|
||||
issued: 2020
|
||||
publisher: Oxford University Press
|
||||
publisher-place: Oxford
|
||||
title: Title
|
||||
type: book
|
||||
- id: author
|
||||
author:
|
||||
- family: Jones
|
||||
given: Jim
|
||||
issued: 2021
|
||||
title: Title
|
||||
type: book
|
||||
url: "https://duckduckgo.com/cite2021"
|
||||
---
|
||||
|
||||
Text.[^n]
|
||||
|
||||
[^n]: See @author. Another example of a sea level mapping tool with
|
||||
similar limitations is @noauthor.
|
||||
^D
|
||||
Text.[1]
|
||||
|
||||
Jones, Jim. Title, 2021. https://duckduckgo.com/cite2021.
|
||||
|
||||
Title. Oxford: Oxford University Press, 2020.
|
||||
|
||||
[1] See Jim Jones, Title, 2021, https://duckduckgo.com/cite2021. Another
|
||||
example of a sea level mapping tool with similar limitations is Title
|
||||
(Oxford: Oxford University Press, 2020).
|
||||
```
|
Loading…
Add table
Reference in a new issue