More sensible semantics for pipe trick with section links after r62076
authorConrad Irwin <conrad@users.mediawiki.org>
Tue, 9 Feb 2010 01:05:49 +0000 (01:05 +0000)
committerConrad Irwin <conrad@users.mediawiki.org>
Tue, 9 Feb 2010 01:05:49 +0000 (01:05 +0000)
[[hello#world|]] -> [[hello#world|world]] (not [[hello#world]])

includes/Linker.php
includes/parser/Parser.php
maintenance/parserTests.txt

index 1d9f9fd..fe2ffa5 100644 (file)
@@ -1237,8 +1237,8 @@ class Linker {
                        list( $tc, $nc ) = Linker::getPipeTrickCharacterClasses();
                        $rexps = array (
                                # try this first, to turn "[[A, B (C)|]]" into "A, B"
-                               "/^(:?$nc+:|[:#\/]|$tc+\\/|)($tc+?)( \\($tc+\\)| ($tc+))$/", # [[ns:page (context)|]]
-                               "/^(:?$nc+:|[:#\/]|$tc+\\/|)($tc+?)( \\($tc+\\)| ($tc+)|)((?:,|,) $tc+|)$/",  # [[ns:page (context), context|]]
+                               "/^(:?$nc+:|[:#\/]|$tc+[\\/#]|)($tc+?)( \\($tc+\\)| ($tc+))$/", # [[ns:page (context)|]]
+                               "/^(:?$nc+:|[:#\/]|$tc+[\\/#]|)($tc+?)( \\($tc+\\)| ($tc+)|)((?:,|,) $tc+|)$/",  # [[ns:page (context), context|]]
                        );  
                }
                $text = urldecode( $link );
index 7a2a36a..9f3d89f 100644 (file)
@@ -4033,9 +4033,9 @@ class Parser
                ) );
 
                # Links of the form [[|<blah>]] or [[<blah>|]] perform pipe tricks
-               # Note this only allows the # in the one position it works.
+               # Note this only allows the # in the position it works.
                global $wgLegalTitleChars;
-               $pipeTrickRe = "/\[\[(?:(\\|)([$wgLegalTitleChars]+)|(#?[$wgLegalTitleChars]+)\\|)\]\]/";
+               $pipeTrickRe = "/\[\[(?:(\\|)([$wgLegalTitleChars]+)|([#$wgLegalTitleChars]+)\\|)\]\]/";
                $text = preg_replace_callback( $pipeTrickRe, array( $this, 'pstPipeTrickCallback' ), $text );
 
                # Trim trailing whitespace
index 578d0ff..5eb095c 100644 (file)
@@ -3051,6 +3051,18 @@ pst
 [[../context/relative (extra)|relative]]
 !! end
 
+!! test
+pre-save transform: context links ("pipe trick") to sections on other pages
+!! options
+pst
+!! input
+[[other#page|]]
+[[Help:Somewhere/completely (wierd)#section (two)|]]
+!! result
+[[other#page|page]]
+[[Help:Somewhere/completely (wierd)#section (two)|section]]
+!! end
+
 !! test
 pre-save transform: context links ("pipe trick") with full-width characters
 !! options