git.iko.soy/typeable/pandoc
on master help sign in
Biblio: Capitalize citation note only if it has a prefix.

So, author names or titles that aren't capitalized will stay uncapitalized.

commit52c5cdb04e6c574f897c948e45084bf9343bf57c authorJohn MacFarlane <jgm@berkeley.edu> dateTue 6 Aug 2013, 16:19 (13 years ago) parentb1be9cf
2 files changed+11−7
changelog+1 src/Text/Pandoc/Biblio.hs+10−7
changelog+1
@@ -76,6 +76,7 @@
7676 + Don't interfere with Notes that aren't citation notes.
7777 This fixes a bug in which notes not generated from citations were
7878 being altered (e.g. first letter capitalized) (#898).
79+ + Only capitalize footnote citations when they have a prefix.
7980 + Changes in suffix parsing. A suffix beginning with a digit gets 'p'
8081 inserted before it before passing to citeproc-hs, so that bare numbers
8182 are treated as page numbers by default. A suffix not beginning with
src/Text/Pandoc/Biblio.hs+10−7
@@ -84,11 +84,6 @@ mvPunct (Space : x : ys) | isNote x, startWithPunct ys =
8484mvPunct (Space : x : ys) | isNote x = x : ys
8585mvPunct xs = xs
8686
87−sanitize :: [Inline] -> [Inline]
88−sanitize xs | endWithPunct xs = toCapital xs
89− | otherwise = toCapital (xs ++ [Str "."])
90−
91−
9287-- A replacement for citeproc-hs's endWithPunct, which wrongly treats
9388-- a sentence ending in '.)' as not ending with punctuation, leading
9489-- to an extra period.
@@ -103,8 +98,8 @@ endWithPunct xs@(_:_) = case reverse (stringify [last xs]) of
10398
10499deNote :: Pandoc -> Pandoc
105100deNote = topDown go
106− where go (Cite cs [Note [Para xs]]) =
107− Cite cs [Note $ bottomUp go' [Para $ sanitize xs]]
101+ where go (Cite (c:cs) [Note xs]) =
102+ Cite (c:cs) [Note $ bottomUp go' $ sanitize c xs]
108103 go (Note xs) = Note $ bottomUp go' xs
109104 go x = x
110105 go' (Note [Para xs]:ys) =
@@ -112,6 +107,14 @@ deNote = topDown go
112107 then initInline xs ++ ys
113108 else xs ++ ys
114109 go' xs = xs
110+ sanitize :: Citation -> [Block] -> [Block]
111+ sanitize Citation{citationPrefix = pref} [Para xs] =
112+ case (null pref, endWithPunct xs) of
113+ (True, False) -> [Para $ xs ++ [Str "."]]
114+ (True, True) -> [Para xs]
115+ (False, False) -> [Para $ toCapital $ xs ++ [Str "."]]
116+ (False, True) -> [Para $ toCapital xs]
117+ sanitize _ bs = bs
115118
116119isTextualCitation :: [Citation] -> Bool
117120isTextualCitation (c:_) = citationMode c == AuthorInText