Repository navigation
Fix citation BibTeX copy button shown with code-copy: false - #15209
Merged
Merged
Conversation
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.
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. |
3 of 5 tasks
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\¬ebook showed as R\¬ebook and a\<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
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
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
processDocumentAppendixadds thecode-with-copyclass, thecode-copy-outer-scaffoldwrapper and the copy button to the BibTeX block unconditionally, and has done so since the block was made copyable in 2022. Withcode-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: falsethe BibTeX block is still rendered, without the button.That resolution was inlined twice in
format-html.ts. It moves toformatHasCodeCopy()informat-html-shared.ts, together withhtmlFormatFeatureDefaults()so theminimaldefault stays computed in one place. The shared module was chosen because the appendix cannot importformat-html.tswithout a cycle (format-html.tsimports the bootstrap postprocessor, which calls the appendix).Fixes #15207
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.