From 6fa06e8174a405e8028b17fa8579f265c4cbb5af Mon Sep 17 00:00:00 2001 From: craig-osterhout Date: Fri, 21 Oct 2022 09:03:57 -0700 Subject: [PATCH] remove $ prompt from code copy --- assets/js/copy.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/assets/js/copy.js b/assets/js/copy.js index 70c71076fc..4ca8bf561b 100644 --- a/assets/js/copy.js +++ b/assets/js/copy.js @@ -15,7 +15,9 @@ function copyCodeBlock(event) { const copyButton = event.currentTarget const codeBlock = copyButton.parentElement.querySelector("pre.highlight code") const code = codeBlock.innerText.trim() - window.navigator.clipboard.writeText(code) + // remove "$ " prompt at start of lines in code + const strippedCode = code.replace(/^[\s]?\$\s+/gm, "") + window.navigator.clipboard.writeText(strippedCode) // change the button text temporarily copyButton.textContent = "Copied!"