Page MenuHomePhabricator

Parsoid breaks next-sibling TemplateStyles hack
Closed, ResolvedPublicBUG REPORT

Description

Steps to reproduce

  1. Open https://hu.wiktionary.org/w/index.php?title=sohase&useparsoid=0#További_információk.
  2. Notice that the links are listed in four columns.
  3. Open https://hu.wiktionary.org/w/index.php?title=sohase&useparsoid=1#További_információk.

Actual result

  1. Notice that the links are listed in one column.

Expected result

  1. Notice that the links are still listed in four columns.

Other information

  • The links are generated by {{hu-links}}, by putting the links right after an {{acol4}} call. {{acol4}} uses TemplateStyles and a next-sibling selector to the style the otherwise unrelated list. Parsoid breaks this by inserting an empty <span> in between.
  • This bug affects both VisualEditor and read views.

Event Timeline

Parsoid breaks this by inserting an empty <span> in between.

Noted in T368095#9997295, that's template span wrapping of whitespace.

It should be possible to exclude the whitespace-wrapping <span> via a tweaked CSS selector.

Something like augmenting .someclass + .something else with .someclass ~ .whitespace-wrapper + .something-else.

.whitespace-wrapper doesn’t sound very stable. Isn’t there an mw- prefixed class?

Also, isn’t there a way to remove the whitespace-wrapping <span>, potentially by tweaking the wikitext? (The best would be if it worked without having to tweak anything on-wiki, but if tweaking is necessary, it doesn’t really matter what needs to be tweaked, and tweaking the wikitext could probably have a cleaner result.)

There isn't a good solution to this from Parsoid because if we don't wrap that whitespace in a span, template continuity will break and that isn't workable for editing -- template markup continuity is a core requirement for Parsoid and all editing (and other clients that analyze Parsoid markup).

So, if the whitespace cannot be removed from the template, other CSS solutions would have to be found for it.

I understand that keeping a node between two parts of the template that doesn’t belong to the template is problematic (even though I could imagine software fault-tolerant enough that it doesn’t break if a whitespace-only text node appears in the middle, only on non-whitespace-only text nodes and on other types of nodes). My question in October – which is yet to be answered – was not about tolerating the whitespace-only nodes, but

  • What stable CSS class I can use. @cscott suggested .whitespace-wrapper, but first, it doesn’t sound stable, and second, I don’t even see it there (maybe because it was indeed unstable?): I see <span about="#mwt1"> without any other attributes.
  • Whether it’s possible to remove the <span>, potentially by tweaking the wikitext. (Presence or absence of whitespace between a <div> and an <ul> doesn’t make any difference.)
  • What stable CSS class I can use. @cscott suggested .whitespace-wrapper, but first, it doesn’t sound stable, and second, I don’t even see it there (maybe because it was indeed unstable?): I see <span about="#mwt1"> without any other attributes.

At present, there is no class set on the wrapper spans. @cscott was suggesting we could add one.

  • Whether it’s possible to remove the <span>, potentially by tweaking the wikitext. (Presence or absence of whitespace between a <div> and an <ul> doesn’t make any difference.)

The start of line constraint of list syntax means that there isn't much that can be done to tweak the wikitext to avoid the newline, short of using html literals. But template wrapping is stable enough that .ouac-acol4+span[about]+ul should be a dependable selector.

On incubatorwiki,

.navbox + .navbox, /* TODO: remove first line after transclusions have updated */
.navbox + .navbox-styles + .navbox {
	margin-top: -1px; /* Single pixel border between adjacent navboxes */
}

https://incubator.wikimedia.org/wiki/Module:Wp/rki/Navbox/styles.css

I don't think we're likely to change how whitespace wrappping in templates work, so ultimately this is going to end up in "Known Differences" and we should work with hu.wiktionary to find an appropriate CSS fix for them to adopt.

On incubatorwiki,

.navbox + .navbox, /* TODO: remove first line after transclusions have updated */
.navbox + .navbox-styles + .navbox {
	margin-top: -1px; /* Single pixel border between adjacent navboxes */
}

https://incubator.wikimedia.org/wiki/Module:Wp/rki/Navbox/styles.css

This one manifests as T378906: Categories as link tags cause navboxes to have a rendering difference.

Change #1194292 had a related patch set uploaded (by Subramanya Sastry; author: Subramanya Sastry):

[mediawiki/services/parsoid@master] WIP: Migrate leading/trailing rendering-transparent nodes in templates

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

Change #1194292 merged by jenkins-bot:

[mediawiki/services/parsoid@master] Migrate leading/trailing rendering-transparent nodes in templates

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

Change #1195699 had a related patch set uploaded (by Isabelle Hurbain-Palatin; author: Isabelle Hurbain-Palatin):

[mediawiki/vendor@master] Bump wikimedia/parsoid to 0.22.0-a27

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

Change #1195699 merged by jenkins-bot:

[mediawiki/vendor@master] Bump wikimedia/parsoid to 0.22.0-a27

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

Looks like I hastily tagged this task with my patch which narrowly targets navbox extremities and this task is different (even if the issue is similar) where the span wrappers are in the middle of the content - between a <div> and <ul>

Change #1196955 had a related patch set uploaded (by Subramanya Sastry; author: Subramanya Sastry):

[mediawiki/services/parsoid@master] WIP: Quick POC for dealing with next-sibling breakage

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

Change #1196955 merged by jenkins-bot:

[mediawiki/services/parsoid@master] Template Wrapping: Narrowly targeted hack/fix for next-sibling breakage

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

Change #1197319 had a related patch set uploaded (by Subramanya Sastry; author: Subramanya Sastry):

[mediawiki/vendor@master] Bump wikimedia/parsoid to 0.22.0-a28

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

Change #1197319 merged by jenkins-bot:

[mediawiki/vendor@master] Bump wikimedia/parsoid to 0.22.0-a28

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

The huwiktionary pages now render "identically". We will run visual diff on this wiki soon and see what are the remaining blockers to deploying read views on this wiki.

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

[mediawiki/services/parsoid@master] Limit transferring typeof to mw:Transclusion

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

Change #1198601 merged by jenkins-bot:

[mediawiki/services/parsoid@master] Limit transferring typeof to mw:Transclusion

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

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

[mediawiki/vendor@master] Bump wikimedia/parsoid to 0.22.0-a29

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

Change #1199040 merged by jenkins-bot:

[mediawiki/vendor@master] Bump wikimedia/parsoid to 0.22.0-a29

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