aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Citeproc/BibTeX.hs
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2020-09-26 14:26:06 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2020-09-26 14:28:28 -0700
commita8220679039f214b0642e598fab1d3b470383eb4 (patch)
treeaef6a39722a46f27d25180bb048123341c9f66bf /src/Text/Pandoc/Citeproc/BibTeX.hs
parent5a388ab2f5c8d0d109e139fd03ac1dd62bcbec57 (diff)
downloadpandoc-a8220679039f214b0642e598fab1d3b470383eb4.tar.gz
Fix short-title.
We were getting null short-titles generated, and that was creating wrong citations in some cases. Close #6702.
Diffstat (limited to 'src/Text/Pandoc/Citeproc/BibTeX.hs')
-rw-r--r--src/Text/Pandoc/Citeproc/BibTeX.hs19
1 files changed, 9 insertions, 10 deletions
diff --git a/src/Text/Pandoc/Citeproc/BibTeX.hs b/src/Text/Pandoc/Citeproc/BibTeX.hs
index 5919fee77..607442adb 100644
--- a/src/Text/Pandoc/Citeproc/BibTeX.hs
+++ b/src/Text/Pandoc/Citeproc/BibTeX.hs
@@ -263,13 +263,12 @@ itemToReference locale variant item = do
B.toList . resolveKey lang <$>
getTitle "series") <|>
return Nothing
- shortTitle' <- Just <$>
- ((guard (not hasMaintitle || isChapterlike) >>
- getTitle "shorttitle")
- <|> if (subtitle' /= mempty || titleaddon' /= mempty) &&
- not hasMaintitle
- then getShortTitle False "title"
- else getShortTitle True "title")
+ shortTitle' <- (Just <$> (guard (not hasMaintitle || isChapterlike) >>
+ getTitle "shorttitle"))
+ <|> (if (subtitle' /= mempty || titleaddon' /= mempty) &&
+ not hasMaintitle
+ then getShortTitle False "title"
+ else getShortTitle True "title")
<|> return Nothing
eventTitle' <- Just <$> getTitle "eventtitle" <|> return Nothing
@@ -747,12 +746,12 @@ getTitle f = do
let processTitle = if utc then unTitlecase (Just lang) else id
return $ processTitle ils
-getShortTitle :: Bool -> Text -> Bib Inlines
+getShortTitle :: Bool -> Text -> Bib (Maybe Inlines)
getShortTitle requireColon f = do
ils <- splitStrWhen (==':') . B.toList <$> getTitle f
if not requireColon || containsColon ils
- then return $ B.fromList $ upToColon ils
- else return mempty
+ then return $ Just $ B.fromList $ upToColon ils
+ else return Nothing
containsColon :: [Inline] -> Bool
containsColon xs = Str ":" `elem` xs