From beb9e38f994535127695d8a215ffce5185782ab1 Mon Sep 17 00:00:00 2001 From: Charles Teague Date: Tue, 6 Sep 2022 09:55:59 -0400 Subject: [PATCH] Always add `citeproc` to filters when it is explicitly enabled Fixes #2294 --- news/changelog-1.2.md | 3 ++- src/command/render/filters.ts | 22 +++++++++++++++++++--- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/news/changelog-1.2.md b/news/changelog-1.2.md index 390ab87077..7d4f7e250c 100644 --- a/news/changelog-1.2.md +++ b/news/changelog-1.2.md @@ -47,9 +47,10 @@ - Handle CNAME file for `gh-pages` either without or without protocol prefix (e.g. https://) -## Bibliographies +## Bibliographies and Citations - Support formats `bibtex`, `biblatex`, and `csljson`. When rendered to one of these formats any citations within the document will be rendered as the specified bibliography format. +- Always add citeproc filter if `citeproc: true` is specified, even if there isn't a bibliography or references in the document (#2294) ## Miscellaneous diff --git a/src/command/render/filters.ts b/src/command/render/filters.ts index bcc8846784..c75b4642e1 100644 --- a/src/command/render/filters.ts +++ b/src/command/render/filters.ts @@ -582,13 +582,29 @@ function citeMethod(options: PandocOptions): CiteMethod | null { // no handler if no references const pandoc = options.format.pandoc; const metadata = options.format.metadata; + + // determine the engine, if provided + const engine = bibEngine(options.format.pandoc, options.flags); + + // If the user is explicitly enabling citeproc: true, use this as the citemethod + // even when there may be no bibliography (see + // https://github.com/quarto-dev/quarto-cli/issues/2294 for an example of why) + if (pandoc.citeproc) { + // If both citeproc and a bib engine are specified, throw an error + if (engine) { + throw new Error( + `The bibliography engine '${engine}' was set when 'citeproc' was also explicitly requested.`, + ); + } + + return "citeproc"; + } + + // No bibliography or refences, and no explicit request, so no engine specified if (!metadata[kBibliography] && !metadata.references) { return null; } - // collect config - const engine = bibEngine(options.format.pandoc, options.flags); - // if it's pdf-based output check for natbib or biblatex if (engine) { return engine;