New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Code copy button adds new line #6327
Comments
Thanks for reporting. Fixed in 34d789b. We now remove trailing whitespace when copying. We deliberately decided not to remove leading whitespace, as I'm not sure what the implications of that might be – there are just too many languages. Trailing whitespace should be fine, except for when you're doing tutorials in the language Whitespace, probably. |
Thanks for the quick fix! :) |
Released as part of 9.4.9. |
I honestly did not want this to be fixed. Sometimes you want a line break at the end. |
Well, thank you! Your comment clearly communicates: there are always different use cases. We cannot possibly please everyone, albeit we try so hard. Unfortunately, we're likely keeping it that way, as it's quite useful for the majority. |
Context
No response
Bug description
Currently, when copying code with the code copy button, a new line is automatically added when pasting the copied code somewhere else. This does not happen if the code is copied manually by selecting everything in the code block.
Especially when copying code that should be run in a Terminal/command prompt, the new line that is automatically added when copying the code with the code copy button can lead to problems in some cases, e.g. code is run immediately when pasting. Expected behaviour of the code copy button should be exactly the same as for copying code manually: copy only the content in the code block without adding a new line.
Related links
Reproduction
9.4.8-code-copy-button.zip
Steps to reproduce
mkdocs.yml
:index.md
.Browser
No response
Before submitting
The text was updated successfully, but these errors were encountered: