@@ -99,7 +99,7 @@ processCitations (Pandoc meta bs) = do
9999 let metanocites = lookupMeta "nocite" meta
100100 let Pandoc meta'' bs' =
101101 maybe id (setMeta "nocite") metanocites .
102− walk (mvPunct moveNotes locale) .
102+ walk (map capitalizeNoteCitation . mvPunct moveNotes locale) .
103103 (if styleIsNoteStyle sopts
104104 then walk addNote . walk deNote
105105 else id) .
@@ -564,28 +564,27 @@ extractText (FancyVal x) = toText x
564564extractText (NumVal n) = T.pack (show n)
565565extractText _ = mempty
566566
567−-- Here we take the Spans with class csl-note that are left
568−-- after deNote has removed nested ones, and convert them
569−-- into real notes.
567+capitalizeNoteCitation :: Inline -> Inline
568+capitalizeNoteCitation (Cite cs [Note [Para ils]]) =
569+ Cite cs
570+ [Note [Para $ B.toList $ addTextCase Nothing CapitalizeFirst
571+ $ B.fromList ils]]
572+capitalizeNoteCitation x = x
573+
570574addNote :: Inline -> Inline
571−addNote (Span ("",["csl-note"],[]) ils) =
572− Note [Para $
573− B.toList . addTextCase Nothing CapitalizeFirst . B.fromList $ ils]
575+addNote (Span ("",["csl-note"],[]) ils) = Note [Para ils]
574576addNote x = x
575577
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
581−deNote (Note bs) =
578+deNote :: [Inline] -> [Inline]
579+deNote [] = []
580+deNote (Note bs:rest) =
582581 case bs of
583582 [Para (cit@(Cite (c:_) _) : ils)]
584583 | citationMode c /= AuthorInText ->
585584 -- if citation is first in note, no need to parenthesize.
586585 Note [Para (walk removeNotes $ cit : walk addParens ils)]
587− _ -> Note (walk removeNotes . walk addParens $ bs)
588−
586+ : deNote rest
587+ _ -> Note (walk removeNotes . walk addParens $ bs) : deNote rest
589588 where
590589 addParens [] = []
591590 addParens (Cite (c:cs) ils : zs)
@@ -595,31 +594,25 @@ deNote (Note bs) =
595594 | otherwise
596595 = Cite (c:cs) (concatMap noteInParens ils) : addParens zs
597596 addParens (x:xs) = x : addParens xs
598−
599597 removeNotes (Span ("",["csl-note"],[]) ils) = Span ("",[],[]) ils
600598 removeNotes x = x
601−
602599 needsPeriod [] = True
603600 needsPeriod (Str t:_) = case T.uncons t of
604601 Nothing -> False
605602 Just (c,_) -> isUpper c
606603 needsPeriod (Space:zs) = needsPeriod zs
607604 needsPeriod _ = False
608−
609605 noteInParens (Span ("",["csl-note"],[]) ils)
610606 = Space : Str "(" :
611607 removeFinalPeriod ils ++ [Str ")"]
612608 noteInParens x = [x]
613−
614609 noteAfterComma needsPer (Span ("",["csl-note"],[]) ils)
615− | not (null ils)
616610 = Str "," : Space :
617611 if needsPer
618612 then ils
619613 else removeFinalPeriod ils
620614 noteAfterComma _ x = [x]
621−
622−deNote x = x
615+deNote (x:xs) = x : deNote xs
623616
624617-- Note: we can't use dropTextWhileEnd indiscriminately,
625618-- because this would remove the final period on abbreviations like Ibid.