Page MenuHomePhabricator

VisualEditor shouldn't turn inline interwiki links into sidebar langlinks by stripping leading colons
Closed, ResolvedPublic

Description

Copied from https://www.mediawiki.org/wiki/Topic:V3b53ed1gg49pct4. It is related to T103635 but not entirely the same problem.

Steps to reproduce issue:

  1. Open a page in VisualEditor
  2. Type some text
  3. Highlight the text
  4. Click on the link icon to turn the highlighted text into a link
  5. Type a page name with an interwiki prefix into the link destination box, e.g. :de:Haribo
  6. Click "done"
  7. (Optional: Click on the link text and then click "edit" again to see that VE has already stripped the leading colon. You can add the leading colon back at this stage and VE will strip it again.)
  8. Save page
  9. Upon saving page, the new link becomes a sidebar interwiki link, not an inline interwiki link.

The difference between this task and T103635 is that in T103635 the user hasn't prefixed a colon and we want VE to guess that the user wants an inline interwiki link. But in this task, the user has deliberately prefixed the colon to signify that they want an inline interwiki link, and VE still strips it and turns it into a sidebar interwiki link.

This problem affects any attempt to turn an existing internal link into an interwiki link, or any attempt to turn existing non-link text into an interwiki link. On the other hand, if one creates a new link without highlighting existing text, VE parses a colon-prefixed page name correctly and gives an interwiki link.

Event Timeline

Generally VisualEditor doesn't know anything about interwiki links (it treats them as normal links to local wiki pages, and expects MediaWiki to handle them specially and redirect to the other wiki), so this would be difficult for us to implement. I would rather focus on fixing T103635, which should render this special case moot.

On the other hand, if one creates a new link without highlighting existing text, VE parses a colon-prefixed page name correctly and gives an interwiki link.

This is interesting (academically ;) ). I looked into why this happens, and it actually doesn't happen in VE, but rather in Parsoid. When the link target is exactly equal to the link label, a special case in Parsoid is used to prevent generating useless piped links (e.g. [[Cat|cat]]). This code apparently also triggers here, and so instead of the incorrect wikitext like [[de:Haribo|:de:Haribo]], the result is [[:de:Haribo]], which works correctly.

Thank you @matmarex . Yes I'm aware that the effort to fix T103635 will
likely fix this as well. The academically interesting observation, that
adding the colon only works when creating a link without highlighting text
first, is perhaps useful for the developers and also outside the scope of
T103635, so I started a new thread about this behaviour.

ppelberg claimed this task.