From 7eceb74d76747f1197e375a7106eb4ccbbb26f3a Mon Sep 17 00:00:00 2001 From: Christophe Dervieux Date: Tue, 20 Oct 2026 11:51:30 +0200 Subject: [PATCH 1/2] Read a .json bibliography as CSL JSON for Google Scholar metadata With google-scholar enabled and a CSL JSON bibliography (a .json file, the format Zotero exports as "CSL JSON"), rendering a document that cites anything failed with "JSON parse error: Error in $: mempty". renderToCSLJSON converts each bibliography with `pandoc -t csljson` and lets pandoc guess the input format. For a .json input pandoc picks its own JSON AST reader, not CSL JSON. When pandoc processes a bibliography itself (citeproc), it maps .json to CSL JSON, so the visible bibliography rendered fine and only the Scholar metadata step broke. Passing `-f csljson` for .json files matches that mapping. BibTeX and CSL YAML bibliographies already worked. The failure is old (the conversion is unchanged since v1.4) and reaches both the per-page Scholar tags and the book references page regeneration. --- src/core/bibliography.ts | 7 ++++++- .../2026/10/14/scholar-references/csl-json.qmd | 15 +++++++++++++++ .../2026/10/14/scholar-references/references.json | 9 +++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 tests/docs/smoke-all/2026/10/14/scholar-references/csl-json.qmd create mode 100644 tests/docs/smoke-all/2026/10/14/scholar-references/references.json diff --git a/src/core/bibliography.ts b/src/core/bibliography.ts index e9ce8c44d78..8c2ef439c43 100644 --- a/src/core/bibliography.ts +++ b/src/core/bibliography.ts @@ -7,7 +7,7 @@ * Adapted from: https://github.com/watson/ci-info */ -import { dirname, isAbsolute, join } from "../deno_ral/path.ts"; +import { dirname, extname, isAbsolute, join } from "../deno_ral/path.ts"; import { kBibliography } from "../config/constants.ts"; import { Metadata } from "../config/types.ts"; import { asArray } from "./array.ts"; @@ -85,6 +85,11 @@ export async function renderToCSLJSON( // in which case just leave it alone (otherwise it is cwd relative) const biblioPath = join(dir, biblio); const cmd = [pandocBinaryPath()]; + // Without -f, pandoc reads a .json input as its own JSON AST + if (extname(biblioPath).toLowerCase() === ".json") { + cmd.push("-f"); + cmd.push("csljson"); + } cmd.push( isAbsolute(biblioPath) ? biblioPath : join(Deno.cwd(), biblioPath), ); diff --git a/tests/docs/smoke-all/2026/10/14/scholar-references/csl-json.qmd b/tests/docs/smoke-all/2026/10/14/scholar-references/csl-json.qmd new file mode 100644 index 00000000000..0e3ac51f98e --- /dev/null +++ b/tests/docs/smoke-all/2026/10/14/scholar-references/csl-json.qmd @@ -0,0 +1,15 @@ +--- +title: Scholar metadata for a CSL JSON bibliography +format: html +google-scholar: true +bibliography: references.json +_quarto: + tests: + html: + ensureHtmlElements: + - ['meta[name="citation_reference"][content*="citation_author=Alice Smith;"]'] +--- + +The bibliography is a CSL JSON file. Pandoc reads a bare `.json` input as its own JSON AST, so the Scholar reference tags need the bibliography read explicitly as CSL JSON. + +This article cites one work [@cited]. diff --git a/tests/docs/smoke-all/2026/10/14/scholar-references/references.json b/tests/docs/smoke-all/2026/10/14/scholar-references/references.json new file mode 100644 index 00000000000..c7faed185d9 --- /dev/null +++ b/tests/docs/smoke-all/2026/10/14/scholar-references/references.json @@ -0,0 +1,9 @@ +[ + { + "id": "cited", + "type": "article-journal", + "title": "Cited reference", + "author": [{ "family": "Smith", "given": "Alice" }], + "issued": { "date-parts": [[2024]] } + } +] From 479aa6c232ffaf03eace49eb9281cecff0ba0c26 Mon Sep 17 00:00:00 2001 From: Christophe Dervieux Date: Tue, 20 Oct 2026 11:55:10 +0200 Subject: [PATCH 2/2] Add changelog entry for #15125 --- news/changelog-1.11.md | 1 + 1 file changed, 1 insertion(+) diff --git a/news/changelog-1.11.md b/news/changelog-1.11.md index af6697373b4..4a4dd339fba 100644 --- a/news/changelog-1.11.md +++ b/news/changelog-1.11.md @@ -64,6 +64,7 @@ All changes included in 1.11: - ([#15108](https://github.com/quarto-dev/quarto-cli/pull/15108)): Fix Google Scholar metadata showing formatting markup such as `` in `citation_reference` tags for bibliography entries, and `undefined` as the book title of a chapter without one. - ([#15115](https://github.com/quarto-dev/quarto-cli/pull/15115)): Fix Google Scholar writing two `citation_reference` tags for a reference defined in two bibliography files. The tag now describes the entry Pandoc renders. - ([#15118](https://github.com/quarto-dev/quarto-cli/pull/15118)): Fix Google Scholar metadata missing the first and last page of bibliography entries, and giving wrong pages for a citation `page` written with an en-dash or as a page list. +- ([#15125](https://github.com/quarto-dev/quarto-cli/pull/15125)): Fix Google Scholar metadata failing the render with a CSL JSON (`.json`) bibliography. ### `pdf`