There's a new-to-me Copy button on fenced code blocks on various stack exchange sites now. When pressed, it puts a copy of the code block to the client's clipboard, along with a couple lines of attribution.
The attribution lines use Windows line endings. The body of the fenced code uses Unix line endings (or possibly, the client's native line endings).
The expected behavior is consistent line endings in the copied text in the client's native line ending format.
Example:
// Source - https://stackoverflow.com/q
is actually:
00000000 2f 2f 20 53 6f 75 72 63 65 20 2d 20 68 74 74 70 |// Source - http|
00000010 73 3a 2f 2f 73 74 61 63 6b 6f 76 65 72 66 6c 6f |s://stackoverflo|
00000020 77 2e 63 6f 6d 2f 71 0d 0a |w.com/q..|
---- CRLF ---------------------^
For me, this results in <CR> markers in my text editor if I paste in a code block.
I can reproduce this on superuser.com and stackoverflow.com on macOS 14.7.6 with Safari 18.6, and Mint linux 21.3 with Chromium 120 and Firefox 144.
I would speculate that the template file used to render the attribution was saved with Windows line endings.
-
2For reference, the Copy button was added to code blocks on Stack Overflow as of the most recent Community Asks Sprint (and other Stack Exchange network sites can request to have it enabled on their site as well). See this announcement for more info: Results of the October 2025 Community Asks Sprint: copy button for code blocks, and moreV2Blast– V2Blast StaffMod2025年11月15日 03:44:01 +00:00Commented Nov 15 at 3:44
-
1Possibly related to this longtime apparently previously unreported buggy behaviour I just bug posted: Post /revisions (versions) page Source page copy & paste has double line spacingphilipxy– philipxy2025年11月15日 07:14:56 +00:00Commented Nov 15 at 7:14
-
Surprised to hear that the copy button is appearing on various SE sites. Can you share an example?setman– setman Staff2025年11月15日 20:01:33 +00:00Commented Nov 15 at 20:01
-
2@setman I have seen posts on some per-site metas Add the "Copy button for code blocks" feature on SU which is status-completed. On other sites not yet enabled Add the "Copy button for code blocks" feature on Server Fault, Please enable the new Copy Button feature on Ask Ubuntu, Please enable the new Copy Button feature on Unix & LinuxChester Gillon– Chester Gillon2025年11月16日 08:31:00 +00:00Commented Nov 16 at 8:31
-
1@setman Python import of local package fails in cygwin is an example on Super User where the copy button on shown on the question and answer. Syntax Hightlighting Requests is on Meta Super User about adding the Code Language to tags to support the code button.Chester Gillon– Chester Gillon2025年11月16日 08:38:46 +00:00Commented Nov 16 at 8:38
-
@setman I saw the button on SuperUser.com and StackOverflow.com, I didn't look on other SE sites. I used "various" because I assumed the feature had been rolled out to the other sites too (I don't know how or when code is shared between the SE sites). Sorry for any confusion.Seth– Seth2025年11月17日 23:21:27 +00:00Commented Nov 17 at 23:21