mirror of https://github.com/docker/docs.git
remove $ prompt from code copy
This commit is contained in:
parent
8ebd41f2f6
commit
6fa06e8174
|
|
@ -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!"
|
||||
|
|
|
|||
Loading…
Reference in New Issue