Page MenuHomePhabricator

[[x||y|z]] (or similar) as a shortcut for [[xy|xz]]
Closed, DeclinedPublic

Description

Author: timedum

Description:
It would be an improvement if links like [[supereroe|supereroi]] (translated:
[[superhero|superheros]]) could be created with this syntax [[superero||e|i]].
This feature would be useful for non-english languages, in which plurals are not
made with a suffix.


Version: unspecified
Severity: enhancement

Details

Reference
bz3527

Event Timeline

bzimport raised the priority of this task from to Lowest.Nov 21 2014, 8:51 PM
bzimport set Reference to bz3527.
bzimport added a subscriber: Unknown Object (MLST).

timedum wrote:

I have a suggestion to implement this improvement. In "Parser.php" file,
"pstPass2" function, add "$p5 = "/\[\[({$tc}+)\\|\\|({$np}+)\|({$np})]]/";" near
2976th line, then six lines later add "$text = preg_replace( $p5,
'[[\\1\\2|\\1\\3]]', $text );". I tried and it works.

It doesn't work on 1.5beta3 nor 1.5rc3. Tested and not working

timedum wrote:

Try this:
Add (without ") "$p5 = "/\[\[({$np}+)\\|\\|({$np}+)\\|({$np}+)]]/";" to line
2900 of "includes/parser.php", after "$p4...."
Then add "$text = preg_replace( $p5, '[[\\1\\2|\\1\\3]]', $text );" to line
2906, BEFORE "$text = preg_replace( $p4, ...".
In my installation it works, try [[Main Pag||e|es]].

timedum wrote:

diff for Parser.php 1.5rc4

Attached:

The matter is: I put it in the exact same spots, but the problem was: the line

$p5 = "/\[\[({$np}+)\\|\\|({$np}+)\\|({$np}+)]]/";

is different from

$p5 = "/\[\[({$tc}+)\\|\\|({$np}+)\|({$np})]]/";

by 2 characters. (The two lines are from your two different posts)
It works now, so thanks. :)

Oh and to thank you for this "extension" overall. I'm Serbian and we could find
it really useful, so thanks in the name of the Wikipedias from the Balkan. I
hope this gets implemented as quickly as possible.

I've encountered a minor glitch with the code. Namely, when the new markup is
saved and when you go to reedit the article, old markup style shows. So, if I
write [[foo||bar|foo]] and save it and then go to the edit box again,
<nowiki>[[foobar|foofoo]]</nowiki> shows, which can be good, but also can't.

avarab wrote:

Changed the summary to actually give an idea of what the bug is about.

timedum wrote:

It's not a glitch, but it's the way it works MediaWiki, it's the same for [[foo
(bar)|]], after you save it, it became [[foo (bar)|foo]]

In my opinion, both should be left in their original form even after the reedit
(they should stay [[foo (bar)|]] and [[foo||bar|bat]]).

*** Bug 3523 has been marked as a duplicate of this bug. ***

I'm pretty leery of doing this as a pre-save transform; they're not
discoverable for users (since they don't appear in page source) and are hard
to figure out and debug when something happens unexpectedly since output
doesn't show in the preview edit box.

Also I'm not sure about the double-pipe. In general we should avoid using
different numbers of adjacent symbols to mean different things, as it's
tricky to parse. (Sadly we already have a bunch of those!)

robchur wrote:

I agree, this will get somewhat confusing.

timedum wrote:

Doing this as a pre-save transform is the easiest way to do it and it follows
the [[foo (bar)|]] syntax.

The double-pipe is the first symbol used to trasform links, i realy can't
introduce new syntax in [[ ]].

Btw, i think that if we must make it in a more difficult way, it will be
implemented in a long time, whereas it is a very little and simple improvement.

The plus side of a pre-save transform is that if we decide to change or dump it, already-written pages don't
have compatibility problems.

So, if there's broad agreement for a trial run we could try this. I still am not too fond of the double |s though,
it's kinda weird.

node.ue wrote:

  1. Why do we need a double-pipe? Why not just [[x|y|z]]???
  2. Why does it need to be a pre-save transform? Why can't it be whatever [[x]]y

is (ie, a rendering thing)?

timedum wrote:

  1. isn't [[x|y|z]] already taken? I saw it but i can't remeber where...
  2. because it is only a trick, a sort of macro, to avoid typing too much, once

is used it done. Then beacuse "if we decide to change or dump it,
already-written pages don't
have compatibility problems."

alarm wrote:

I'd propose something like [[x|-en|-ing]] or similar as [[x||y|z]] is not very intuitive format, but in general anything like
that would be very helpfull in some languages (at least in Lithuanian ti would be very nice to have)

timedum wrote:

[[x|-en|-ing]] is more intuitive, i agree whith Andrius.

rowan.collins wrote:

*** Bug 3523 has been marked as a duplicate of this bug. ***

Doesn't appear to be much support or interest in this;
unnecessary markup complication; similar use of markup is
proposed for other users, will probably want to keep it open
for more important things.

WONTFIXing this for now.