Page MenuHomePhabricator

Support nested special page transclusion?
Open, MediumPublic

Description

T59886 handled the case where the special page transclusion was at the top level. The solution there doesn't work if the special page transclusion is nested in a template, as the commit message says,

As a first pass, we call out to the legacy parser for the output of
special pages, which is HTML ($isHTML in Parser.php) and only returned
if asked to render ($this->ot['html'] in Parser.php) as opposed to
template expansion ($this->ot['pre']).

Event Timeline

MSantos triaged this task as Medium priority.Mar 11 2024, 8:05 PM
MSantos removed a project: Parsoid.

I suggested to @Arlolra that this could be solved by integrating strip state into the parsoid tokenizer. Parsoid expects the result of a transclusion to be "wikitext" and the result of an extension tag expansion to be "html". Both of those are actually incorrect: transclusions (including parser functions) can result in html (returning ["some html string", "isHtml"] as documented by Parser::setFunctionHook) and extension tag expansions can result in wikitext (returning [ 0=>"some html string", "markerType"=>"none"] when called from Parser::extensionSubstitution()).

The solution used in the core parser is to encapsulate the HTML in a strip state marker. Parsoid could integrate "strip state marker" as a token type in its tokenizer, and then use that to fetch the raw html from the strip state and encapsulate it into a DOM Fragment token. That would allow any combination of HTML and wikitext to be handled properly by Parsoid.

This is elaborated on in T257606#9216083.