Skip to content
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

Add copy button to code blocks #181

Open
daavoo opened this issue May 9, 2022 · 6 comments
Open

Add copy button to code blocks #181

daavoo opened this issue May 9, 2022 · 6 comments

Comments

@daavoo
Copy link
Contributor

daavoo commented May 9, 2022

It would be nice to have a button to copy the entire content of code blocks, like the one supported in GitHub markdown:

pip install dvclive

Captura de Pantalla 2022-05-09 a las 16 45 59

@julieg18
Copy link
Contributor

julieg18 commented May 9, 2022

Should be doable since we can turn our code blocks into React components! The hardest part that comes to mind is making sure we parse the different types of code blocks correctly so that the copied code actually looks right 🤔

@shcheklein
Copy link
Member

the biggest question I had thinking about this - should be copy outputs as well:

$ dvc plots show
Plots file is ....

# Now run ...
$ dvc plots diff
Some output

what should we copy in this case?

@shcheklein shcheklein added the A: website Website development label May 9, 2022
@daavoo
Copy link
Contributor Author

daavoo commented May 9, 2022

what should we copy in this case?

We could leave this decision up to the writer, which can decide whether to split code and output into 2 separated blocks?

@shcheklein
Copy link
Member

which can decide whether to split code and output into 2 separated blocks

feel too complicated, will looks a bit ugly I guess ... can be done though, yep

@jorgeorpinel
Copy link

jorgeorpinel commented May 10, 2022

Would need to be applicable to some CLI blocks specifically indeed. Doesn't sound like an easy implementation. Triple click does the trick too but I'm not sure how many people are aware.

@omesser
Copy link

omesser commented Mar 5, 2023

Can we maybe reprioritize this and simplify? Having guides without this seems lacking

No need for fancy logic IMO - we can start with:

  • Asking for this explicitly (i.e. not a feature of cli). We can add a component similar to cli, but "asking for this feature"- called cli-guide or cli-with-copy to make this explicit and not break all existing snippets.
  • Have it copy all the contents as is, with the exception of shaving terminal-curser token (^$ to support multiple commands) which should be relatively easy I hope.

It will be possible to expand on that in the future with robust logic to differentiate between the command(s) and outputs. But we can do without it today.
Thoughts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants