Page MenuHomePhabricator

Extend context link ("pipe trick") syntax to pages with commas in title
Closed, ResolvedPublic

Description

As proposed on [[Wikipedia:Village pump (technical)#Why does the "pipe trick"
not work on place names?]], the attached patch makes the pre-save context link
expansion (see [[Help:Pipe trick]]) trigger on commas as well as parentheses.
This means, in particular, that:

  1. [[Foo, Bar|]] will expand to [[Foo, Bar|Foo]], and
  2. [[|Foo]] on page named [[Foobar, Baz]] will expand to [[Foo, Baz|Foo]].

Due the expansion being done during the PST, this change will not affect
existing content in any way. Also, since the "empty pipe" syntax does not
conflict with normal link syntax, users are unlikely to run afoul of this effect
by accident. That said, there is one case where the new behavior may be
unexpected and perhaps, in some cases, unwanted: the syntax [[Ns:Foo, Bar|]],
which used to expand to [[Ns:Foo, Bar|Foo, Bar]] will after the change expand to
[[Ns:Foo, Bar|Foo]] instead.


Version: 1.7.x
Severity: enhancement

Details

Reference
bz6826

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 9:16 PM
bzimport set Reference to bz6826.

Patch to extend the pipe trick syntax to titles with commas

attachment pipetrick.diff ignored as obsolete

(In reply to comment #0)

Due the expansion being done during the PST, this change will not affect
existing content in any way. Also, since the "empty pipe" syntax does not
conflict with normal link syntax, users are unlikely to run afoul of this effect
by accident. That said, there is one case where the new behavior may be
unexpected and perhaps, in some cases, unwanted: the syntax [[Ns:Foo, Bar|]],
which used to expand to [[Ns:Foo, Bar|Foo, Bar]] will after the change expand to
[[Ns:Foo, Bar|Foo]] instead.

Why not just give the priority to colon instead of comma? Of course, if such a
thing is possible.

New patch, gives priority to parens over comma, more tests

Here's a new patch which uses two regexps to ensure that [[Foo, Bar (baz)|]]
becomes [[Foo, Bar (baz)|Foo, Bar]] and [[Foo (baz), Bar|]] becomes [[Foo
(baz), Bar|Foo]].

I've also made the behavior of the [[|Foo]] and [[Foo|]] syntaxes consistent,
such that, for example, both consider the namespace part of the context. There
is, however, one notable exception: If the page title is of the form "Foo
(bar), Baz", the link [[|Foobar]] becomes [[Foobar, Baz|Foobar]], _not_
[[Foobar (bar), Baz|Foobar]]. I believe this is what most people would expect,
since titles with parens followed by a comma are fairly uncommon.

Attached:

neroute2 wrote:

This looks good. I'd hate to see it die from lack of interest.

  • Bug 7489 has been marked as a duplicate of this bug. ***
  • Bug 11530 has been marked as a duplicate of this bug. ***