diff options
Diffstat (limited to 'src/Text/Pandoc/Biblio.hs')
-rw-r--r-- | src/Text/Pandoc/Biblio.hs | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/Text/Pandoc/Biblio.hs b/src/Text/Pandoc/Biblio.hs index ae371a46d..31c55472e 100644 --- a/src/Text/Pandoc/Biblio.hs +++ b/src/Text/Pandoc/Biblio.hs @@ -32,7 +32,7 @@ module Text.Pandoc.Biblio ( processBiblio ) where import Data.List import Data.Char ( isDigit, isPunctuation ) import qualified Data.Map as M -import Text.CSL hiding ( Cite(..), Citation(..) ) +import Text.CSL hiding ( Cite(..), Citation(..), endWithPunct ) import qualified Text.CSL as CSL ( Cite(..) ) import Text.Pandoc.Definition import Text.Pandoc.Generic @@ -88,6 +88,19 @@ 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. +endWithPunct :: [Inline] -> Bool +endWithPunct [] = True +endWithPunct xs@(_:_) = case reverse (stringify [last xs]) of + [] -> True + (')':c:_) | isEndPunct c -> True + (c:_) | isEndPunct c -> True + | otherwise -> False + where isEndPunct c = c `elem` ".,;:!?" + deNote :: Pandoc -> Pandoc deNote = topDown go where go (Note [Para xs]) = Note $ bottomUp go' [Para $ sanitize xs] |