Wikitext such as [[Foo{{echo]]}} get parsed as broken links by the
preprocessor, but then end up being parsed as valid wikilinks later.
This exposes the intermediate representation of the preprocessor
and should be avoided.
Similarly, given [[Foo|{{echo|Bar]]x}}y]]z:
- Both PHP and Parsoid ignore the ]] inside the echo in the "preprocessor" stage. The {{echo extends until the x}}, and the outer [[Foo extends until the y]]
- (a) But then the PHP preprocessor emits [[Foo|Bar]]xy]]z as an intermediate result (after template expansion), and link processing happens on this intermediate result, which moves the wikilink boundary leftward to [[Foo|Bar]]
- (b) Parsoid works in a single step, so it's going to keep the wikilink as extending to the y]]
- (a) Then PHP does linktrail processing which slurps up the trailing xy inside the link.
- (b) Parsoid will do linktrail processing to slurp up the trailing z inside the link.
This is "correct" behavior. Parsoid's basic worldview is that the ]] inside the template shouldn't be allowed to leak out to affect the surrounding wikilink. PHP may match Parsoid (in the future) if you use {{#balance}} (T114445). But we could also fix the preprocessor so that the "broken" ]] is escaped during preprocessing so that it can't leak out and close a wikilink in later processing.