Page MenuHomePhabricator

VisualEditor: Strip whitespace from the start of paragraphs before sending to Parsoid
Closed, ResolvedPublic

Description

See, for example, https://en.wikipedia.org/w/index.php?title=Peaches_Does_Herself&diff=prev&oldid=564544238 and https://en.wikipedia.org/w/index.php?title=Carl_Rogers&diff=prev&oldid=564544061 - this is kinda a problem.


Version: unspecified
Severity: enhancement
See Also:
T53509: Wikimark square bracket is this an expected working ?

Details

Reference
bz51462

Event Timeline

bzimport raised the priority of this task from to High.Nov 22 2014, 2:04 AM
bzimport set Reference to bz51462.

If VE can strip leading whitespace in paragraphs, that will eliminate these errors. Alternatively, Parsoid can do that normalization. Unclear where this should be done. Will discuss on IRC.

Without whitespace stripping (either in VE or Parsoid) and no nowiki, that text will become <pre>-formatted.

Quickly discussed with Gabriel on IRC. It is probably better fixed in VE since Parsoid doesn't have contextual information about where the space is meaningful or not.

If leading whitespace at start of line is desired by the editor, then VE should convert them to &nbsp; or if nowikis are acceptable, the spaces can be left alone. In either case, this kind of edits should hopefully be rare.

  • Bug 51509 has been marked as a duplicate of this bug. ***

With bug 50841 we now convert

[space]Foo

to

<nowiki> </nowiki>Foo

(previously <nowiki> Foo</nowiki>)

This is the correct behaviour.

We should be careful going do the road of automatically correcting what we believe to be typos. Perhaps this, and other whitespace issues (e.g. double spaces), should be flagged up to the user (with a wiggle underline?)

  • Bug 52252 has been marked as a duplicate of this bug. ***

(In reply to comment #5)

With bug 50841 we now convert

[space]Foo

to

<nowiki> </nowiki>Foo

(previously <nowiki> Foo</nowiki>)

This is the correct behaviour.

Also, with gerrit 76223 VisualEditor users can now edit through <nowiki>s transparently.

Perhaps this, and other whitespace issues (e.g. double
spaces), should be flagged up to the user (with a wiggle underline?)

That would be one solution that is quite generalisable, but could be a great deal more work.

Change 77287 had a related patch set uploaded by Esanders:
[WIP] Remove inserted leading whitepsace

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

So I just implemented a fix for this, but it broke a test that asserts that whitespace inside a pre is untouched. I'll put it a check for <pre> elements but we should be aware that this is broken, because any element can have white-space:pre attached to it, e.g.

<span style="white-space:pre"> Foo</span>

Will now normalise to

<span style="white-space:pre">Foo</span>

Long term we should look into just warning the user.

Change 77287 merged by jenkins-bot:
Remove inserted leading whitespace

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

Now fixed in the code; next scheduled deployment is not until 15 August,
however. :-(

I am also filing a related common problem we meet at it.wp.
If this is not the right place, just tell me and I'll copy/paste my report elsewhere.

We had troubles with nowikis being thrown right after some templates when the user did not add an extra space there, but simply edited something in that page. See https://it.wikipedia.org/w/index.php?title=Wikipedia&diff=61171396&oldid=61171228 .

We actually found a workaround for this: https://it.wikipedia.org/w/index.php?title=Template:Quote&curid=224372&diff=61173726&oldid=60749506 but since this addition is apparently a nonsense, users demand that VE prevents that behaviour instead.

They also think this is related to templates featuring some kind of table.

I did some tests as well.
I was able to reproduce an unwanted situation where the first line and the table (which is actually a template) were mingled in a non-editable block https://it.wikipedia.org/w/index.php?title=Utente%3AElitre_%28WMF%29%2FSandbox_VE&diff=61181542&oldid=61181524 .

But I was also able to avoid nowikis, even if the extra span tags were not added to the template: as you can see here https://it.wikipedia.org/w/index.php?title=Utente:Elitre_(WMF)/Sandbox_VE&diff=prev&oldid=61181473, if the first letter of the line is actually closer to the template's final brace (with no space between), VEditing that page will result in the text getting automatically placed in a better position, and no nowikis in sight, even after multiple saves of the page.

Thanks.

(In reply to comment #12)

Reopening as this is still happening:
first nowiki after line 133 in
https://en.wikipedia.org/w/index.
php?title=Pet&diff=570614739&oldid=570586939 .

That's almost certainly using a cached version of the code; I can't reproduce that on Chrome/Firefox/Safari/Opera on Mac or Linux.

(In reply to comment #13)

I am also filing a related common problem we meet at it.wp.
If this is not the right place, just tell me and I'll copy/paste my report
elsewhere.

Yeah, if you could file this as a new bug please - this is not related to removing whitespace from the start of paragraphs.