Page MenuHomePhabricator

Parsoid doesn't process Template:Markup correctly on cbk_zamwiki
Open, MediumPublic

Description

Event Timeline

After an initial look, this may be a variation of https://www.mediawiki.org/wiki/Parsoid/Parser_Unification/Instructions_for_editors#Access_to_parent_frame_from_within_extensions ... The <syntaxhighlight>..</syntaxhighlight> arg to the markup template is not evaluated in the preprocessor in the Parsoid scenaior and then gets embedded inside a <pre> which pretty much means that the syntaxhighlight markup is rendered as text instead of being evaluated as wikitext. But, there is no clear workaround available here. Just to confirm that theory, I tried it here. Legacy rendering has other issues (escaped strip markers), but Parsoid rendering doesn't evaluate the syntaxhighlight even via {{#tag:...}}.

These set of templates are also present on enwiki and the same problems can be seen there as well.

There's a discussion in https://phabricator.wikimedia.org/T146771#11122244 (and its linked bugs) to effect that all of this <pre><syntaxhighlight> nonsense is working around the actual "real" bug in T146771 and we could remove it all if we managed to fix that task as proposed there. I'm not /completely/ sold on that, because we need a migration strategy as well -- a lint rule at the very least -- but I think it is worth discussing this in depth as an option before we start implementing or patching around this.

MSantos triaged this task as Medium priority.Nov 21 2025, 10:09 AM
cscott added a subscriber: Arlolra.

I believe this involves a <pre> tag in the template and can be fixed with the new <pre> functionality @Arlolra added for T353697, so I'm tentatively assigning this to @Arlolra. Feel free to unassign/reassign if I'm wrong about this.

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

[mediawiki/core@master] [WIP] Template:Markup

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

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

[mediawiki/extensions/SyntaxHighlight_GeSHi@master] Add test for nowiki escaping angle brackets

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

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

[mediawiki/extensions/SyntaxHighlight_GeSHi@master] [WIP] Drop nowiki unstripping in parserHook

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

Change #1300275 merged by jenkins-bot:

[mediawiki/core@master] Avoid the escaping from nowiki processing

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

Change #1300884 merged by jenkins-bot:

[mediawiki/extensions/SyntaxHighlight_GeSHi@master] Add test for nowiki escaping angle brackets

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

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

[mediawiki/core@wmf/1.47.0-wmf.6] Avoid the escaping from nowiki processing

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

Change #1300913 merged by jenkins-bot:

[mediawiki/core@wmf/1.47.0-wmf.6] Avoid the escaping from nowiki processing

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

Mentioned in SAL (#wikimedia-operations) [2026-06-11T21:20:37Z] <arlolra@deploy1003> Started scap sync-world: Backport for [[gerrit:1300913|Avoid the escaping from nowiki processing (T398967)]]

Mentioned in SAL (#wikimedia-operations) [2026-06-11T21:22:23Z] <arlolra@deploy1003> arlolra: Backport for [[gerrit:1300913|Avoid the escaping from nowiki processing (T398967)]] synced to the testservers (see https://wikitech.wikimedia.org/wiki/Mwdebug). Changes can now be verified there.

Mentioned in SAL (#wikimedia-operations) [2026-06-11T21:29:46Z] <arlolra@deploy1003> Finished scap sync-world: Backport for [[gerrit:1300913|Avoid the escaping from nowiki processing (T398967)]] (duration: 09m 09s)

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

[mediawiki/core@master] [WIP] Plumb through flags

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

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

[mediawiki/extensions/SyntaxHighlight_GeSHi@master] [WIP] Add more tests for Template:Markup use

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

Change #1300937 merged by jenkins-bot:

[mediawiki/core@master] Store nowiki source in StripState::extra to support subst-nowiki

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

Change #1300938 merged by jenkins-bot:

[mediawiki/extensions/SyntaxHighlight_GeSHi@master] Add more tests for Template:Markup use

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

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

[mediawiki/core@wmf/1.47.0-wmf.6] Store nowiki source in StripState::extra to support subst-nowiki

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

Change #1301451 merged by jenkins-bot:

[mediawiki/core@wmf/1.47.0-wmf.6] Store nowiki source in StripState::extra to support subst-nowiki

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

The pattern from that page was to pass a syntaxhighlight tag to template:markup, as in

{{markup|<syntaxhighlight language="wikitext">{{1x|<div>test</div>}}</syntaxhighlight>}}

However, template:markup embeds the content in a pre extension tag, whose contents have traditionally been plaintext (ignore the new format wikitext of the pre extention). The resulting html was an ugly html pre in html pre in the legacy parser, whereas Parsoid killed the strip marker and showed the literal syntaxhighlight tag.

Following above merged patches and updating the markup template from enwiki,
https://cbk-zam.wikipedia.org/w/index.php?title=Plantilla%3AMarkup%2Frow&diff=118039&oldid=101076

the new recommended pattern is

{{markup|<nowiki>{{1x|<div>test</div>}}</nowiki>|tag=syntaxhighlight}}

which makes use of the typical escaping mechanism, nowiki, and only output the single html pre of syntaxhighlight, and is compatible with both parsers.

A few pages were updated,
https://cbk-zam.wikipedia.org/w/index.php?title=Plantilla%3ARefn%2Fdoc&diff=118132&oldid=115841
https://cbk-zam.wikipedia.org/w/index.php?title=Plantilla%3ALegend%2Fdoc&diff=118135&oldid=116113
https://cbk-zam.wikipedia.org/w/index.php?title=Plantilla%3AHarvard_citation_documentation&diff=118134&oldid=115880
https://cbk-zam.wikipedia.org/w/index.php?title=Plantilla%3APlainlist%2Fdoc&diff=118133&oldid=115568

and the example from the task description now renders the same,
https://cbk-zam.wikipedia.org/wiki/Template%3ARefn%2Fdoc?useparsoid=0
https://cbk-zam.wikipedia.org/wiki/Template%3ARefn%2Fdoc?useparsoid=1

One issue remains. en:template:markup/row defaults to the inline=1 attribute for syntaxhighlight, which isn't expected in the above examples. And on cbk_zamwiki this was removed temporarily,
https://cbk-zam.wikipedia.org/w/index.php?title=Plantilla%3AMarkup%2Frow&diff=118053&oldid=118039

A discussion on enwiki is open to discuss making that configurable,
https://en.wikipedia.org/wiki/Template_talk:Markup#Line_breaks_and_syntaxhighlight

One issue remains. en:template:markup/row defaults to the inline=1 attribute for syntaxhighlight, which isn't expected in the above examples. And on cbk_zamwiki this was removed temporarily,
https://cbk-zam.wikipedia.org/w/index.php?title=Plantilla%3AMarkup%2Frow&diff=118053&oldid=118039

A discussion on enwiki is open to discuss making that configurable,
https://en.wikipedia.org/wiki/Template_talk:Markup#Line_breaks_and_syntaxhighlight

After looking at the current uses of tag=syntaxhighlight with a Category:T398967, it was determined that we could remove inline=1 on enwiki as well, which was done in Special:Diff/1362866283 and styling was adjusted in Special:Diff/1362865867

{F92124078}