strip trailing space (left behind by callouts) when copying source
authorDan Allen <dan@opendevise.com>
Sat, 12 Dec 2020 03:33:33 +0000 (20:33 -0700)
committerDan Allen <dan@opendevise.com>
Sat, 12 Dec 2020 03:33:33 +0000 (20:33 -0700)
src/js/06-copy-to-clipboard.js

index 9562dfa..ab1de52 100644 (file)
@@ -52,7 +52,7 @@
   }
 
   function writeToClipboard (code) {
-    var text = code.innerText
+    var text = code.innerText.replace(/ *$/gm, '')
     if (code.dataset.lang === 'console' && text.startsWith('$ ')) text = extractCommands(text)
     window.navigator.clipboard.writeText(text).then(
       function () {