r62150 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r62149‎ | r62150 | r62151 >
Date:01:05, 9 February 2010
Author:conrad
Status:reverted
Tags:
Comment:
More sensible semantics for pipe trick with section links after r62076
[[hello#world|]] -> [[hello#world|world]] (not [[hello#world]])
Modified paths:
  • /trunk/phase3/includes/Linker.php (modified) (history)
  • /trunk/phase3/includes/parser/Parser.php (modified) (history)
  • /trunk/phase3/maintenance/parserTests.txt (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/parserTests.txt
@@ -3052,6 +3052,18 @@
30533053 !! end
30543054
30553055 !! test
 3056+pre-save transform: context links ("pipe trick") to sections on other pages
 3057+!! options
 3058+pst
 3059+!! input
 3060+[[other#page|]]
 3061+[[Help:Somewhere/completely (wierd)#section (two)|]]
 3062+!! result
 3063+[[other#page|page]]
 3064+[[Help:Somewhere/completely (wierd)#section (two)|section]]
 3065+!! end
 3066+
 3067+!! test
30563068 pre-save transform: context links ("pipe trick") with full-width characters
30573069 !! options
30583070 pst
Index: trunk/phase3/includes/parser/Parser.php
@@ -4033,9 +4033,9 @@
40344034 ) );
40354035
40364036 # Links of the form [[|<blah>]] or [[<blah>|]] perform pipe tricks
4037 - # Note this only allows the # in the one position it works.
 4037+ # Note this only allows the # in the position it works.
40384038 global $wgLegalTitleChars;
4039 - $pipeTrickRe = "/\[\[(?:(\\|)([$wgLegalTitleChars]+)|(#?[$wgLegalTitleChars]+)\\|)\]\]/";
 4039+ $pipeTrickRe = "/\[\[(?:(\\|)([$wgLegalTitleChars]+)|([#$wgLegalTitleChars]+)\\|)\]\]/";
40404040 $text = preg_replace_callback( $pipeTrickRe, array( $this, 'pstPipeTrickCallback' ), $text );
40414041
40424042 # Trim trailing whitespace
Index: trunk/phase3/includes/Linker.php
@@ -1237,8 +1237,8 @@
12381238 list( $tc, $nc ) = Linker::getPipeTrickCharacterClasses();
12391239 $rexps = array (
12401240 # try this first, to turn "[[A, B (C)|]]" into "A, B"
1241 - "/^(:?$nc+:|[:#\/]|$tc+\\/|)($tc+?)( \\($tc+\\)| ($tc+))$/", # [[ns:page (context)|]]
1242 - "/^(:?$nc+:|[:#\/]|$tc+\\/|)($tc+?)( \\($tc+\\)| ($tc+)|)((?:,|,) $tc+|)$/", # [[ns:page (context), context|]]
 1241+ "/^(:?$nc+:|[:#\/]|$tc+[\\/#]|)($tc+?)( \\($tc+\\)| ($tc+))$/", # [[ns:page (context)|]]
 1242+ "/^(:?$nc+:|[:#\/]|$tc+[\\/#]|)($tc+?)( \\($tc+\\)| ($tc+)|)((?:,|,) $tc+|)$/", # [[ns:page (context), context|]]
12431243 );
12441244 }
12451245 $text = urldecode( $link );

Follow-up revisions

RevisionCommit summaryAuthorDate
r62689Moving Conrad's recent parser work out to a branch. Reverted r62434, r62416, ...tstarling05:19, 19 February 2010

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r62076Update Pipe Trick semantics per bug 845 and bug 21660...conrad02:15, 7 February 2010

Status & tagging log