Skip to content

Commit db92f61

Browse files
committed
Citeproc: don't link citations if suppress-bibliography specified.
For there will be nothing to link to. Closes #9163.
1 parent d3d0406 commit db92f61

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

src/Text/Pandoc/Citeproc.hs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,9 @@ processCitations (Pandoc meta bs) = do
7676
let citations = getCitations locale otherIdsMap $ Pandoc meta' bs
7777

7878

79-
let linkCites = maybe False truish $ lookupMeta "link-citations" meta
79+
let linkCites = maybe False truish (lookupMeta "link-citations" meta) &&
80+
-- don't link citations if no bibliography to link to:
81+
not (maybe False truish (lookupMeta "suppress-bibliography" meta))
8082
let linkBib = maybe True truish $ lookupMeta "link-bibliography" meta
8183
let opts = defaultCiteprocOptions{ linkCitations = linkCites
8284
, linkBibliography = linkBib }
@@ -479,9 +481,9 @@ isYesValue _ = False
479481
insertRefs :: [(Text,Text)] -> [Text] -> [Block] -> Pandoc -> Pandoc
480482
insertRefs _ _ [] d = d
481483
insertRefs refkvs refclasses refs (Pandoc meta bs) =
482-
if isRefRemove meta
483-
then Pandoc meta bs
484-
else case runState (walkM go (Pandoc meta bs)) False of
484+
case lookupMeta "suppress-bibliography" meta of
485+
Just x | truish x -> Pandoc meta bs
486+
_ -> case runState (walkM go (Pandoc meta bs)) False of
485487
(d', True) -> d'
486488
(Pandoc meta' bs', False)
487489
-> Pandoc meta' $
@@ -517,10 +519,6 @@ refTitle meta =
517519
Just (MetaBlocks [Para ils]) -> Just ils
518520
_ -> Nothing
519521

520-
isRefRemove :: Meta -> Bool
521-
isRefRemove meta =
522-
maybe False truish $ lookupMeta "suppress-bibliography" meta
523-
524522
legacyDateRanges :: Reference Inlines -> Reference Inlines
525523
legacyDateRanges ref =
526524
ref{ referenceVariables = M.map go $ referenceVariables ref }

0 commit comments

Comments
 (0)