dvc.org icon indicating copy to clipboard operation
dvc.org copied to clipboard

Add copy button to code blocks

Open daavoo opened this issue 3 years ago • 5 comments

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

daavoo avatar May 09 '22 14:05 daavoo

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 🤔

julieg18 avatar May 09 '22 15:05 julieg18

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 avatar May 09 '22 15:05 shcheklein

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?

daavoo avatar May 09 '22 16:05 daavoo

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

shcheklein avatar May 09 '22 16:05 shcheklein

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.

jorgeorpinel avatar May 10 '22 00:05 jorgeorpinel