Index: trunk/phase3/maintenance/parserTests.txt |
— | — | @@ -2999,6 +2999,36 @@ |
3000 | 3000 | !! end |
3001 | 3001 | |
3002 | 3002 | !! test |
| 3003 | +pre-save transform: context links ("pipe trick") based on current page |
| 3004 | +!! options |
| 3005 | +pst |
| 3006 | +!! input |
| 3007 | +[[#section|]] |
| 3008 | +[[#section (context)|]] |
| 3009 | +[[/relative|]] |
| 3010 | +[[../context/relative|]] |
| 3011 | +[[../context/relative (extra)|]] |
| 3012 | +!! result |
| 3013 | +[[#section|section]] |
| 3014 | +[[#section (context)|section]] |
| 3015 | +[[/relative|relative]] |
| 3016 | +[[../context/relative|relative]] |
| 3017 | +[[../context/relative (extra)|relative]] |
| 3018 | +!! end |
| 3019 | + |
| 3020 | +!! test |
| 3021 | +pre-save transform: context links ("pipe trick") with full-width characters |
| 3022 | +!! options |
| 3023 | +pst |
| 3024 | +!! input |
| 3025 | +[[title, context|]] |
| 3026 | +[[title (context)|]] |
| 3027 | +!! result |
| 3028 | +[[title, context|title]] |
| 3029 | +[[title (context)|title]] |
| 3030 | +!! end |
| 3031 | + |
| 3032 | +!! test |
3003 | 3033 | pre-save transform: context links ("pipe trick") with interwiki prefix |
3004 | 3034 | !! options |
3005 | 3035 | pst |
Index: trunk/phase3/includes/parser/Parser.php |
— | — | @@ -1917,7 +1917,8 @@ |
1918 | 1918 | * From the [[title|]] return link-text as though the used typed [[title|link-text]] |
1919 | 1919 | * |
1920 | 1920 | * For most links this be as though the user typed [[ns:title|title]] |
1921 | | - * However [[ns:title (context)]], [[ns:title, context]] and [[ns:title (context), context]] |
| 1921 | + * However [[ns:title (context)|]], [[ns:title, context|]] and [[ns:title (context), context|]] |
| 1922 | + * [[#title (context)|]] [[../context/title (context), context|]] |
1922 | 1923 | * all return the |title]] with no context or indicative punctuation. |
1923 | 1924 | */ |
1924 | 1925 | function getPipeTrickText( $link ) { |
— | — | @@ -1926,8 +1927,8 @@ |
1927 | 1928 | list( $tc, $nc ) = Parser::getPipeTrickCharacterClasses(); |
1928 | 1929 | $rexps = array ( |
1929 | 1930 | # try this first, to turn "[[A, B (C)|]]" into "A, B" |
1930 | | - "/^(:?$nc+:|:|)($tc+?)( \\($tc+\\)| ($tc+))$/", # [[ns:page (context)|]] |
1931 | | - "/^(:?$nc+:|:|)($tc+?)( \\($tc+\\)|)(, $tc+|)$/" # [[ns:page (context), context|]] |
| 1931 | + "/^(:?$nc+:|[:#\/]|$tc+\\/|)($tc+?)( \\($tc+\\)| ($tc+))$/", # [[ns:page (context)|]] |
| 1932 | + "/^(:?$nc+:|[:#\/]|$tc+\\/|)($tc+?)( \\($tc+\\)| ($tc+)|)((?:,|,) $tc+|)$/", # [[ns:page (context), context|]] |
1932 | 1933 | ); |
1933 | 1934 | } |
1934 | 1935 | $text = urldecode( $link ); |
— | — | @@ -1951,8 +1952,8 @@ |
1952 | 1953 | if( !$rexps ) { |
1953 | 1954 | list( $tc, $nc ) = Parser::getPipeTrickCharacterClasses(); |
1954 | 1955 | $rexps = array ( |
1955 | | - "/^($nc+:|)$tc+?( \\($tc+\\))$/", # [[ns:page (context)]] |
1956 | | - "/^($nc+:|)$tc+?(, $tc+|)$/" # [[ns:page, context]] |
| 1956 | + "/^($nc+:|)$tc+?( \\($tc+\\)| ($tc+))$/", # [[ns:page (context)|]] |
| 1957 | + "/^($nc+:|)$tc+?(?:(?: \\($tc+\\)| ($tc+)|)((?:,|,) $tc+|))$/" # [[ns:page (context), context|]] |
1957 | 1958 | ); |
1958 | 1959 | } |
1959 | 1960 | |
— | — | @@ -4062,9 +4063,10 @@ |
4063 | 4064 | ) ); |
4064 | 4065 | |
4065 | 4066 | # Links of the form [[|<blah>]] or [[<blah>|]] perform pipe tricks |
| 4067 | + # Note this only allows the # in the one position it works. |
4066 | 4068 | list( $tc, $nc ) = Parser::getPipeTrickCharacterClasses(); |
4067 | | - $pipeTrickRe = "/\[\[(?:(\\|)($tc+)|($tc+)\\|)\]\]/"; |
4068 | | - $text = preg_replace_callback( $pipeTrickRe, array( $this, 'pstPipeTrickCallback' ), $text); |
| 4069 | + $pipeTrickRe = "/\[\[(?:(\\|)($tc+)|(#?$tc+)\\|)\]\]/"; |
| 4070 | + $text = preg_replace_callback( $pipeTrickRe, array( $this, 'pstPipeTrickCallback' ), $text ); |
4069 | 4071 | |
4070 | 4072 | # Trim trailing whitespace |
4071 | 4073 | $text = rtrim( $text ); |
— | — | @@ -4078,7 +4080,7 @@ |
4079 | 4081 | * |
4080 | 4082 | * @param Array ("|" or "", text, link) $m |
4081 | 4083 | */ |
4082 | | - function pstPipeTrickCallback($m) |
| 4084 | + function pstPipeTrickCallback( $m ) |
4083 | 4085 | { |
4084 | 4086 | if( $m[1] ) { # [[|<blah>]] |
4085 | 4087 | $text = $m[2]; |
Index: trunk/phase3/RELEASE-NOTES |
— | — | @@ -832,6 +832,8 @@ |
833 | 833 | * (bug 5210) preload parser should parse <noinclude> (as well as <includeonly>) |
834 | 834 | * (bug 8785) Pipe trick should work with colon functions |
835 | 835 | * (bug 4099) Pipe trick doesn't work when emptiness is only provided by empty template parameter |
| 836 | +* (bug 845) [[#foo|]], [[/bar|]] should be equivalent to [[#foo|foo]], [[/bar|bar]] (new use of "pipe trick") |
| 837 | +* (bug 21660) Support full-width commas for pipe trick |
836 | 838 | |
837 | 839 | === Languages updated in 1.16 === |
838 | 840 | |