Handle 'nocite' better with --biblatex and --natbib.

Previously the nocite metadata field was ignored with
these formats.  Now it populates a `nocite-ids` template
variable and causes a `\nocite` command to be issued.

Closes #4585.
This commit is contained in:
John MacFarlane 2021-03-14 00:09:36 -08:00
parent c55a73b642
commit 3622097da3
2 changed files with 13 additions and 2 deletions

View file

@ -372,6 +372,9 @@ $for(bibliography)$
\addbibresource{$bibliography$}
$endfor$
$endif$
$if(nocite-ids)$
\nocite{$for(nocite-ids)$$it$$sep$, $endfor$}
$endif$
$if(csl-refs)$
\newlength{\cslhangindent}
\setlength{\cslhangindent}{1.5em}

View file

@ -1,4 +1,5 @@
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE PatternGuards #-}
{-# LANGUAGE ScopedTypeVariables #-}
@ -145,6 +146,11 @@ pandocToLaTeX options (Pandoc meta blocks) = do
let dirs = query (extract "dir") blocks
let nociteIds = query (\case
Cite cs _ -> map citationId cs
_ -> [])
$ lookupMetaInlines "nocite" meta
let context = defField "toc" (writerTableOfContents options) $
defField "toc-depth" (tshow
(writerTOCDepth options -
@ -177,9 +183,11 @@ pandocToLaTeX options (Pandoc meta blocks) = do
else id) $
(case writerCiteMethod options of
Natbib -> defField "biblio-title" biblioTitle .
defField "natbib" True
defField "natbib" True .
defField "nocite-ids" nociteIds
Biblatex -> defField "biblio-title" biblioTitle .
defField "biblatex" True
defField "biblatex" True .
defField "nocite-ids" nociteIds
_ -> id) $
defField "colorlinks" (any hasStringValue
["citecolor", "urlcolor", "linkcolor", "toccolor",