Repository navigation
Fix Google Scholar reference tags missing first and last page - #15118
Merged
Merged
Conversation
`citation_reference` tags for bibliography entries never carried `citation_firstpage` or `citation_lastpage`. The Scholar writer reads only CSL `page-first`/`page-last`, and Pandoc's CSL JSON for a bibliography entry has only `page` (BibTeX `97--111` arrives as `97-111`). The split of `page` into first and last page existed only for the document's own citation. That split also mishandled values the document citation can receive: an en-dash range (`97–111`, as written in CSL JSON or YAML) became the first page, a page list (`1-3, 7-9`) gave the last page `3, 7`, and spaced ranges kept their spaces. The parsing moves to `cslPageRange` in `core/csl.ts`, used for both the document citation and bibliography entries. It accepts hyphen, en-dash and em-dash separators, trims, and for a page list writes only the first page rather than inventing an extent.
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 was referenced Oct 20, 2026
cderv
added a commit
to quarto-dev/quarto-web
that referenced
this pull request
Oct 20, 2026
From Quarto 1.11, the CSL `page` value is split into a first and last page for each `citation_reference` tag, as well as for the document citation. The split accepts a hyphen, en dash or em dash. A page list such as `1-3, 7-9` gives only a first page. Explicit `page-first` and `page-last` values take precedence over the split. The Citation Fields table now documents this. Related to quarto-dev/quarto-cli#15118
cderv
added a commit
that referenced
this pull request
Oct 20, 2026
With google-scholar enabled, rendering a document that cites from a CSL JSON bibliography (.json) failed with "JSON parse error: Error in $: mempty". The Scholar metadata ran `pandoc <file> -t csljson` without an input format, so pandoc read the .json file as its own JSON AST. Pass `-f csljson` for .json bibliographies. The conversion dates back to v1.4, so this affected every Scholar render with a CSL JSON bibliography. The per-page tags and the book references page both go through it. See #15118
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: true, thecitation_referencetags written for bibliography entries never carrycitation_firstpageorcitation_lastpage. A.bibentry withpages = {97--111}gets neither, and one withpages = {42}gets nocitation_firstpageeither. The document's own citation does get them.Root cause
googleScholarMetawrites the page tags only from CSLpage-firstandpage-last. Pandoc's CSL JSON for a bibliography entry only haspage(97--111arrives as97-111). The split ofpageinto first and last page is done bypages()insrc/quarto-core/attribution/document.ts, which only runs for the document citation.That split also gives wrong values for the document citation, as it only splits on a hyphen. A
page: 97–111with an en-dash, as written in CSL JSON or YAML, becomes the first page as is.1-3, 7-9gives3, 7as last page, and97 - 111keeps the spaces.Fix
The page parsing moves to
cslPageRangeinsrc/core/csl.ts. It is used for the document citation, and for bibliography entries whenpage-firstandpage-lastare not set. It splits on a hyphen, en-dash or em-dash and trims the result. For a page list like1-3, 7-9, onlycitation_firstpageis written, as there is no single last page to report.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.