diff --git a/assets/js/just-the-docs.js b/assets/js/just-the-docs.js
index 07d4f07620ffe7c9938e9c9c2265ba6d30e3be64..953c6154307840c909f4e2cef643025e79f29055 100644
--- a/assets/js/just-the-docs.js
+++ b/assets/js/just-the-docs.js
@@ -504,7 +504,7 @@ jtd.onReady(function(){
 
     copyButton.addEventListener('click', function () {
       if(timeout === null) {
-        var code = codeBlock.querySelector('pre:not(.lineno)').innerText;
+        var code = (codeBlock.querySelector('pre:not(.lineno, .highlight)') || codeBlock.querySelector('code')).innerText;
         window.navigator.clipboard.writeText(code);
 
         copyButton.innerHTML = svgCopied;