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

code blocks include prompt chars when copied #21316

Open
1 task done
palfvin opened this issue Nov 2, 2024 · 1 comment
Open
1 task done

code blocks include prompt chars when copied #21316

palfvin opened this issue Nov 2, 2024 · 1 comment
Labels
kind/enhancement Improves the usability of docs

Comments

@palfvin
Copy link

palfvin commented Nov 2, 2024

Is this a docs issue?

  • My issue is about the documentation content or website

Type of issue

Other

Description

The code blocks for docker shell commands typically show a prompt of "/ # ", but this prompt is not recognized by the shell lexer associated with the console language. As a result, when the code is copied using the copy icon, the prompt is included in the copied text, causing errors when pasted.

Location

https://docs.docker.com/get-started/workshop/05_persisting_data/

Suggestion

If I'm following things correctly, the console/shell lexer that this github page is using is read-only and there aren't any other lexers with more comprehensive notion of shell prompts. As such, I'd suggest removing the prompt from the code block until such time as a suitable lexer is available.

@palfvin palfvin added the status/triage Needs triage label Nov 2, 2024
@dvdksn
Copy link
Collaborator

dvdksn commented Nov 4, 2024

Hello. Thanks for reaching out.

We're using the lexer from chroma to generate these code blocks. Not that it matters - chroma also does not recognize the shell prompt format in these examples. Even if it did, the shell prompt is actually manually excluded from the copied text with a regex:

class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title="copy" @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, ''));

We could add something like [/\w]+\s[#$] to the above regex to exclude it from the copied contents. But it's already hacky as it is... maybe there is a more elegant solution. E.g. a custom component we could use to render console I/O examples...

@dvdksn dvdksn changed the title getting-started code blocks include prompts not supported by language qualifier code blocks include prompt chars when copied Nov 4, 2024
@dvdksn dvdksn added kind/enhancement Improves the usability of docs and removed status/triage Needs triage labels Nov 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement Improves the usability of docs
Projects
None yet
Development

No branches or pull requests

2 participants