Page MenuHomePhabricator

Parsoid shouldn't do the mw:DisplaySpace transform (french spacing) on preformatted text
Closed, ResolvedPublic

Description

Consider the wikitext:

<pre>
function foo ( $x ) {
  return $x ? " x " : " y ";
}
</pre>
<!-- same thing, but with indent-pre -->
 function foo ( $x ) {
   return $x ? " x " : " y ";
 }

I'd suggest that a reader (hence tagging this for Parsoid-Read-Views) would expect to be able to copy-and-paste from the resulting HTML. But in fact current parsing will perform the "french spacing" post processing transformation here and insert <span typeof="mw:DisplaySpace">&nsbp;</span>. This would cause the code to fail if you copy-and-pasted it, as your runtime choked either on the unexpected whitespace character, or the unexpected contents of your string literals.

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

Change 797348 had a related patch set uploaded (by Jgiannelos; author: Jgiannelos):

[mediawiki/services/parsoid@master] Omit french spacing on pre nodes

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

Change 806213 had a related patch set uploaded (by Jgiannelos; author: Jgiannelos):

[mediawiki/services/parsoid@master] Add support for handling DOM traversal state

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

Change 806214 had a related patch set uploaded (by Jgiannelos; author: Jgiannelos):

[mediawiki/services/parsoid@master] Omit DisplaySpace processing inside pre nodes

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

Change 797348 abandoned by Jgiannelos:

[mediawiki/services/parsoid@master] Omit french spacing on pre nodes

Reason:

Closing this one after: 806214

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

Change 806214 abandoned by Jgiannelos:

[mediawiki/services/parsoid@master] Omit DisplaySpace processing inside pre nodes

Reason:

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

Change 809927 had a related patch set uploaded (by Jgiannelos; author: Jgiannelos):

[mediawiki/services/parsoid@master] Omit DisplaySpace processing inside pre nodes

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

Change 809927 merged by jenkins-bot:

[mediawiki/services/parsoid@master] Omit DisplaySpace processing inside pre nodes

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

Change 814892 had a related patch set uploaded (by Arlolra; author: Arlolra):

[mediawiki/vendor@master] Bump parsoid to 0.16.0-a16

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

Change 814892 merged by jenkins-bot:

[mediawiki/vendor@master] Bump parsoid to 0.16.0-a16

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

Arlolra subscribed.

This seems fine now after the deploy,
https://en.wikipedia.org/w/index.php?title=User:Arlolra/sandbox&oldid=1101005760&veaction=editsource
https://en.wikipedia.org/api/rest_v1/page/html/User:Arlolra%2Fsandbox/1101005760

view-source:https://en.wikipedia.org/api/rest_v1/page/html/User:Arlolra%2Fsandbox/1101005760

<pre typeof="mw:Extension/pre" about="#mwt3" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"\nfunction foo ( $x ) {\n  return $x ? \" x \" : \" y \";\n}\n"}}' id="mwAg">function foo ( $x ) {
  return $x ? " x " : " y ";
}
</pre>
<!-- same thing, but with indent&#x2D;pre -->
<pre id="mwAw">function foo ( $x ) {
  return $x ? " x " : " y ";
}</pre>

Change 806213 abandoned by Jgiannelos:

[mediawiki/services/parsoid@master] Add support for handling DOM traversal state

Reason:

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