Page MenuHomePhabricator

Parsoid fails to expand transclusion generated by a Lua module on mnwiki
Closed, ResolvedPublic

Description

See transcript below for a mnwiki wikitext snippet:

$ echo "{{Ангилал он}}" | php bin/parse.php --domain mn.wikipedia.org --dump tplsrc --pageName "Ангилал:1990 он"
[dump] ============================ template source ============================
TEMPLATE:Загвар:Ангилал_онTRANSCLUSION:"{{Ангилал он}}"
--------------------------------------------------------------------------------
<div {{Цагалбарын хэв}}>
...
</div>

The template generating the div's style attributes isn't expanded. It comes from these lines in this module.

This phab task is the only blocker for mnwiki. It affects likely *all* Category pages on this wiki.

Details

Event Timeline

ssastry renamed this task from Parsoid fails to expand template generated by a Lua module on mnwiki to Parsoid fails to expand transclusion generated by a Lua module on mnwiki.Mar 11 2026, 3:55 PM
ssastry updated the task description. (Show Details)

I did some more debugging here. The reproduction steps for a simpler example is the following:

With parsoid as renderer the inline styling is not rendered but legacy renders it.

More specifically parsoid:

<div class="mw-content-ltr mw-parser-output" lang="en" dir="ltr" data-mw-parsoid-version="0.23.0.0-alpha23" data-mw-html-version="2.8.0">
   <section data-mw-section-id="0" id="mwAQ">
      <div about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"T419726","href":"./Template:T419726"},"params":{},"i":0}}]}' id="mwAg">


         <p>hello</p>


      </div>
   </section>
</div>

legacy:

<div class="mw-content-ltr mw-parser-output" lang="en" dir="ltr">
   <div style="text-align:center; border:1px solid #ccc; background-color:pink">
     <p>hello</p>
</div>

The error is reproducible even with a simpler setup:

  • Template <- Lua <- Test Page

https://test.wikipedia.org/wiki/T419726-no-nesting?useparsoid=1
https://test.wikipedia.org/wiki/T419726-no-nesting?useparsoid=0

For debugging purposes I tried this patch and it renders the output like legacy, because it allows expanding the templates from invoke:

diff --git a/src/Wt2Html/TT/TemplateHandler.php b/src/Wt2Html/TT/TemplateHandler.php
index 531a6d4ae..16fbfca2c 100644
--- a/src/Wt2Html/TT/TemplateHandler.php
+++ b/src/Wt2Html/TT/TemplateHandler.php
@@ -1058,7 +1058,7 @@ class TemplateHandler extends XMLTagBasedHandler {
                                        [
                                                // Template like content returned from the
                                                // preprocessor should not be further expanded
-                                               'expandTemplates' => false,
+                                               'expandTemplates' => true,
                                                'srcOffsets' => $srcOffsets,
                                        ] + $this->options

The issue here is that this is a decision made for reasons discussed here: https://phabricator.wikimedia.org/T385806 so I am not sure if this something we want to fix in parsoid.

Here's another interesting test case:

https://en.wikipedia.org/w/index.php?title=User:Cscott/T419726&useparsoid=1
vs
https://en.wikipedia.org/w/index.php?title=User:Cscott/T419726&useparsoid=0

Using this simple lua module: https://en.wikipedia.org/wiki/Module:User:Cscott/T419726

This is somewhat surprising: the "double expansion" of arguments seems limited to html tags, /not/ extension tags. (I had thought that the double expansion was happening when extension tag arguments were parsed.)

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

[mediawiki/core@master] Remove double template expansion in html attributes

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

Change #1266328 merged by jenkins-bot:

[mediawiki/core@master] Remove double template expansion in html attributes

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