Page MenuHomePhabricator

Parsoid doesn't insert same spacers when article text starts with two or more newlines.
Open, LowPublic

Description

PHP:

$ (echo 'x' ) | php maintenance/parse.php --quiet
<div class="mw-parser-output"><p>x
</p></div>
$ (echo; echo 'x' ) | php maintenance/parse.php --quiet
<div class="mw-parser-output"><p>x
</p></div>
$ (echo; echo; echo 'x' ) | php maintenance/parse.php --quiet
<div class="mw-parser-output"><p><br />
x
</p></div>
$ (echo; echo; echo; echo 'x' ) | php maintenance/parse.php --quiet
<div class="mw-parser-output"><p><br />
</p><p>x
</p></div>
$ (echo; echo; echo; echo; echo 'x' ) | php maintenance/parse.php --quiet
<div class="mw-parser-output"><p><br />
</p><p><br />
x
</p></div>
$ (echo; echo; echo; echo; echo; echo 'x' ) | php maintenance/parse.php --quiet
<div class="mw-parser-output"><p><br />
</p><p><br />
</p><p>x
</p></div>
$ (echo; echo; echo; echo; echo; echo; echo 'x' ) | php maintenance/parse.php --quiet
<div class="mw-parser-output"><p><br />
</p><p><br />
</p><p><br />
x
</p></div>

Parsoid:

$ (echo 'x' ) | bin/parse.js --normalize
<p>x</p>
$ (echo; echo 'x' ) | bin/parse.js --normalize
<p>x</p>
$ (echo ; echo; echo 'x' ) | bin/parse.js --normalize
<p>x</p>
$ (echo ; echo; echo; echo 'x' ) | bin/parse.js --normalize
<p><br/> x</p>
$ (echo ; echo; echo; echo; echo 'x' ) | bin/parse.js --normalize
<p><br/></p>
<p>x</p>
$ (echo ; echo; echo; echo; echo; echo 'x' ) | bin/parse.js --normalize
<p><br/></p>
<p>x</p>
$ (echo ; echo; echo; echo; echo; echo; echo 'x' ) | bin/parse.js --normalize
<p><br/></p>
<p><br/> x</p>

In general Parsoid looks like it is generating the output for one fewer leading newline than PHP, but there are other differences with 4 and 5 newlines that should be looked into.

Event Timeline

$ (echo; echo; echo; echo 'x' ) | php maintenance/parse.php --quiet
<div class="mw-parser-output"><p><br />
</p><p>x
</p></div>
$ (echo; echo; echo; echo 'x' ) | php maintenance/parse.php --quiet
<div class="mw-parser-output"><p><br />
</p><p><br />
x
</p></div>

What happened here? Is that some sort of non-determinism :)

What happened here? Is that some sort of non-determinism :)

Whoops, cut-and-paste error. Fixed.

This task has been assigned to the same task owner for more than two years. Resetting task assignee due to inactivity, to decrease task cookie-licking and to get a slightly more realistic overview of plans. Please feel free to assign this task to yourself again if you still realistically work or plan to work on this task - it would be welcome!

For tips how to manage individual work in Phabricator (noisy notifications, lists of task, etc.), see https://phabricator.wikimedia.org/T228575#6237124 for available options.
(For the records, two emails were sent to assignee addresses before resetting assignees. See T228575 for more info and for potential feedback. Thanks!)