From 546322662b17062e024aaeab88ef76084cb72cf8 Mon Sep 17 00:00:00 2001 From: Waldir Pimenta Date: Thu, 6 Dec 2012 06:14:58 +0000 Subject: [PATCH] Further tweaks to pipe trick documentation (follow-up Iaf365e31) - 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 | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php index 5699ef8d43..2c8b6e51dc 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -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 ); -- 2.20.1