@@ -99,7 +99,7 @@ processCitations (Pandoc meta bs) = do
99 let metanocites = lookupMeta "nocite" meta
99 let metanocites = lookupMeta "nocite" meta
100 let Pandoc meta'' bs' =
100 let Pandoc meta'' bs' =
101 maybe id (setMeta "nocite") metanocites .
101 maybe id (setMeta "nocite") metanocites .
102− walk (mvPunct moveNotes locale) .
102+ walk (map capitalizeNoteCitation . mvPunct moveNotes locale) .
103 (if styleIsNoteStyle sopts
103 (if styleIsNoteStyle sopts
104 then walk addNote . walk deNote
104 then walk addNote . walk deNote
105 else id) .
105 else id) .
@@ -564,28 +564,27 @@ extractText (FancyVal x) = toText x
564extractText (NumVal n) = T.pack (show n)
564extractText (NumVal n) = T.pack (show n)
565extractText _ = mempty
565extractText _ = mempty
567−-- Here we take the Spans with class csl-note that are left
567+capitalizeNoteCitation :: Inline -> Inline
568−-- after deNote has removed nested ones, and convert them
568+capitalizeNoteCitation (Cite cs [Note [Para ils]]) =
569−-- into real notes.
569+ Cite cs
570+ [Note [Para $ B.toList $ addTextCase Nothing CapitalizeFirst
572+capitalizeNoteCitation x = x
570addNote :: Inline -> Inline
574addNote :: Inline -> Inline
571−addNote (Span ("",["csl-note"],[]) ils) =
575+addNote (Span ("",["csl-note"],[]) ils) = Note [Para ils]
573− B.toList . addTextCase Nothing CapitalizeFirst . B.fromList $ ils]
574addNote x = x
576addNote x = x
576−-- Here we handle citation notes that occur inside footnotes
577−-- or other citation notes, in a note style. We don't want
578−-- notes inside notes, so we convert these to parenthesized
579−-- or comma-separated citations.
580−deNote :: Inline -> Inline
578+deNote :: [Inline] -> [Inline]
581−deNote (Note bs) =
580+deNote (Note bs:rest) =
582 case bs of
581 case bs of
583 [Para (cit@(Cite (c:_) _) : ils)]
582 [Para (cit@(Cite (c:_) _) : ils)]
584 | citationMode c /= AuthorInText ->
583 | citationMode c /= AuthorInText ->
585 -- if citation is first in note, no need to parenthesize.
584 -- if citation is first in note, no need to parenthesize.
586 Note [Para (walk removeNotes $ cit : walk addParens ils)]
585 Note [Para (walk removeNotes $ cit : walk addParens ils)]
587− _ -> Note (walk removeNotes . walk addParens $ bs)
587+ _ -> Note (walk removeNotes . walk addParens $ bs) : deNote rest
590 addParens [] = []
589 addParens [] = []
591 addParens (Cite (c:cs) ils : zs)
590 addParens (Cite (c:cs) ils : zs)
@@ -595,31 +594,25 @@ deNote (Note bs) =
595 | otherwise
594 | otherwise
596 = Cite (c:cs) (concatMap noteInParens ils) : addParens zs
595 = Cite (c:cs) (concatMap noteInParens ils) : addParens zs
597 addParens (x:xs) = x : addParens xs
596 addParens (x:xs) = x : addParens xs
599 removeNotes (Span ("",["csl-note"],[]) ils) = Span ("",[],[]) ils
597 removeNotes (Span ("",["csl-note"],[]) ils) = Span ("",[],[]) ils
600 removeNotes x = x
598 removeNotes x = x
602 needsPeriod [] = True
599 needsPeriod [] = True
603 needsPeriod (Str t:_) = case T.uncons t of
600 needsPeriod (Str t:_) = case T.uncons t of
604 Nothing -> False
601 Nothing -> False
605 Just (c,_) -> isUpper c
602 Just (c,_) -> isUpper c
606 needsPeriod (Space:zs) = needsPeriod zs
603 needsPeriod (Space:zs) = needsPeriod zs
607 needsPeriod _ = False
604 needsPeriod _ = False
609 noteInParens (Span ("",["csl-note"],[]) ils)
605 noteInParens (Span ("",["csl-note"],[]) ils)
610 = Space : Str "(" :
606 = Space : Str "(" :
611 removeFinalPeriod ils ++ [Str ")"]
607 removeFinalPeriod ils ++ [Str ")"]
612 noteInParens x = [x]
608 noteInParens x = [x]
614 noteAfterComma needsPer (Span ("",["csl-note"],[]) ils)
609 noteAfterComma needsPer (Span ("",["csl-note"],[]) ils)
616 = Str "," : Space :
610 = Str "," : Space :
617 if needsPer
611 if needsPer
619 else removeFinalPeriod ils
613 else removeFinalPeriod ils
620 noteAfterComma _ x = [x]
614 noteAfterComma _ x = [x]
622−deNote x = x
615+deNote (x:xs) = x : deNote xs
624-- Note: we can't use dropTextWhileEnd indiscriminately,
617-- Note: we can't use dropTextWhileEnd indiscriminately,
625-- because this would remove the final period on abbreviations like Ibid.
618-- because this would remove the final period on abbreviations like Ibid.