Repository navigation
Fix Google Scholar references missing for a bare YAML bibliography - #15128
Merged
Merged
Conversation
With google-scholar enabled, a YAML bibliography that is not wrapped in --- delimiters produced no citation_reference tags. The Scholar metadata ran `pandoc <file> -t csljson`, and pandoc has no reader for a YAML bibliography: it falls back to markdown, which only finds references in a delimited metadata block. pandoc --bibliography accepts the bare forms, so documents rendered fine but lost their Scholar references. Read .yaml/.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 in a metadata block on stdin, as --metadata-file needs a map; its fields are still parsed by pandoc, so markdown titles and unquoted numbers behave as they do in the map form. The shape check uses the failsafe schema with json: true, so a duplicate key keeps the last value as pandoc does instead of failing the render. See #15125
Pandoc reads a YAML bibliography with any tag, standard (!!int, !!null) or custom (!foo), and keeps the value's text. The failsafe schema used to tell a references: map from a top-level list knows only str, seq and map, so a tagged value threw "unknown tag" and the Scholar references were dropped, including for delimited files that worked before. Extend the failsafe schema with a catch-all type per kind that keeps the untagged value. QuartoJSONSchema doesn't fit here: its implicit number types would turn an unquoted 1.10 into 1.1 on the list path, and it still rejects custom tags.
Collaborator
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
With
google-scholar: trueand a YAML bibliography not wrapped in---delimiters, the document renders fine but nocitation_referencetags are written for the cited works:Follow-up to #15125, which fixed the same conversion for a CSL JSON bibliography. CSL YAML with
---delimiters works today, which is why the YAML case looked fine there.Root cause
The Scholar metadata converts each bibliography with
pandoc <file> -t csljson. Pandoc has no reader for a YAML bibliography, so a.yamlfile is read as markdown, and only a delimited file is seen as a metadata block. Pandoc citeproc reads it differently:--bibliographytakes the first YAML document, either a map withreferencesor a top-level list of references. Both bare forms work for citations but give an empty list here.There is no
-fto pass for this, as was done for.json.Fix
For
.yamland.yml, a first YAML parse only tells the two shapes apart, and Pandoc still reads the fields:references:map goes through--metadata-file, which accepts it with or without delimiters{references: ...}in a metadata block on stdin, as--metadata-fileneeds a mapPandoc doing the field parsing keeps markdown in titles and values like an unquoted
volume: 1.10the same as in the delimited case. Converting the YAML to CSL JSON on our side was not used for that reason. The shape check accepts any YAML tag and keeps the last value of a duplicate key, like Pandoc, so delimited files that worked before still do.Not a regression, this conversion is the same since at least v1.4.
Checklist
I have (if applicable):
AI-assisted PR
Note: autonomous AI agents submitting PRs without human oversight are not permitted — see the Code of Conduct.