Skip to content

Fix citation BibTeX copy button shown with code-copy: false - #15209

Merged
cderv merged 3 commits into
mainfrom
fix-bibtex-dead-copy-button
Oct 27, 2026
Merged

cderv merged 3 commits into
mainfrom
fix-bibtex-dead-copy-button

Conversation

@cderv

@cderv cderv commented Oct 27, 2026

Copy link
Copy Markdown
Member

With code-copy: false, the BibTeX block in the citation appendix still gets a copy button that does nothing. Found while reviewing #14387, which moved the button inside the BibTeX block and made it more visible.

Root cause

processDocumentAppendix adds the code-with-copy class, the code-copy-outer-scaffold wrapper and the copy button to the BibTeX block unconditionally, and has done so since the block was made copyable in 2022. With code-copy: false, clipboard.js and the ClipboardJS setup script are not added to the page, so nothing is wired to the button.

Fix

The appendix now only adds the class, scaffold and button when code copy is enabled, using the same resolution as the other code blocks of the document. With code-copy: false the BibTeX block is still rendered, without the button.

That resolution was inlined twice in format-html.ts. It moves to formatHasCodeCopy() in format-html-shared.ts, together with htmlFormatFeatureDefaults() so the minimal default stays computed in one place. The shared module was chosen because the appendix cannot import format-html.ts without a cycle (format-html.ts imports the bootstrap postprocessor, which calls the appendix).

Fixes #15207

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: DeepWiki MCP, 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 3 commits October 27, 2026 15:10
The citation appendix added a copy button, its scaffold and the
code-with-copy class to the BibTeX block unconditionally, since the block
was made copyable in 0579ebc. With `code-copy: false`, clipboard.js and
the ClipboardJS setup script are not emitted, so the button was rendered
with its icon but did nothing.

The appendix now gates the class, scaffold and button on the same
resolved option as other code blocks. The resolution was inlined twice in
format-html.ts; it moves to formatHasCodeCopy() in format-html-shared.ts
so the appendix can share it without importing format-html.ts, which
imports the bootstrap postprocessor that calls the appendix.
createCodeBlock no longer adds code-with-copy itself, as the appendix is
its only caller.
formatHasCodeCopy() re-derived the code-copy default from 'minimal', duplicating htmlFormatFeatureDefaults(). That function was private to format-html.ts, which the appendix cannot import without a cycle (format-html.ts -> bootstrap -> appendix). Moving it to format-html-shared.ts keeps the feature defaults in one place for every caller.
@posit-snyk-bot

posit-snyk-bot commented Oct 27, 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 210691f into main Oct 27, 2026
52 checks passed
@cderv
cderv deleted the fix-bibtex-dead-copy-button branch October 27, 2026 15:18
cderv added a commit that referenced this pull request Oct 27, 2026
The appendix BibTeX block was inserted as HTML, so the parser decoded
entity-like text in the Pandoc output: R\&notebook showed as R\¬ebook
and a\&lt;b as a\<b. The block now holds the text as Pandoc wrote it,
with LF line endings, and the copy button copies the same text.

- Set the BibTeX block with textContent in createCodeBlock, and
  normalize newlines to LF
- Add regression fixtures for entity-like text in titles

Fixes #15210
See #15209
@cderv cderv added this to the v1.11 milestone Oct 27, 2026
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.

Citation BibTeX copy button is shown but does nothing with code-copy: false

2 participants