Page MenuHomePhabricator

TemplateStyles tag transcluded in template is not parsed in Visual Editing mode in Visual Editor
Closed, ResolvedPublic

Description

Steps to reproduce:
Edit a page with templates with TemplateStyles transclusion with Visual Editing mode in Visual Editor.

Actual results:
TemplateStyle tags shown as paragraph text near the template.
HTML snippet included below:

<p about="#mwt1" class="ve-ce-leafNode ve-ce-focusableNode ve-ce-mwTransclusionNode ve-ce-focusableNode-focused" contenteditable="false">&lt;templatestyles src="Template:Infobox/style.css" /&gt;</p>

Expected results:
TemplateStyle tags should be hidden in Visual Editing mode.
Instead of showing as a paragraph in HTML, it should be wrapped in the style tags.

<style data-mw-deduplicate="TemplateStyles:rxxxxxxx typeof="mw:Extension/templatestyles" ...>CSS here</style>

The TemplateStyles tags are only not parsed when editing in Visual Editing mode in Visual Editor, the tags are properly parsed in normal page view/read mode.
I am on a non-WMF Mediawiki setup, the related versions are included below:

Mediawiki1.31.3
Parsoid0.10.0
VisualEditor0.1.0 (c3c9140)
TemplateStyles1.0 (814b63c)

Event Timeline

JTannerWMF added subscribers: Ryasmeen, JTannerWMF.

Hey @Ryasmeen can you take a look at this to see if you can reproduce it, from there we will determine how to address this.

Related to the issue I mentioned above, the style transcluded in the template only appear in Visual Edit when it is inside of the <includeonly> tags or when no <includeonly> tags are present in the template. However, in both scenario, the above not parsed bug still present. Not sure if it is the intended behavior.

I am unable to follow the steps here. Not sure, how to exactly get "templates with TemplateStyles transclusion". Please include step by step actions that caused this issue.

@Ryasmeen templates with TemplateStyles transclusion means using a template that uses TemplateStyles, aka having <templatestyles src="Template:Foo/style.css">.

@Ryasmeen templates with TemplateStyles transclusion means using a template that uses TemplateStyles, aka having <templatestyles src="Template:Foo/style.css">.

I see, can you share an example page where it's happening consistently? Thanks!

@Ryasmeen it is on a non-WMF wiki, here's an example page containing templates using TemplateStyles: https://scwdev.czen.me/Defender
Since it is a dev site, registration is locked and edits are permission only. However, I hope that the following screenshot would help:

Read mode:

image.png (1×1 px, 446 KB)

Visual edit mode:
image.png (1×1 px, 415 KB)

As you can see the templatestyles tag are not parsed.

@alistair3149: I am sharing with you the result I got while trying to replicate it on Beta cluster. Could you please confirm if I described the issue correctly below?

Steps to replicate:

  1. Open VE for any page.
  2. Go to Insert>Template.
  3. Search for a TemplateStyles transclusion (I used TemplateStylesTest/style.css)

This is how it renders in VE mode:

Screen Shot 2020-02-04 at 12.22.48 PM.png (457×1 px, 177 KB)

@Ryasmeen instead of inserting a template, it was simply visual editing a page that already has a template in there.

The issue wasn't reproducible on any WMF wikis as they are not on LTS build.

@Ryasmeen instead of inserting a template, it was simply visual editing a page that already has a template in there.

The issue wasn't reproducible on any WMF wikis as they are not on LTS build.

yes, so after inserting it, when I reopen this page, it shows the same rendering. So I guess that's the issue. I will leave it upto engineers now to decide on next step.

matmarex subscribed.

@Ryasmeen I think that's not the same issue. You transcluded "TemplateStylesTest/style.css", which contains the CSS, so displaying the CSS code on the page is the expected behavior (…well, "expected" is a big word, but at least it's consistent with the view mode). When transclusing "TemplateStylesTest", the code block doesn't appear, and a <templatestyles> tag doesn't appear either, but in the analogous situation on https://scwdev.czen.me/Defender, it does.


@alistair3149 Thank you for the details, the screenshots and the link to the wiki helps. (That's a cool-looking wiki, by the way.)

I cheated a little and forced VE to load on that page (even though I can't edit), and I also see the issue there.

Looks like the "plain text" <templatestyles> tag is already present in the Parsoid output, as seen here: https://scwdev.czen.me/api.php?action=visualeditor&format=json&paction=parse&page=Defender&uselang=en (Ctrl+F to search for &lt;templatestyles). VisualEditor just displays this.

So this is either a bug in Parsoid, or some misconfiguration on your side. I have no idea what would cause this, I've never seen it before.

AFAIK Parsoid just makes an API request back to your wiki to parse the tag, like this: https://scwdev.czen.me/Special%3AApiSandbox#action=parse&format=json&text=<templatestyles%20src%3D"Template%3AInfobox%2Fstyle.css"%20%2F> and that seems to work just fine…

@matmarex thanks for looking into it and the praise! Not sure if the following information helps but we don't have RESTBase on the wiki.
Also another weird behavior is that templates placed inside the <tabber> tags (from Extension:Tabber) seems to be not affected.

To better illustrate the examples:

When the template is under the <tabber> tags, the <templatestyles> tags are parsed:

image.png (1×1 px, 431 KB)

When there is not <tabber> tags, the <templatestyles> tags are not parsed,
on top of that VE does not seem to respect image size defined in the wiki markup:

image.png (1×1 px, 120 KB)

Apart from that, the style was only there because it was cached when you visit the page in read mode.
If you go directly to the edit URL (e.g. index.php?title=Defender&action=edit), the styles from templatestyles are not loaded at all:

image.png (1×1 px, 404 KB)

LGoto triaged this task as Low priority.Feb 14 2020, 5:27 PM
LGoto edited projects, added Parsoid-Read-Views-Deprecated-Project; removed Parsoid.

Just to clarify, for those who looked into this: the issue is that Parsoid's generated HTML is wrapping a <p> tag here? (We've categorized this as a read-view issue for now.)

Or is Parsoid generating correct HTML and VisualEditor somehow is mangling it for display?

Does the page appear correct when viewed with the REST API?

Instructions for determining whether this is a Parsoid or a VE issue can be found at https://www.mediawiki.org/wiki/Parsoid/How_to_triage_bugs

@cscott It's a Parsoid issue (although I can't tell if it's a bug or misconfiguration).

Parsoid's generated HTML for a <templatestyles src="Template:Infobox/style.css" /> tag in wikitext is literally &lt;templatestyles src="Template:Infobox/style.css" /> (it doesn't parse the wikitext tag), instead of some kind of a <style>... HTML tag.

I think the REST API is not exposed on this wiki, but you can view the output via action=visualeditor API (T239305#5850245).

although I can't tell if it's a bug or misconfiguration

If Parsoid is returning the literal representation then it's failing to recognize the extension tag as being installed. Does <templatestyles> show up on Special:Version? What about in "extensiontags" in action=query&meta=siteinfo?

although I can't tell if it's a bug or misconfiguration

If Parsoid is returning the literal representation then it's failing to recognize the extension tag as being installed. Does <templatestyles> show up on Special:Version? What about in "extensiontags" in action=query&meta=siteinfo?

Both the extension and the tag are registered on Special:Version. The templatestyles tags are also registered on siteinfo

If I add - uri: 'https://scwdev.czen.me/api.php' to a local Parsoid instance, it doesn't have that issue.

Can you check the output of Parsoid directly by visiting the equivalent of http://localhost:8000/scwdev.czen.me/v3/page/html/Defender/108449 for your setup?

Also, how do things look in your LocalSettings.php? $wgVirtualRestConfig['modules']['parsoid']

The Parsoid output is as follow:

madmin@scw-u18lts:/home/www-data/public_html$ grep -C5 parsoid LocalSettings.php
#  'redisServer'    => '127.0.0.1:6379',

#  'claimTTL'       => 3600
#);

For the $wgVirtualRestConfig['modules']['parsoid']

#parsoid
$wgVirtualRestConfig['modules']['parsoid'] = array(
  // URL to the Parsoid instance
  // Use port 8142 if you use the Debian package
  'url' => 'http://localhost:8142',
  'domain' => 'localhost'
);
alistair3149 claimed this task.

Seems to be a misconfiguration issue on my end.
The issue was resolved after a reinstall of Parsoid, now everything works fine.