Merge "Further tweaks to pipe trick documentation (follow-up Iaf365e31)"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Thu, 24 Jan 2013 15:48:24 +0000 (15:48 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Thu, 24 Jan 2013 15:48:24 +0000 (15:48 +0000)
includes/parser/Parser.php

index d47ccb9..36f6273 100644 (file)
@@ -4492,14 +4492,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 );