Page MenuHomePhabricator

Piped links using {{!}} are not rendered correctly
Open, MediumPublicBUG REPORT

Description

Steps to reproduce

  1. Navigate to a page with wikitext like this (example at w:eu:User:Rummskartoffel/piped link example):
[[Some title{{!}}Something else]]

[[{{Some template call}}]]

where "Template:Some template call" is a template like this:

Some title{{!}}Something else
  1. Observe.

Expected results

The page should contain two links to the page "Some title" with the link text "Something else" – this is the behaviour of the web version.

Actual results

The page contains the literal text Some titleSomething else, followed by the literal text [[Some title|Something else]].

Environments observed

App version: 2.7.50372-r-2021-09-01
Android OS versions: 9 (EMUI 9.1.0, build number 9.1.0.178)
Device model: Huawei Honor 7x (BND-721)
Device language: German

Event Timeline

Change 810001 had a related patch set uploaded (by C. Scott Ananian; author: C. Scott Ananian):

[mediawiki/services/parsoid@master] parserTests.txt: Add test case for piped link using {{!}}

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

This is verrrry interesting, and gets at the "purpose" of {{!}}. What exactly is it used for? The canonical use is to generate table markup from within a template argument (https://en.wikipedia.org/w/index.php?title=File:Templates_are_dead!_Long_live_templates!.pdf&page=15 and next few slides).

But in that context the important thing is that the {{!}} is *not* immediately expanded as a | but instead stays (conceptually) unevaluated until it is used as a synonym for | in the table markup tokens. That way no matter how many "levels of template" you have, you can still reliably generate the table markup.

I guess you could argue (and this bug is arguing) that {{!}} should be treated as a general substitute for | in *any* wiki construct it appears, with the same purpose except in template syntax. That is, {{!}} is "not a template argument separator" but for every other purpose it is tokenized the same as |. For example, given:

{{1x|Some title{{!}}Something else}}

{{1x|{{Some template call}}}}

both yield Some title|Something else in both parsers. (Demonstrating that the "magic" property of {{!}} persists through multiple levels of template expansion and behaves as if it is handled only at the top-most level.)

Parsoid appears to treat {{!}} as a synonym for | only in table markup.

Note that there are multiple ways to escape the | character: <nowiki>|</nowiki>, &#124;, {{!}}, etc. Nothing gives the behavior the bug submitter wants ("not a template argument divider, but *is* otherwise treated as equivalent to | when tokenizing link syntax") except for {{!}}. Alas. Most of the alternatives (like heredoc) provide better ways to *escape* the | but not to selectively *unescape* it. Refactoring the top-level template to return "an argument list" without the need for {{!}} would be another alternative, but that's not really an actionable proposal at the current time either.

So bottom line is: I think Parsoid does have to match the core behavior here; there's not really any realistic workaround possible in the short term. I've added a parser test for the issue in Iba8b5242af4e1cd4c65ae258278e5778b9d8ae41 but I don't know how hard this will be to "fix".

Change 810001 merged by jenkins-bot:

[mediawiki/services/parsoid@master] parserTests.txt: Add test case for piped link using {{!}}

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

Change 816216 had a related patch set uploaded (by Subramanya Sastry; author: Subramanya Sastry):

[mediawiki/vendor@master] Bump wikimedia/parsoid to 0.16.0-a17

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

Change 816216 merged by jenkins-bot:

[mediawiki/vendor@master] Bump wikimedia/parsoid to 0.16.0-a17

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

I just want to flag that this is an issue on talk pages, and maybe should be in Parsoid-Read-Views Phase 1 for DiscussionTools because it causes links to break.

See for example, https://en.wikipedia.org/wiki/Talk:Twitter/Archive_10?useparsoid=0 and https://en.wikipedia.org/wiki/Talk:Twitter/Archive_10?useparsoid=1

useparsoid=0useparsoid=1
Screenshot 2024-07-22 at 00-34-31 Talk Twitter_Archive 10 - Wikipedia.png (392×808 px, 107 KB)
Screenshot 2024-07-22 at 00-34-18 Talk Twitter_Archive 10 - Wikipedia.png (422×819 px, 115 KB)

I don't know why people use {{!}} instead of typing the | key (maybe they don't have it on their keyboard or don't know where it is??), but it's being used :/

Maybe fear of parser functions or something, which aren't a general issue with links like this (which so far as I know have always had precedence); I've seen it used in templates even though it wasn't needed, as literal [[A{{!}}B]]... which I try to clean up when I do see it.

However, some? many? templates probably have something of the form:

[[A{{#ifeq:{{{B|}}}|C|{{!}}D}}]]

Rather than being written as

{{#ifeq:{{{B|}}}|C|[[A]]|[[A|D]]}}

A use which I see as legitimate, due to 1) avoiding PEIS on highly used templates, and 2) having some common formatting structure/name internal to the template, so an attempt to avoid other duplication as well (especially in {{#switch}}s) e.g. a <span> construct having to be repeated in D across branches or multiple options in a switch.

Pretty sure that concern isn't one necessary for initial rollout of Parsoid Reads, but will be later for template expansion. Well, maybe it will be if a template gets substed on a page and the parser function doesn't have the relevant safesubst or other item to prevent all the junk showing up on the page.

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

[mediawiki/services/parsoid@master] Fix processing pipe magic word in bailing wikilinks

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

Change #1122657 merged by jenkins-bot:

[mediawiki/services/parsoid@master] Fix processing pipe magic word in bailing wikilinks

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

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

[mediawiki/services/parsoid@master] Support {{!}} as a top level wikilink seperator

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

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

[mediawiki/vendor@master] Bump wikimedia/parsoid to V0.21.0-a19

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

Change #1124186 merged by jenkins-bot:

[mediawiki/vendor@master] Bump wikimedia/parsoid to 0.21.0-a19

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

Change #1123724 merged by jenkins-bot:

[mediawiki/services/parsoid@master] Support {{!}} as a top level wikilink seperator

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

Change #1126146 had a related patch set uploaded (by Jgiannelos; author: Jgiannelos):

[mediawiki/vendor@master] Bump wikimedia/parsoid to 0.21.0-a20

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

Change #1126146 merged by jenkins-bot:

[mediawiki/vendor@master] Bump wikimedia/parsoid to 0.21.0-a20

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