Page MenuHomePhabricator

Add special handling for annotation tags in template arguments
Closed, ResolvedPublic

Description

This is a spinoff from T295406 based on rt-testing failures on metawiki:Wikimedia Community User Group Malaysia and metawiki:Wikimedia Wikimeet India 2021 which exposed a larger issue. How do we handle annotations found in arguments to templates?

Let us take translate as an example and look at {{some-template|arg1=<translate>foo</translate>|arg2=<translate>bar</translate>}}.

Translate extension currently strips these annotations from the arguments, so when this wikitext is transformed to HTML, what is actually transformed is {{some-template|arg1=foo|arg2=bar}}. However, Parsoid currently does not do this. It blithely passes the whole string right on through (even before we started working on T261181) which is incorrect. This is demonstrated by an example on mediawiki.org. Compare the output of the legacy parser on this page compared to Parsoid's output on the same.

The current behaviour of the Translate extension makes sense. Annotations exist to simply demarcate regions of wikitext and shouldn't impact processing otherwise and so should be stripped from all contexts where they might modify results. So, template and extension arguments should both have annotations stripped from them.

Translate, the only extension using annotations so far, does not rely on Parsoid's output to process the annotation. Hence, it is not necessary to do anything particular beyond stripping them from the template arguments. If another extension were to rely on Parsoid's parsing of annotations, T301490 would need to be tackled.

Related Objects

StatusSubtypeAssignedTask
OpenReleaseNone
OpenNone
OpenNone
OpenNone
OpenFeatureNone
OpenNone
OpenNone
OpenNone
OpenNone
OpenNone
Resolved Esanders
OpenFeatureNone
Resolvedihurbain
Resolvedihurbain
ResolvedBUG REPORTArlolra
Resolvedihurbain
ResolvedBUG REPORTihurbain

Event Timeline

ssastry lowered the priority of this task from High to Medium.Nov 17 2021, 2:24 PM

https://gerrit.wikimedia.org/r/c/mediawiki/extensions/Translate/+/762849 should resolve the issue and does so without baking the stripping into Parsoid's annotation implementation (modulo https://gerrit.wikimedia.org/r/c/mediawiki/services/parsoid/+/768136)

Should the patch in T295834#7511850 be abandoned and T301490 closed as no longer valid?

We'll need to do something when Parsoid starts using its own native preprocessor so keeping this all around in our back pocket is always good.