Further tweaks to pipe trick documentation (follow-up Iaf365e31)
authorWaldir Pimenta <waldir@email.com>
Thu, 6 Dec 2012 06:14:58 +0000 (06:14 +0000)
committerWaldir Pimenta <waldir@email.com>
Thu, 6 Dec 2012 06:19:13 +0000 (06:19 +0000)
- call them pipe tricks (plural) as there's more than one
- mention double-width comma as well
- use one tab character for alignment due to double-width chars
- document reverse pipe trick

Change-Id: I27a1d04362eb3988fc1318fa1f73f69877019439

includes/parser/Parser.php

index 5699ef8..2c8b6e5 100644 (file)
@@ -4478,14 +4478,14 @@ class Parser {
                        '~~~' => $sigText
                ) );
 
-               # Context links ("pipe trick"): [[|name]] and [[name (context)|]]
+               # Context links ("pipe tricks"): [[|name]] and [[name (context)|]]
                $tc = '[' . Title::legalChars() . ']';
                $nc = '[ _0-9A-Za-z\x80-\xff-]'; # Namespaces can use non-ascii!
 
-               $p1 = "/\[\[(:?$nc+:|:|)($tc+?)( ?\\($tc+\\))\\|]]/";                  # [[ns:page (context)|]]
-               $p4 = "/\[\[(:?$nc+:|:|)($tc+?)( ?($tc+))\\|]]/";                    # [[ns:page(context)|]] (double-width brackets, added in r40257)
-               $p3 = "/\[\[(:?$nc+:|:|)($tc+?)( ?\\($tc+\\)|)((?:, |,)$tc+|)\\|]]/"; # [[ns:page (context), context|]]
-               $p2 = "/\[\[\\|($tc+)]]/";                                             # [[|page]]
+               $p1 = "/\[\[(:?$nc+:|:|)($tc+?)( ?\\($tc+\\))\\|]]/";                   # [[ns:page (context)|]]
+               $p4 = "/\[\[(:?$nc+:|:|)($tc+?)( ?($tc+))\\|]]/";                           # [[ns:page(context)|]] (double-width brackets, added in r40257)
+               $p3 = "/\[\[(:?$nc+:|:|)($tc+?)( ?\\($tc+\\)|)((?:, |,)$tc+|)\\|]]/";         # [[ns:page (context), context|]] (using either single or double-width comma)
+               $p2 = "/\[\[\\|($tc+)]]/";                                              # [[|page]] (reverse pipe trick: add context from page title)
 
                # try $p1 first, to turn "[[A, B (C)|]]" into "[[A, B (C)|A, B]]"
                $text = preg_replace( $p1, '[[\\1\\2\\3|\\2]]', $text );