vuejs / vitepress

Vite & Vue powered static site generator.
https://vitepress.dev
MIT License
12.35k stars 2.01k forks source link

Partially Copying Code Blocks #3436

Open soerenmartius opened 7 months ago

soerenmartius commented 7 months ago

Is your feature request related to a problem? Please describe.

Currently, whenever copying from a code block, all code exposed in that box will be copied. In an ideal world, within the same code block I am able to show a command as well as the resulting output of a command. However, as a user, when copying the code I only want the actual command without the outputs to be copied.

E.g.

```sh
ls # command

file file file file #output

Describe the solution you'd like

Being able to define a line or range of lines of code to be copied from a code block.

```sh{cp1}
ls # command

file file file file #output

Describe alternatives you've considered

No response

Additional context

No response

Validations

ms264556 commented 6 months ago

I would love this sort of functionality.

When showing the necessary console commands to achieve something, it is helpful to show not just the output but also the prompt since the prompt shows useful information.

e.g. I would like to show the entire code block below, but the only information I want to be copied is enable\n and debug\n:-

ruckus> enable 
ruckus# debug 
You have all rights in this mode.
ruckus(debug)#
BenoitDesrosiers commented 2 months ago

it would also be useful when putting code in a context. For example, if you want to show that a line has to be inserted between 2 lines, you want to show these 2 lines, but you don't want them to be copied