Page MenuHomePhabricator

Parsoid: Relative internal wiki links show the wikitext rather than their traditional label
Closed, ResolvedPublic


The output of

[[../Round 5/]]

(on MWwiki page Outreach_Program_for_Women/Round_6) is:

<a rel="mw:WikiLink" href="../Outreach_Program_for_Women/Round_5/" data-parsoid="…">../Round 5/</a>

whereas the PHP parser output is:

<a href="/wiki/Outreach_Program_for_Women/Round_5" title="Outreach Program for Women/Round 5">Round 5</a>

The contents of the <a> should be "Round 5" instead of "../Round 5/".

Version: unspecified
Severity: minor



Event Timeline

bzimport raised the priority of this task from to Medium.Nov 22 2014, 1:38 AM
bzimport set Reference to bz48081.
  • Bug 49919 has been marked as a duplicate of this bug. ***

The same for non-traversing relative links:

/Round 5/
becomes href="/Round 5/">/Round 5/</a>
instead of href="/Round 5">Round 5</a>

In core the trick is that a relative url with a *trailing slash* and no custom label, will expand to linking to the page without the trailing slash and a label with both the leading and trailing slash removed (note that "Round/" and "Round" are both valid and *separate* MediaWiki pages. A wiki can have both.

User documentation:

Our implementation is in js/lib/ext.core.LinkHandler.js, which in turn uses resolveTitle in mediawiki.parser.environment.js for relative link resolution.

Sorry, resolveTitle is only called implicitly when constructing a title. That will then only apply to the actual link, but not to the link text. I guess we could handle this in line 100 in the LinkHandler (in getWikiLinkTargetInfo, the relative link case) and update info.href accordingly. That will then be used to render the link text in case that is not explicitly specified.

Alternatively the stripping could also be a separate method that is called by renderWikiLink. Not sure if this should also apply to other namespaces. Can figure that out later, lets tackle regular wiki links first.

Related URL: (Gerrit Change Ic5eb06b8b4992e5bcc97dceff0ab67d4ff356deb)

Change 70100 merged by jenkins-bot:
Bug 48081: Fix relative internal wiki link labels

[Parsoid component reorg by merging JS/General and General. See bug 50685 for more information. Filter bugmail on this comment. parsoidreorg20130704]