Change:
<script type="text/javascript"> function copyCode(elem){ if (document.getElementById(elem)) { <del> // create hidden text element, if it doesn't already exist var targetId = "_hiddenCopyText_"; // must use a temporary form element for the selection and copy target = document.getElementById(targetId); if (!target) { var target = document.createElement("textarea"); target.style.position = "absolute"; target.style.left = "-9999px"; target.style.top = "0"; target.id = targetId; document.body.appendChild(target); } target.value = document.getElementById(elem).innerText; // select the content target.select(); // copy the selection var succeed; try { succeed = document.execCommand("copy"); } catch(e) { swal("Oh, no…","Sorry, your browser doesn't support copying this example to your clipboard."); succeed = false; } if (succeed) { swal("Copied to clipboard: ",elem); return succeed; </del> <ins> if (navigator.clipboard) { navigator.clipboard.writeText(document.getElementById(elem).textContent).then( function () { swal("Copied to clipboard: ",elem); }, function () { swal("Oh, no…","Failed to copy to clipboard: ",elem); }, ); </ins> } else { <del> swal("Oops!", elem + " not found when trying to copy code"); return false; </del> <ins> swal("Oh, no…","Sorry, your browser doesn't support copying this example to your clipboard."); </ins> } } }

Discussion:
I have a suggestion for the "copy to clipboard" option that is available at the right top of any YAML file examples in docs. The copied content when pasted on any editor seems to insert newlines, whereas if same yaml if copied manually by selecting text doesn't insert newlines. The newlines makes the content pretty much unreadable, can this be addressed please? e.g. Text copied using copy to clipboard option: apiVersion: v1 kind: Pod metadata: name: userns spec: hostUsers: false containers: name: shell command: ["sleep", "infinity"] image: debian Below is manually copied YAML: apiVersion: v1 kind: Pod metadata: name: userns spec: hostUsers: false containers: name: shell command: ["sleep", "infinity"] image: debian
This issue is currently awaiting triage. SIG Docs takes a lead on issue triage for this website, but any Kubernetes member can accept issues by applying the label. The label can be by org members by writing in a comment. <detailsInstructions for interacting with me using PR comments are available . If you have questions or suggestions related to my behavior, please file an issue against the repository. </details
Similar to: /triage duplicate /retitle Blank lines when copying example manifests
This issue is a duplicate of . Related PR:
The Kubernetes project currently lacks enough contributors to adequately respond to all issues. This bot triages un-triaged issues according to the following rules: After 90d of inactivity, is applied After 30d of inactivity since was applied, is applied After 30d of inactivity since was applied, the issue is closed You can: Mark this issue as fresh with Close this issue with Offer to help out with [Issue Triage][1] Please send feedback to sig-contributor-experience at . /lifecycle stale [1]:
The Kubernetes project currently lacks enough active contributors to adequately respond to all issues. This bot triages un-triaged issues according to the following rules: After 90d of inactivity, is applied After 30d of inactivity since was applied, is applied After 30d of inactivity since was applied, the issue is closed You can: Mark this issue as fresh with Close this issue with Offer to help out with [Issue Triage][1] Please send feedback to sig-contributor-experience at .

/lifecycle rotten [1]:
The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs. This bot triages issues according to the following rules: After 90d of inactivity, is applied After 30d of inactivity since was applied, is applied After 30d of inactivity since was applied, the issue is closed You can: Reopen this issue with Mark this issue as fresh with Offer to help out with [Issue Triage][1] Please send feedback to sig-contributor-experience at . /close not-planned [1]:
Closing this issue, marking it as "Not Planned". <detailsIn response to : The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs. After 90d of inactivity, is applied After 30d of inactivity since was applied, is applied After 30d of inactivity since was applied, the issue is closedReopen this issue with Mark this issue as fresh with Offer to help out with [Issue Triage][1] Instructions for interacting with me using PR comments are available . If you have questions or suggestions related to my behavior, please file an issue against the repository. </details