VisualEditor does not like TemplateStyles
Closed, ResolvedPublic1 Story Points

Description

VisualEditor does not like TemplateStyles. In https://sv.wikipedia.org/w/index.php?diff=42504081 a VE edit is made to a page that uses the template https://sv.wikipedia.org/wiki/Mall:Jap that has a templatestyles tag. As you can see it just spits out a lot of spans.

After some testing in my own sandbox I came to the conclusion that it really is the combination of VE and the templatestyles tag:
https://sv.wikipedia.org/w/index.php?diff=42504672 is made with wikitext and with the templatestyles tag
https://sv.wikipedia.org/w/index.php?diff=42504675 is made with VE and with the templatestyles tag
https://sv.wikipedia.org/w/index.php?diff=42504696 is made with wikitext and without the templatestyles tag
https://sv.wikipedia.org/w/index.php?diff=42504707 is made with VE and without the templatestyles tag

As you can see, out of these four combinations, only VE + templatestyles tag fails.

Nirmos created this task.Feb 23 2018, 9:28 PM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptFeb 23 2018, 9:28 PM
Tgr added a subscriber: Tgr.Feb 23 2018, 10:43 PM

Does this happen when you change the parameters of a template that uses templatestyles? Or on any edit to a page containing such a template?

No, I did not try to edit the template call with VE. I just changed "febsdfsdfsdfruari" to "febsdfsdfsdfrsdfsdfsdfuari" in https://sv.wikipedia.org/w/index.php?diff=42504675

Tgr triaged this task as High priority.
Tgr added a comment.Feb 23 2018, 11:03 PM

Parsoid translates the wikitext to

<p id="mwAg"><b id="mwAw">Tōta Kaneko</b>,  <span id="mwBA"></span><span id="mwBQ">(</span><a rel="mw:WikiLink" href="./Japanska" title="Japanska" id="mwBg">japanska</a><span id="mwBw">: </span><span lang="ja" id="mwCA">金子 兜太<sup id="mwCQ"><small id="mwCg"><a rel="mw:WikiLink" href="./Wikipedia:Återgivning_av_främmande_språk/Japanska" title="Wikipedia:Återgivning av främmande språk/Japanska" id="mwCw">?</a></small></sup></span><span id="mwDA">, </span><i id="mwDQ">Kaneko Tōta</i><span id="mwDg">)</span>, född 1919, död 20 febsdfsdfsdfrsdfsdfsdfuari 2018, var en <a rel="mw:WikiLink" href="./Japan" title="Japan" id="mwDw">japansk</a> <a rel="mw:WikiLink" href="./Poet" title="Poet" id="mwEA">poet</a>.
</p>

which is missing all the template markup.

Tgr added a comment.Feb 23 2018, 11:05 PM

And the styles added by TemplateStyles are missing, too.

Should I move the styles back to the MediaWiki namespace on svwiki?

Anomie added a subscriber: Anomie.Feb 23 2018, 11:29 PM

Doing a little digging, https://sv.wikipedia.org/api/rest_v1/page/html/Anv%C3%A4ndare%3AAnomie%2FSandbox?redirect=false (that is fetched by VE to begin editing a similar page I created) includes the <style> tag. I can't find the <style> in VE's DOM, though.

If I make a change to the text and then click to switch to wikitext (using the 2010 editor), VE submits the following page content:

<!doctype html><html prefix="dc: http://purl.org/dc/terms/ mw: http://mediawiki.org/rdf/" about="http://sv.wikipedia.org/wiki/Special:Redirect/revision/42505120"><head prefix="mwr: http://sv.wikipedia.org/wiki/Special:Redirect/"><meta property="mw:TimeUuid" content="840befcb-18f0-11e8-babb-093d3942dbea"><meta charset="utf-8"><meta property="mw:pageNamespace" content="2"><meta property="mw:pageId" content="8131206"><link rel="dc:replaces" resource="mwr:revision/42505112"><meta property="dc:modified" content="2018-02-23T23:23:10.000Z"><meta property="mw:revisionSHA1" content="ce85d30f99f119fc05986012e8f5be035a7dc9e0"><meta property="mw:html:version" content="1.6.0"><link rel="dc:isVersionOf" href="//sv.wikipedia.org/wiki/Anv%C3%A4ndare%3AAnomie/Sandbox"><title>Användare:Anomie/Sandbox</title><base href="https://sv.wikipedia.org/wiki/"><link rel="stylesheet" href="//sv.wikipedia.org/w/load.php?modules=mediawiki.legacy.commonPrint%2Cshared%7Cmediawiki.skinning.content.parsoid%7Cmediawiki.skinning.interface%7Cskins.vector.styles%7Csite.styles%7Cext.cite.style%7Cext.cite.styles%7Cmediawiki.page.gallery.styles&amp;only=styles&amp;skin=vector"><!--[if lt IE 9]><script src="//sv.wikipedia.org/w/load.php?modules=html5shiv&amp;only=scripts&amp;skin=vector&amp;sync=1"></script><script>html5.addElements('figure-inline');</script><![endif]--></head><body id="mwAA" class="mw-content-ltr sitedir-ltr ltr mw-body-content parsoid-body mediawiki mw-parser-output" dir="ltr" lang="sv"><p id="mwAg"><b id="mwAw">Tōta Kaneko</b>,  <span about="#mwt1">
</span><span about="#mwt1">(</span><a rel="mw:WikiLink" href="./Japanska" title="Japanska" about="#mwt1">japanska</a><span about="#mwt1">: </span><span about="#mwt1" lang="ja">金子 兜太<sup><small><a rel="mw:WikiLink" href="./Wikipedia:Återgivning_av_främmande_språk/Japanska" title="Wikipedia:Återgivning av främmande språk/Japanska">?</a></small></sup></span><span about="#mwt1">, </span><span class="unicode audiolink" about="#mwt1"><i><a rel="mw:MediaLink" href="./Special:FilePath/Foobar" title="Foobar" typeof="mw:Error" data-mw="{&quot;errors&quot;:[{&quot;key&quot;:&quot;apierror-filedoesnotexist&quot;,&quot;message&quot;:&quot;This image does not exist.&quot;}]}">Kaneko Tōta</a></i></span><span about="#mwt1"> </span><span class="metadata audiolinkinfo" about="#mwt1"><small><a rel="mw:WikiLink" href="./Fil:Foobar" title="Fil:Foobar" class="new">info</a></small></span><span about="#mwt1">)</span>, född 1919, död 20 blah 2018, var en <a href="./Japan" rel="mw:WikiLink" title="Japan" id="mwBQ">japansk</a> <a href="./Poet" rel="mw:WikiLink" title="Poet" id="mwBg">poet</a>.</p></body></html>

I note the styles are missing. I suspect Parsoid is losing the template entirely because the data-mw attribute that actually describes the template was on the missing <style> tag, and then winds up keeping the various <span about="#mwt1"> tags that should have turned into the template transclusion.

Parsoid translates the wikitext to

<p id="mwAg"><b id="mwAw">Tōta Kaneko</b>,  <span id="mwBA"></span><span id="mwBQ">(</span><a rel="mw:WikiLink" href="./Japanska" title="Japanska" id="mwBg">japanska</a><span id="mwBw">: </span><span lang="ja" id="mwCA">金子 兜太<sup id="mwCQ"><small id="mwCg"><a rel="mw:WikiLink" href="./Wikipedia:Återgivning_av_främmande_språk/Japanska" title="Wikipedia:Återgivning av främmande språk/Japanska" id="mwCw">?</a></small></sup></span><span id="mwDA">, </span><i id="mwDQ">Kaneko Tōta</i><span id="mwDg">)</span>, född 1919, död 20 febsdfsdfsdfrsdfsdfsdfuari 2018, var en <a rel="mw:WikiLink" href="./Japan" title="Japan" id="mwDw">japansk</a> <a rel="mw:WikiLink" href="./Poet" title="Poet" id="mwEA">poet</a>.
</p>

which is missing all the template markup.

That's probably because Nirmos removed the <templatestyles> tag in this edit, a few minutes before your comment.

Ok, so I'm gonna move all styles I've migrated back to the MediaWiki namespace, until this is sorted out. Even if this turns out to be premature, the key here is that moving styles back and forth is very little work. Finding and cleaning up edits by potentially all VE users is a tremendous amount of work. I will do this now.

Doing a little digging, https://sv.wikipedia.org/api/rest_v1/page/html/Anv%C3%A4ndare%3AAnomie%2FSandbox?redirect=false (that is fetched by VE to begin editing a similar page I created) includes the <style> tag. I can't find the <style> in VE's DOM, though.
....
I note the styles are missing. I suspect Parsoid is losing the template entirely because the data-mw attribute that actually describes the template was on the missing <style> tag, and then winds up keeping the various <span about="#mwt1"> tags that should have turned into the template transclusion.

Thanks Brad for this investigation. That pretty much explains the corruption.

Done. Everything with regard to migration of styles on svwiki is now reverted, so that this task may be investigated in peace without any fear of more wild span tags being added to articles.

Stryn added a subscriber: Stryn.Feb 25 2018, 11:05 AM

Further deployment of TemplateStyles it dependent on the resolution of this task.

Deskana moved this task from To Triage to Current work on the VisualEditor board.Feb 26 2018, 11:42 AM
Deskana edited projects, added VisualEditor (Current work); removed VisualEditor.

This sounds like a Parsoid issue at the moment, not VE?

This sounds like a Parsoid issue at the moment, not VE?

Ed, see T188143#3998163. VE is stripping the style tags that have data-mw and transclusion info.

Esanders claimed this task.Feb 26 2018, 4:41 PM

Change 414713 had a related patch set uploaded (by Esanders; owner: Esanders):
[mediawiki/extensions/VisualEditor@master] Whitelist style tags from Parsoid, e.g. TemplateStyles

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

This sounds like a Parsoid issue at the moment, not VE?

Ed, see T188143#3998163. VE is stripping the style tags that have data-mw and transclusion info.

Ah, thanks - that's an easy fix..

Change 414713 merged by jenkins-bot:
[mediawiki/extensions/VisualEditor@master] Whitelist style tags from Parsoid, e.g. TemplateStyles

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

Deskana closed this task as Resolved.Feb 27 2018, 10:46 AM
Deskana set the point value for this task to 1.

This should be live on the Swedish Wikipedia on Thursday.

Deskana moved this task from Up next to Done on the TemplateStyles board.Mar 6 2018, 6:45 PM