Last modified: 2012-12-06 01:29:26 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T44667, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 42667 - Presence/absence of initial newline in <pre> should be in round-trip data
Presence/absence of initial newline in <pre> should be in round-trip data
Status: RESOLVED FIXED
Product: Parsoid
Classification: Unclassified
General (Other open bugs)
unspecified
All All
: Unprioritized normal
: ---
Assigned To: ssastry
:
Depends on:
Blocks: 42469
  Show dependency treegraph
 
Reported: 2012-12-04 01:23 UTC by Roan Kattouw
Modified: 2012-12-06 01:29 UTC (History)
4 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Roan Kattouw 2012-12-04 01:23:05 UTC
There is a syntactic (but not a semantic) difference between <pre>Foo</pre> and <pre>\nFoo</pre>. VE will normalize the latter to the former (due to the browsers' HTML DOM implementation), so Parsoid should use round-trip data to serialize this correctly.

Test wikitext:

<pre>Foo</pre>

<pre>
Foo</pre>


/_rtform/ claims this round-trips cleanly, but it's lying. If you put the wikitext into /_wikitext/, grab the HTML, then copypaste that into /_html/ , you'll see the initial newline in the second <pre> is eaten.
Comment 1 Gabriel Wicke 2012-12-05 03:24:12 UTC
From http://dev.w3.org/html5/spec-preview/syntax.html#element-restrictions:

"A single newline may be placed immediately after the start tag of pre and textarea elements. This does not affect the processing of the element. The otherwise optional newline must be included if the element's contents themselves start with a newline (because otherwise the leading newline in the contents would be treated like the optional newline, and ignored)."

This is about the syntax, so applies to serializing and parsing. A serializer must emit an additional newline if the pre content (without the optional newline) in the DOM starts with a newline. Sadly, the innerHTML method in modern browsers does not seem to implement this, so we have to work around it.
Comment 2 Gabriel Wicke 2012-12-06 01:29:26 UTC
Fix merged in https://gerrit.wikimedia.org/r/#/c/36923/

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links