diff options
author | John MacFarlane <jgm@berkeley.edu> | 2013-08-06 16:19:34 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2013-08-06 16:20:45 -0700 |
commit | 52c5cdb04e6c574f897c948e45084bf9343bf57c (patch) | |
tree | 302e55a4da51340264302a1c848b9a726159caa2 /src | |
parent | b1be9cfaef10f907e3439d4fa91b63b3402b233f (diff) | |
download | pandoc-52c5cdb04e6c574f897c948e45084bf9343bf57c.tar.gz |
Biblio: Capitalize citation note only if it has a prefix.
So, author names or titles that aren't capitalized will stay
uncapitalized.
Diffstat (limited to 'src')
-rw-r--r-- | src/Text/Pandoc/Biblio.hs | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/Text/Pandoc/Biblio.hs b/src/Text/Pandoc/Biblio.hs index d0db35ae7..755c779ea 100644 --- a/src/Text/Pandoc/Biblio.hs +++ b/src/Text/Pandoc/Biblio.hs @@ -84,11 +84,6 @@ mvPunct (Space : x : ys) | isNote x, startWithPunct ys = mvPunct (Space : x : ys) | isNote x = x : ys mvPunct xs = xs -sanitize :: [Inline] -> [Inline] -sanitize xs | endWithPunct xs = toCapital xs - | otherwise = toCapital (xs ++ [Str "."]) - - -- A replacement for citeproc-hs's endWithPunct, which wrongly treats -- a sentence ending in '.)' as not ending with punctuation, leading -- to an extra period. @@ -103,8 +98,8 @@ endWithPunct xs@(_:_) = case reverse (stringify [last xs]) of deNote :: Pandoc -> Pandoc deNote = topDown go - where go (Cite cs [Note [Para xs]]) = - Cite cs [Note $ bottomUp go' [Para $ sanitize xs]] + where go (Cite (c:cs) [Note xs]) = + Cite (c:cs) [Note $ bottomUp go' $ sanitize c xs] go (Note xs) = Note $ bottomUp go' xs go x = x go' (Note [Para xs]:ys) = @@ -112,6 +107,14 @@ deNote = topDown go then initInline xs ++ ys else xs ++ ys go' xs = xs + sanitize :: Citation -> [Block] -> [Block] + sanitize Citation{citationPrefix = pref} [Para xs] = + case (null pref, endWithPunct xs) of + (True, False) -> [Para $ xs ++ [Str "."]] + (True, True) -> [Para xs] + (False, False) -> [Para $ toCapital $ xs ++ [Str "."]] + (False, True) -> [Para $ toCapital xs] + sanitize _ bs = bs isTextualCitation :: [Citation] -> Bool isTextualCitation (c:_) = citationMode c == AuthorInText |