Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions src/resources/formats/html/templates/quarto-html-after-body.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,14 @@
}

const getTextToCopy = function(trigger) {
const codeEl = trigger.previousElementSibling.cloneNode(true);
for (const childEl of codeEl.children) {
if (isCodeAnnotation(childEl)) {
childEl.remove();
}
const outerScaffold = trigger.parentElement.cloneNode(true);
const codeEl = outerScaffold.querySelector('code');
for (const childEl of codeEl.children) {
if (isCodeAnnotation(childEl)) {
childEl.remove();
}
return codeEl.innerText;
}
return codeEl.innerText;
}

const clipboard = new window.ClipboardJS('.code-copy-button:not([data-in-quarto-modal])', {
Expand Down
22 changes: 22 additions & 0 deletions tests/docs/smoke-all/2025/09/02/issue-13196.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
format: html
code-copy: true
code-annotations: hover
_quarto:
tests:
html:
# we need to check two things:
# 1. the parent of the button is the scaffold div
# 2. the scaffold div contains the code element
ensureHtmlElements:
- - "div.code-copy-outer-scaffold > button.code-copy-button"
- "div.code-copy-outer-scaffold code.sourceCode"
- []
---

```python
# A commented line
print("Hello, World!") # <1>
```

1. This line prints "Hello, World!" to the console.
Loading