Skip to content

Fix Google Scholar reference tags missing first and last page - #15118

Merged
cderv merged 3 commits into
mainfrom
fix/scholar-reference-page-range
Oct 20, 2026
Merged

cderv merged 3 commits into
mainfrom
fix/scholar-reference-page-range

Conversation

@cderv

@cderv cderv commented Oct 19, 2026 •

Copy link
Copy Markdown
Member

With google-scholar: true, the citation_reference tags written for bibliography entries never carry citation_firstpage or citation_lastpage. A .bib entry with pages = {97--111} gets neither, and one with pages = {42} gets no citation_firstpage either. The document's own citation does get them.

Root cause

googleScholarMeta writes the page tags only from CSL page-first and page-last. Pandoc's CSL JSON for a bibliography entry only has page (97--111 arrives as 97-111). The split of page into first and last page is done by pages() in src/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–111 with an en-dash, as written in CSL JSON or YAML, becomes the first page as is. 1-3, 7-9 gives 3, 7 as last page, and 97 - 111 keeps the spaces.

Fix

The page parsing moves to cslPageRange in src/core/csl.ts. It is used for the document citation, and for bibliography entries when page-first and page-last are not set. It splits on a hyphen, en-dash or em-dash and trims the result. For a page list like 1-3, 7-9, only citation_firstpage is written, as there is no single last page to report.

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, Codex (review)
  • 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.

`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.
@posit-snyk-bot

posit-snyk-bot commented Oct 19, 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 f93239c into main Oct 20, 2026
50 of 51 checks passed
@cderv
cderv deleted the fix/scholar-reference-page-range branch October 20, 2026 09:23
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
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