Page MenuHomePhabricator

Inline templates in the lead sections won't show on page preview, reducing readability
Open, Needs TriagePublicBUG REPORT

Description

Chinese Wikipedia has a {{地区用词2}} Template to show the name of a subject corresponding to user variant , which is used very frequently on lead sections of articles.

Steps to reproduce:

  1. View zhwiki article 奥斯曼帝国 (and it permanent link). You can see a {{地區用詞}} (which internally use {{地区用词2}}) template in the lead section. It is expanded as the image below shows (in the red rectangle):
    Untitled.png (506×2 px, 93 KB)
  2. Then open this page, on which a link to 奥斯曼帝国 article exists. Hover on this link to get the preview, like this image:
    Untitled1.png (1×1 px, 173 KB)
  3. Compared to the article text, {{地区用词2}} template is not displayed (the red rectangle is empty). It is expected to be the displayed just as that in the first image.

This bug has a strong impact on readability, so I hope this bug will be fixed soon.

Event Timeline

Aklapper changed the task status from Open to Stalled.Jun 7 2021, 10:56 AM

Hi @Tranve, thanks for taking the time to report this! Please see https://www.mediawiki.org/wiki/How_to_report_a_bug and provide clear steps to reproduce (including links), what you expect, and what happens instead.

@Aklapper Sorry for inconvenience, I've updated the description to provide more details.

Aklapper changed the task status from Stalled to Open.Jun 7 2021, 4:38 PM
Jdlrobson subscribed.

The content of page previews come the mobile content service API, so that's where this would need to be analyzed and fixed.

This issue happens because /summary endpoint receives wrong extract and extract_html properties. Similar problem has been resolved in this task: https://phabricator.wikimedia.org/T295255
However, this particular case happens because mobileapps removes necessary data from the tag attribute.
Here is the problem part of the Parsoid output that is received by processing module (lib/processing.js):

<p id="mwFw"><b about="#mwt34" typeof="mw:Transclusion" data-mw="{&quot;parts&quot;:[{&quot;template&quot;:{&quot;target&quot;:{&quot;wt&quot;:&quot;地區用詞&quot;,&quot;href&quot;:&quot;./Template:地區用詞&quot;},&quot;params&quot;:{&quot;start&quot;:{&quot;wt&quot;:&quot;{{lang-ota|دولت علیه عثمانیه}},{{lang-tr|Osmanlı İmparatorluğu}}&quot;},&quot;cn&quot;:{&quot;wt&quot;:&quot;奥斯曼帝国&quot;},&quot;tw&quot;:{&quot;wt&quot;:&quot;鄂圖曼帝國&quot;},&quot;hk&quot;:{&quot;wt&quot;:&quot;tw&quot;}},&quot;i&quot;:0}}]}" id="mwGA">

As we can see, the main text content that is needed for summary is inside data-mw attribute which is removing while transformation process in lib/transformations/rmAttributes.js ( link )

So in the output we receive empty <b> tag like this:

<p id="mwFw"><b id="mwGA"></b>是一个存在于 ...

In conclusion this is propably Parsoid/Parser issue of how it parses zh wikitext.
Seems that this part of wikitext is broken:

{{地區用詞|start={{lang-ota|دولت علیه عثمانیه}},{{lang-tr|Osmanlı İmparatorluğu}}|cn=奥斯曼帝国|tw=鄂圖曼帝國|hk=tw}}是一个存在于1299年至1923年的军事[[帝国]],国名来自创立者[[奥斯曼一世|奧-{}-斯曼一世]],以[[伊斯兰教]]为国教。

Here is Parsoid output with the highlighted DOM-node:

zh-wiki-parser.png (1×2 px, 1 MB)

@ssastry , could you take a look?

Arlolra subscribed.

The wikitext,

{{地區用詞|start={{lang-ota|دولت علیه عثمانیه}},{{lang-tr|Osmanlı İmparatorluğu}}|cn=奥斯曼帝国|tw=鄂圖曼帝國|hk=tw}}是一个存在于1299年至1923年的军事[[帝国]],国名来自创立者[[奥斯曼一世|奧-{}-斯曼一世]],以[[伊斯兰教]]为国教。

expands to,

<b about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"dsr":[0,151,null,null],"pi":[[{"k":"start","named":true},{"k":"cn","named":true},{"k":"tw","named":true},{"k":"hk","named":true}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"地區用詞","href":"./Template:地區用詞"},"params":{"start":{"wt":"{{lang-ota|دولت علیه عثمانیه}},{{lang-tr|Osmanlı İmparatorluğu}}"},"cn":{"wt":"奥斯曼帝国"},"tw":{"wt":"鄂圖曼帝國"},"hk":{"wt":"tw"}},"i":0}}]}'><span typeof="mw:LanguageVariant" data-mw-variant='{"twoway":[{"l":"zh-cn","t":"&lt;span typeof=\"mw:LanguageVariant\" data-mw-variant=&apos;{\"filter\":{\"l\":[\"zh\",\"zh-hans\"],\"t\":\"奥斯曼帝国\"}}&apos; data-parsoid=&apos;{\"fl\":[\"zh\",\"zh-hans\"]}&apos;>&lt;/span>"},{"l":"zh-hk","t":"&lt;span typeof=\"mw:LanguageVariant\" data-mw-variant=&apos;{\"filter\":{\"l\":[\"zh\",\"zh-hant\"],\"t\":\"鄂圖曼帝國\"}}&apos; data-parsoid=&apos;{\"fl\":[\"zh\",\"zh-hant\"]}&apos;>&lt;/span>"},{"l":"zh-tw","t":"&lt;span typeof=\"mw:LanguageVariant\" data-mw-variant=&apos;{\"filter\":{\"l\":[\"zh\",\"zh-hant\"],\"t\":\"鄂圖曼帝國\"}}&apos; data-parsoid=&apos;{\"fl\":[\"zh\",\"zh-hant\"]}&apos;>&lt;/span>"}]}'></span></b> ...

The relevant part is not the bold tag itself, but the span inside it that start with,

<span typeof="mw:LanguageVariant" data-mw-variant='{"twoway" ...

Parsoid's conversion traverser doesn't quite know what to do with this markup,

		} elseif ( isset( $dmv->twoway ) ) {
			// FIXME

https://github.com/wikimedia/parsoid/blob/master/src/Language/ConversionTraverser.php#L283-L284

This seems similar to T258118. Parsoid's language converter implementation for zhwiki isn't ready for production use of read views yet, T204969