Page MenuHomePhabricator

<nowiki/> tag removed inside template parameter
Closed, ResolvedPublic

Description

<nowiki/> tag inside a template parameter was removed in this edit: https://ko.wikipedia.org/w/?oldid=27637873&diff=prev&diffmode=source

This is surprising to me. I thought the wikitext in template parameters isn't really processed at all?

Event Timeline

ssastry triaged this task as Medium priority.Oct 1 2020, 4:37 PM
ssastry moved this task from Needs Triage to Current & Upcoming Work on the Parsoid board.

This issue is annoying me very much, so I tried to do some debugging.

I grepped for <nowiki/> and found this bit of code, which seems to be responsible for this behavior:

WikitextSerializer.php
				// Strip (useless) trailing <nowiki/>s
				// Interim fix till we stop introducing them in the first place.
				//
				// Don't strip |param = <nowiki/> since that pattern is used
				// in transclusions and where the trailing <nowiki /> is a valid
				// template arg. So, use a conservative regexp to detect that usage.
				$replaced_line = preg_replace( '#^([^=]*?)(?:<nowiki\s*/>\s*)+$#D', '$1', $line, 1 );

This interim fix was originally added in 2015: rGPAR06baaf4ff65a: T115717: Strip trailing <nowiki />s

Following a few links from there, I found that it was a workaround for T58381, which has been fixed since 2017.

We should try to remove this…

Parsoid now represents them as <span typeof="mw:Nowiki"></span>, but VisualEditor still needs to do the work to drop them when the context has been edited.

It looks like we did this in T197990/T96528 in 2019, but I tested it a bit and it doesn't work reliably in some cases.

Change 714375 had a related patch set uploaded (by Bartosz Dziewoński; author: Bartosz Dziewoński):

[mediawiki/services/parsoid@master] Stop stripping trailing <nowiki/>s

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

Change 714376 had a related patch set uploaded (by Bartosz Dziewoński; author: Bartosz Dziewoński):

[VisualEditor/VisualEditor@master] Fix removing empty annotations when the entire paragraph is removed

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

These patches seem to work for me when testing, but I'm having trouble with the tests (in both repos). Maybe I'll come back to this some other time.

They're both ready for review now.

Change 714375 merged by jenkins-bot:

[mediawiki/services/parsoid@master] Stop stripping trailing <nowiki/>s

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

Change 715581 had a related patch set uploaded (by Sbailey; author: Sbailey):

[mediawiki/vendor@master] Bump parsoid to 0.14.0.a17

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

Change 715581 merged by jenkins-bot:

[mediawiki/vendor@master] Bump parsoid to 0.14.0-a17

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

Change 714376 merged by jenkins-bot:

[VisualEditor/VisualEditor@master] Fix removing empty annotations when the entire paragraph is removed

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

Change 720478 had a related patch set uploaded (by Bartosz Dziewoński; author: Bartosz Dziewoński):

[mediawiki/extensions/VisualEditor@master] Update VE core submodule to master (eaa1e32b5)

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

Change 720478 merged by jenkins-bot:

[mediawiki/extensions/VisualEditor@master] Update VE core submodule to master (eaa1e32b5)

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

ppelberg claimed this task.