Repository navigation
Citation BibTeX copy button is shown but does nothing with code-copy: false #15207
Description
With code-copy: false, the BibTeX block in the citation appendix still gets a copy button, but clicking it does nothing.
---
title: "Citation BibTeX block without code-copy"
author: "Author name"
date: "2025-01-01"
format: html
citation: true
code-copy: false
---code-copy: false correctly removes the copy button from the document code blocks, and it also means clipboard.js is not loaded and the copy script is not added to the page. However the citation appendix adds its copy button and scaffold to the BibTeX block unconditionally, without looking at code-copy:
quarto-cli/src/format/html/format-html-appendix.ts
Lines 306 to 315 in 734f424
| const bibTexDiv = createCodeBlock(doc, cite.bibtex, "bibtex"); | |
| bibTexDiv.classList.add(kQuartoCiteBibtexClass); | |
| const outerScaffold = doc.createElement("div"); | |
| outerScaffold.classList.add("code-copy-outer-scaffold"); | |
| outerScaffold.appendChild(bibTexDiv); | |
| contentsDiv.appendChild(outerScaffold); | |
| const copyButton = createCodeCopyButton(doc, format); | |
| outerScaffold.appendChild(copyButton); |
while the option is only checked for the regular code blocks and the clipboard dependency:
quarto-cli/src/format/html/format-html.ts
Lines 309 to 313 in 734f424
| if (featureDefaults.copyCode) { | |
| options.copyCode = format.metadata[kCodeCopy] !== false; | |
| } else { | |
| options.copyCode = format.metadata[kCodeCopy] || false; | |
| } |
So the button is rendered with its icon, but nothing is wired to it. This has been the case since the BibTeX block was made copyable, it is not a regression. It is more visible now since #14387 moved the button inside the BibTeX block.
We could resolve code-copy the same way in the appendix and only add the button when it is enabled, so the BibTeX block behaves like the other code blocks of the document.
Workaround
Hide the button with some CSS, for example in a styles.css file referenced with css: styles.css:
#quarto-citation .code-copy-button {
display: none;
}Or keep code-copy enabled (true or the default hover) if a working copy button on code blocks is fine for the document.
Activity
Respect code-copy for the citation BibTeX copy button (quarto-dev#15209)