Skip to content

Fix Google Scholar render failure with a CSL JSON bibliography - #15125

Merged
cderv merged 2 commits into
mainfrom
fix/scholar-csl-json-s055
Oct 20, 2026
Merged

cderv merged 2 commits into
mainfrom
fix/scholar-csl-json-s055

Conversation

@cderv

@cderv cderv commented Oct 20, 2026 •

Copy link
Copy Markdown
Member

With google-scholar: true and a CSL JSON bibliography (bibliography: references.json), rendering a document that cites anything fails with:

Failed to generate bibliography, rendering failed with code 64
JSON parse error: Error in $: mempty

Found while working on Google Scholar reference metadata in #15118. The same document renders fine without google-scholar, and BibTeX and CSL YAML bibliographies work with it.

The Scholar metadata converts each bibliography with pandoc <file> -t csljson and lets Pandoc guess the input format from the extension. For .json, Pandoc picks its own JSON AST reader, not CSL JSON. Pandoc citeproc reads a .json bibliography as CSL JSON, so the fix passes -f csljson for .json files to match. This covers both the per-page tags and the book references page, which use the same conversion.

Not a regression, this conversion has been the same since at least v1.4.

Checklist

I have (if applicable):

  • referenced the GitHub issue this PR closes
  • updated the appropriate changelog in the PR
  • ensured the present test suite passes
  • added new tests
  • created a separate documentation PR in Quarto's website repo and linked it to this PR
AI-assisted PR
  • AI tool used: Claude Code
  • Codebase grounding: local clone
  • Human review: I have reviewed, tested, and verified the AI-generated content before submitting.

Note: autonomous AI agents submitting PRs without human oversight are not permitted — see the Code of Conduct.

cderv added 2 commits October 20, 2026 11:51
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 <file> -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.
@posit-snyk-bot

posit-snyk-bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Collaborator

✅ Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
✅ Open Source Security 0 0 0 0 0 issues
✅ Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@cderv
cderv merged commit 5001d8b into main Oct 20, 2026
51 checks passed
@cderv
cderv deleted the fix/scholar-csl-json-s055 branch October 20, 2026 11:31
cderv added a commit that referenced this pull request Oct 20, 2026
A YAML bibliography not wrapped in --- delimiters produced no
citation_reference tags with google-scholar enabled, so its references
were missing from the Scholar output. Pandoc has no reader for YAML
bibliographies, so the file was read as markdown, which only finds
references in a delimited metadata block. Read .yaml and .yml files the
way --bibliography does, from the first YAML document:

- A references: map goes through --metadata-file, so Pandoc's YAML
 reader handles it unchanged.
- A top-level list is wrapped as {references: ...} on stdin, since
 --metadata-file needs a map.
- The shape check accepts any YAML tag and keeps the last value of a
 duplicate key, as Pandoc does, so delimited files that worked before
 still do.

See #15125 for the CSL JSON case of the same conversion.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants