Skip to content

Conversation

chrismatteson
Copy link

Modifying the behavior of the "copy" button in the docs for terminal commands so that it doesn't include the leading $ and whitespace.

}

// Initialize the copy handler
setupCopyHandler();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feels unnecessary to wrap the setup copy handler. Why not remove it?

});

// Check if any lines were modified (meaning this was a terminal example)
const wasModified = lines.some((line, index) => line !== modifiedLines[index]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of trying to guess from the content, look at the code block for the language attribute:

<code class="language-yaml" data-lang="yaml">

Then you can replace with confidence.

const modifiedLines = lines.map(line => {
// If line starts with $ followed by whitespace, strip it
if (/^\$\s/.test(line)) {
return line.replace(/^\$\s+/, '');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will not work for this code:

$ aws eks describe-cluster \
    --name my-cluster

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

Successfully merging this pull request may close these issues.

2 participants