File tree Expand file tree Collapse file tree 2 files changed +29
-6
lines changed
src/resources/formats/html/templates
tests/docs/smoke-all/2025/09/02 Expand file tree Collapse file tree 2 files changed +29
-6
lines changed Original file line number Diff line number Diff line change 9696 }
9797
9898 const getTextToCopy = function (trigger ) {
99- const codeEl = trigger .previousElementSibling .cloneNode (true );
100- for ( const childEl of codeEl . children ) {
101- if ( isCodeAnnotation (childEl) ) {
102- childEl . remove ();
103- }
99+ const outerScaffold = trigger .parentElement .cloneNode (true );
100+ const codeEl = outerScaffold . querySelector ( ' code ' );
101+ for ( const childEl of codeEl . children ) {
102+ if ( isCodeAnnotation (childEl)) {
103+ childEl . remove ();
104104 }
105- return codeEl .innerText ;
105+ }
106+ return codeEl .innerText ;
106107 }
107108
108109 const clipboard = new window.ClipboardJS (' .code-copy-button:not([data-in-quarto-modal])' , {
Original file line number Diff line number Diff line change 1+ ---
2+ format : html
3+ code-copy : true
4+ code-annotations : hover
5+ _quarto :
6+ tests :
7+ html :
8+ # we need to check two things:
9+ # 1. the parent of the button is the scaffold div
10+ # 2. the scaffold div contains the code element
11+ ensureHtmlElements :
12+ - - "div.code-copy-outer-scaffold > button.code-copy-button"
13+ - " div.code-copy-outer-scaffold code.sourceCode"
14+ - []
15+ ---
16+
17+ ``` python
18+ # A commented line
19+ print (" Hello, World!" ) # <1>
20+ ```
21+
22+ 1 . This line prints "Hello, World!" to the console.
You can’t perform that action at this time.
0 commit comments