git.iko.soy/typeable/pandoc
on master help sign in
Fix short-title.

We were getting null short-titles generated, and that was creating wrong citations in some cases. Close #6702.

commita8220679039f214b0642e598fab1d3b470383eb4 authorJohn MacFarlane <jgm@berkeley.edu> dateSat 26 Sep 2020, 14:26 (6 years ago) parent5a388ab
2 files changed+27−24
src/Text/Pandoc/Citeproc/BibTeX.hs+9−10 test/command/pandoc-citeproc-chicago-fullnote-bibliography.md+18−14
src/Text/Pandoc/Citeproc/BibTeX.hs+9−10
@@ -263,13 +263,12 @@ itemToReference locale variant item = do
263263 B.toList . resolveKey lang <$>
264264 getTitle "series") <|>
265265 return Nothing
266− shortTitle' <- Just <$>
267− ((guard (not hasMaintitle || isChapterlike) >>
268− getTitle "shorttitle")
269− <|> if (subtitle' /= mempty || titleaddon' /= mempty) &&
270− not hasMaintitle
271− then getShortTitle False "title"
272− else getShortTitle True "title")
266+ shortTitle' <- (Just <$> (guard (not hasMaintitle || isChapterlike) >>
267+ getTitle "shorttitle"))
268+ <|> (if (subtitle' /= mempty || titleaddon' /= mempty) &&
269+ not hasMaintitle
270+ then getShortTitle False "title"
271+ else getShortTitle True "title")
273272 <|> return Nothing
274273
275274 eventTitle' <- Just <$> getTitle "eventtitle" <|> return Nothing
@@ -747,12 +746,12 @@ getTitle f = do
747746 let processTitle = if utc then unTitlecase (Just lang) else id
748747 return $ processTitle ils
749748
750−getShortTitle :: Bool -> Text -> Bib Inlines
749+getShortTitle :: Bool -> Text -> Bib (Maybe Inlines)
751750getShortTitle requireColon f = do
752751 ils <- splitStrWhen (==':') . B.toList <$> getTitle f
753752 if not requireColon || containsColon ils
754− then return $ B.fromList $ upToColon ils
755− else return mempty
753+ then return $ Just $ B.fromList $ upToColon ils
754+ else return Nothing
756755
757756containsColon :: [Inline] -> Bool
758757containsColon xs = Str ":" `elem` xs
test/command/pandoc-citeproc-chicago-fullnote-bibliography.md+18−14
@@ -102,33 +102,37 @@ Sam Smith. Oxford: Oxford University Press, 2007.
102102
103103[^2]: [**Nonexistent?**](#ref-nonexistent)
104104
105−[^3]: [2005](#ref-item1).
105+[^3]: [*First Book*, 2005](#ref-item1).
106106
107107[^4]: [Ibid., 30](#ref-item1).
108108
109109[^5]: [Ibid.](#ref-item1), with suffix.
110110
111−[^6]: [2005](#ref-item1); [2006, 30](#ref-item2); see also [Doe and
112− Roe](#ref-пункт3).
111+[^6]: [*First Book*, 2005](#ref-item1); ["Article," 2006,
112+ 30](#ref-item2); see also [Doe and Roe, "Why Water Is
113+ Wet"](#ref-пункт3).
113114
114−[^7]: [Doe and Roe](#ref-пункт3) ([12](#ref-пункт3)) and a citation
115− without locators ([Doe and Roe](#ref-пункт3)).
115+[^7]: [Doe and Roe](#ref-пункт3) (["Why Water Is Wet," 12](#ref-пункт3))
116+ and a citation without locators ([Doe and Roe, "Why Water Is
117+ Wet"](#ref-пункт3)).
116118
117−[^8]: See [Doe, 2005, chap. 3](#ref-item1); also [Doe and Roe,
118− 34--35](#ref-пункт3).
119+[^8]: See [Doe, *First Book*, 2005, chap. 3](#ref-item1); also [Doe and
120+ Roe, "Why Water Is Wet," 34--35](#ref-пункт3).
119121
120−[^9]: See [Doe, 2005, 34--35](#ref-item1).
122+[^9]: See [Doe, *First Book*, 2005, 34--35](#ref-item1).
121123
122−[^10]: Some citations (See [ibid., chap. 3](#ref-item1); [Doe and
123− Roe](#ref-пункт3); [Doe, 2006](#ref-item2)).
124+[^10]: Some citations (See [ibid., chap. 3](#ref-item1); [Doe and Roe,
125+ "Why Water Is Wet"](#ref-пункт3); [Doe, "Article,"
126+ 2006](#ref-item2)).
124127
125−[^11]: [Doe, 2005, 33, 35--37](#ref-item1), and nowhere else.
128+[^11]: [Doe, *First Book*, 2005, 33, 35--37](#ref-item1), and nowhere
129+ else.
126130
127−[^12]: [Doe, 2005](#ref-item1) and nowhere else.
131+[^12]: [Doe, *First Book*, 2005](#ref-item1) and nowhere else.
128132
129133[^13]: Like a citation without author: ([Ibid.](#ref-item1)), and again
130− ([Ibid.](#ref-item1)), and now Doe with a locator ([2006,
134+ ([Ibid.](#ref-item1)), and now Doe with a locator (["Article," 2006,
131135 44](#ref-item2)).
132136
133−[^14]: *See* [Doe, 2005, 32](#ref-item1).
137+[^14]: *See* [Doe, *First Book*, 2005, 32](#ref-item1).
134138```