Page MenuHomePhabricator

<pre> block HTML copying doesn't preserve the internal whitespace formatting
Closed, ResolvedPublic8 Estimated Story Points

Description

Cutting and pasting a block of text with a pre block in it mangles the text.

Attempted HTML to copy:

class ReallyClassyCode {
  public function taptaptap();
  public function isthisthingon();
  public function hello();

Result (approximately):

class ReallyClassyCode {  public function taptaptap();  public function isthisthingon();  public function hello();

I discovered this trying to cut and paste using the HTML from Phab into a MediaWiki text. It almost worked, but the pre blocks made the output look a little too mangled. Example output from VE here: https://test2.wikipedia.org/wiki/User:RobLa-WMF/preblock

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript
Jdforrester-WMF renamed this task from <pre> block HTML copying doesn't preserve the whitespace formatting to <pre> block HTML copying doesn't preserve the internal whitespace formatting.Apr 12 2016, 7:13 PM
Jdforrester-WMF triaged this task as Medium priority.
Jdforrester-WMF moved this task from To Triage to TR0: Interrupt on the VisualEditor board.

Change 307324 had a related patch set uploaded (by DLynch):
ElementLinearData: don't sanitize away newlines within <pre>

https://gerrit.wikimedia.org/r/307324

This was introduced back in November by the fix for T104790. My proposed patch preserves most of that fix, but skips the added behavior when within a preformatted block.

ve.dm.PreformattedNode.static.hasSignificantWhitespace = true; to the rescue!

Change 307324 merged by jenkins-bot:
ElementLinearData: don't sanitize away newlines within <pre>

https://gerrit.wikimedia.org/r/307324