Copying <pre> always adds newlines around it as <p> does
Categories
(Core :: DOM: Serializers, defect, P3)
Tracking
()
People
(Reporter: richard.schneeman, Unassigned)
Details
Attachments
(2 files)
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:65.0) Gecko/20100101 Firefox/65.0
Steps to reproduce:
- Visit a site that has multiple pre or code elements such as this example code pen https://codepen.io/schneems/pen/LqXRgz
- Copy multiple lines from the area
- Paste those lines anywhere
Actual results:
In addition to the text that you expected to copy, there is an additional empty newline on every other line.
Video of the bug is attached.
Expected results:
When you paste, you should only get the lines of text and not the additional newlines. When you try the same behavior on the same page with chrome, it works.
| Reporter | ||
Comment 1•6 years ago
|
||
The original video upload was too large, here's the same video on youtube https://www.youtube.com/watch?v=eSKXhobjFgk&feature=youtu.be
Updated•6 years ago
|
Updated•6 years ago
|
Comment 2•5 years ago
|
||
Seems that copying <pre> currently always adds newlines.
Have absolutely same annoying problem with Firefox. On Chrome no such problem.
Video with demonstration: https://yadi.sk/i/BUK8Qr2bZaQByQ
FF Version: 76.0 (64-bit)
Another example,
Steps to reproduce
- Go to any code submission on https://codeforces.com
For example: https://codeforces.com/contest/1344/submission/80590953 - Scroll down to end of source code, and click on
Click to see test details - Copy
input dataof any test case.
For example: Copy input data for 1st test case.
Actual Output
Each line contains an extra new line.
5 4
1 2 1
1 3 2
3 4 1
3 5 3
2 1
4 2
2 6
5 10
Actual Output
Copied data should be as it's i.e. no new line after each line of code.
Comment 5•5 years ago
|
||
Same as Vipul's example but it happens only with KDE terminals such as Yakuake, Konsole
(In reply to dimanavsisto from comment #5)
it happens only with KDE terminals such as Yakuake, Konsole
Do you means, it only happens when you paste data in KDE terminal? Not in any text editor or place where you can paste your data.
Comment 7•5 years ago
|
||
(In reply to Vipul from comment #6)
(In reply to dimanavsisto from comment #5)
it happens only with KDE terminals such as Yakuake, Konsole
Do you means, it only happens when you paste data in KDE terminal? Not in any text editor or place where you can paste your data.
yes, only from Firefox to Yakuake, Konsole via Ctrl+Shift+V. If I paste to fish shell via Ctrl+V all fine, but not in vim or other console apps
| Reporter | ||
Comment 8•5 years ago
|
||
I see this bug when I paste into sublime text 2, Evernote, and other text boxes in the Firefox browser.
It’s especially frustrating since I work support for Heroku and frequently copy and paste many lines of stack traces, I have to manually go back and remove all the lines.
Comment 9•5 years ago
|
||
This is about whether we want to add newline for blocks with default margins. Currently Firefox always adds newlines for both <p> and <pre> but Chrome adds newlines only for <p>.
I prefer adding newlines as it's more natural in this attachment. Using <pre> for every line as the example in comment #0 did is just like using <p> for every line.
Comment 10•5 years ago
•
|
||
That said, comment #4 uses a single <pre> block for each code block and the issue disappears if you open the DevTools, edit <body> with "Edit As HTML" just to remove event listeners, and copy the problematic blocks again. I suspect some javascript is causing the issue there.
Comment 11•5 years ago
|
||
Comment 12•5 years ago
•
|
||
Oh, this turns out to be a line ending issue where \r\n is incorrectly processed as double newlines.
Updated•5 years ago
|
Comment 13•5 years ago
|
||
Although I don't have concrete idea, if <pre> elements are adjacent siblings, line breaks between them might not be necessary for the comment 0's case especially when it has only one line content.
Updated•5 years ago
|
Updated•5 years ago
|
Comment 14•5 years ago
|
||
Filed Bug 1650720 for comment #4 as it's different from comment #0.
Updated•5 years ago
|
| Reporter | ||
Comment 15•5 years ago
|
||
I see this is still set as "unconfirmed" can we set this to new? cc @hsinyi
Comment 16•5 years ago
|
||
(In reply to dimanavsisto from comment #7)
yes, only from Firefox to Yakuake, Konsole via Ctrl+Shift+V. If I paste to fish shell via Ctrl+V all fine, but not in vim or other console apps
It seems like Bug 1650720 is similar to Bug 1554489 (plaintext-serialization issue), that's if you paste data in text/html based editor like Libre Writer, data format will intact, may be Fish shell is also parsing pasted data in similar fashion.
| Reporter | ||
Comment 17•5 years ago
|
||
I'm able to reproduce the behavior in vim using both iterm2 and terminal.app here is a screengrab of me copying and pasting into iterm vim https://imgur.com/a/xfhN3jU.
| Reporter | ||
Comment 18•3 years ago
|
||
Any ideas here? Are you able to reproduce this behavior? I'm seeing it across 3~4 computers over 5 years including all of the editors anyone has mentioned here.
Updated•3 years ago
|
Comment 19•1 year ago
|
||
I can still reproduce this behaviour (Windows 11, Firefox 133). It's annoying because some common widgets for displaying code or logs seem to use one pre tag per line. I encountered it when I was doing mentoring on exercism.org.
Description
•