-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Remove leading $, > and # chars from clipboard of console snippets #1346
Conversation
Hello folks, just a friendly reminder about this PR :D |
I'm a little concerned this would be surprising behavior more than it'd be helpful behavior, so I don't feel comfortable merging it. Especially since it's trivial for a user to remove special leading characters from console output. Not blocking though in case someone else approves. |
Hi @frewsxcv. I did not get your point. Would you mind to elaborate a little bit more on the reason to not accept this PR? From my point of view, as a user/consumer of the Rust book that uses mdBook, I expect that the action of copying/pasting console snippets just works without the need to remove a unnecessary leading char. The related PR/Issues shows that other users think the same. |
I've encountered this behavior (i.e. copy button excludes shell prompts) on a few other sites in the past, and personally have always found it pleasantly surprising. I can't think of many circumstances where this would be the "wrong thing" to do (and on the few occasions when it would be undesirable, it can be worked around trivially, by manually selecting the entire block, including the prompts - whereas removing the prompt characters is a more drawn out manual process). Here's an online demo for another implementation of the same feature, which can be used to try out the behaviour (and workaround): https://sphinx-copybutton.readthedocs.io/en/latest/ Also here's another example of irritation with the current behaviour. The example cited is a (broken link) to the Embedded Rust "Discovery" mdBook, which has since moved here. |
Hi @tim-seoss, thanks for your comment. I really like the |
Here is another example of a copy button that removes the leading |
Here's the GitHub Issue and PR for this feature: readthedocs/readthedocs.org#4698 readthedocs/readthedocs.org#4990 And here's the library they're using: https://sbrunner.github.io/sphinx-prompt/ This seems to be a different approach than the one proposed in this PR. Their approach requires the user to opt-in to making the prompt prefix symbol unselectable, whereas the approach in this PR is to remove all prompt prefix symbols whether the user wants it or not |
Looking at: https://sphinx-copybutton.readthedocs.io/en/latest/
When this default hasn't been opted out of, the user is still able to easily select the text, including the prompts i.e.
The prompt stripping only occurs when the copy icon at the edge of the text block element. If you consider the case where the user is presented with a list of 5 shell commands, and wants to execute them all, having visually inspected them... i.e. With this functionality in place the user has: ... you can verify this by experimenting with the example in the above link. Without the functionality (or with it disabled), the user has: I can't think of an occasion when I've wanted to copy shell commands with the prompts, but if I did, it would still be reasonably easy to do-so (and by an IMO intuitive method). |
I began reading the Book today, and I came here to find if there already was an issue or a PR about this. It would be a nice feature to have in my (very humble) opinion! |
I wanted this feature, so I implemented it in my project's custom mdBook back-end. The result is available online. NB: As a comment above notes, it's very fragile (I won't even try disputing that, I'm fine with relying on impl details & having to update those bodges periodically for my own stuff), but it still produces something that works for the end user and can be judged, and the implementation will be cleaned up if this is deemed good enough to upstream. The logic is as follows:
It's not the most general logic, it's what works for my case; the custom renderer is a bunch of bodges, so I didn't bother making it generic & clean, but I would bother if this was to be upstreamed. Rationale:
|
Given how often people create issue on the rust book I think most users find this surprising that the $ is copied. |
Independent of this PR as it currently stands, is there any consensus on whether this would a useful enhancement? I suppose the options are:
Personally, I think as an opt-in feature it would allow each individual book author to decide on whether this was appropriate, so wouldn't risk changing behaviour in a surprising way for any existing books. Any thoughts? |
I think it's useful to apply it to the |
Hi folks! I had forgotten this PR (as it's been here for almost 2 years). I think it would be nice to have an opt-in if this is something that might cause unexpected behaviors when forced. |
I'd consider the |
I ran into this issue again today when copying
from https://doc.rust-lang.org/book/ch01-01-installation.html#installing-rustup-on-linux-or-macos. |
Closing this. There’s absolutely no point in keeping such a simple change waiting for 3+ years for a resolution. |
@ehuss and @Dylan-DPC, the issue this meant to address just got flagged up again over on TRPL. Is there anything I can do to help get this particular PR or another like it actually landed? |
This PR aims to add a function to remove leading
$
,>
, and#
characters from the clipboard of console snippets.Related PR: #1110
Related issues: #864, rust-lang/book#1756, rust-lang/book#2420, rust-lang/book#2179,