Biblio: Capitalize citation note only if it has a prefix.
So, author names or titles that aren't capitalized will stay uncapitalized.
This commit is contained in:
parent
b1be9cfaef
commit
52c5cdb04e
2 changed files with 11 additions and 7 deletions
|
@ -76,6 +76,7 @@
|
|||
+ Don't interfere with Notes that aren't citation notes.
|
||||
This fixes a bug in which notes not generated from citations were
|
||||
being altered (e.g. first letter capitalized) (#898).
|
||||
+ Only capitalize footnote citations when they have a prefix.
|
||||
+ Changes in suffix parsing. A suffix beginning with a digit gets 'p'
|
||||
inserted before it before passing to citeproc-hs, so that bare numbers
|
||||
are treated as page numbers by default. A suffix not beginning with
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue