Page MenuHomePhabricator

Transclusion of pages with CSS/JS/JSON/LUA content model transcludes the plain text without styling
Open, Needs TriagePublic

Description

Hi. Open some page for source edit and add "{{some js or css or json or lua page}}". It looks terrible, especially json. I believe it should be fixed or at least prevented at all until the fix. Thank you.

For example:
pasted_file (950×1 px, 114 KB)
When transcluded:
pasted_file (950×1 px, 80 KB)

Event Timeline

matmarex renamed this task from Fix contentmodel page transclusion to Transclusion of pages with CSS/JS/JSON content model transcludes the plain text without styling.Sep 29 2016, 8:10 PM
matmarex subscribed.

The Content class has a getWikitextForTransclusion() method, possibly CssContent/JavaScriptContent/JsonContent should override it with… something.

Well, @matmarex, what do you think about (in pseudocode)

return $('<syntaxhighlight>', {lang: 'css', html: super()});

will it work?

Yes, basically, with two caveats:

  • SyntaxHighlight is an extension, so MediaWiki core would have to use <pre> and add a hook that SyntaxHighlight can use to change it to <syntaxhighlight>.
  • MediaWiki's XML-like tags are not nestable, so if the page being transcluded contained </pre> itself, the styling would stop in the middle of the page. This can probably be avoided with some clever parser abuse.
IKhitron renamed this task from Transclusion of pages with CSS/JS/JSON content model transcludes the plain text without styling to Transclusion of pages with CSS/JS/JSON/LUA content model transcludes the plain text without styling.Sep 30 2016, 12:00 PM
IKhitron updated the task description. (Show Details)

You are the boss, @matmarex. I also added the lua model.

Anomie subscribed.

Parsoid would probably also need something done here, if only replacing whatever it currently does to get the wikitext for a transclusion with something that calls getWikitextForTransclusion(). And in turn that might need some change to the action API.

Parsoid would probably also need something done here, if only replacing whatever it currently does to get the wikitext for a transclusion with something that calls getWikitextForTransclusion(). And in turn that might need some change to the action API.

Parsoid calls the expandtemplates action api endpoint, so as long as that does the right thing, this should work in Parsoid.

JJMC89 raised the priority of this task from High to Needs Triage.May 18 2018, 5:43 PM