Revert "Fix link prefix/suffixes around Category and Language links."
authorTim Starling <tstarling@wikimedia.org>
Fri, 1 Sep 2017 00:36:41 +0000 (00:36 +0000)
committerLegoktm <legoktm@member.fsf.org>
Fri, 1 Sep 2017 00:47:32 +0000 (00:47 +0000)
This reverts commit c66c9aa5352743b2f87bc4627a1be529c5d18535.

Bug: T174639
Change-Id: Ibf6d3780f384ba8edc80bf28c893f1aee8ce28a8

includes/parser/Parser.php
tests/parser/parserTests.txt

index 5ef0032..3261002 100644 (file)
@@ -2323,11 +2323,8 @@ class Parser {
                                                $this->mOutput->addLanguageLink( $nt->getFullText() );
                                        }
 
-                                       /**
-                                        * Strip the whitespace interwiki links produce, see T10897
-                                        */
                                        $s = rtrim( $s . $prefix );
-                                       $s .= rtrim( $trail, "\n" );
+                                       $s .= trim( $trail, "\n" ) == '' ? '' : $prefix . $trail;
                                        continue;
                                }
 
@@ -2352,11 +2349,7 @@ class Parser {
                                                continue;
                                        }
                                } elseif ( $ns == NS_CATEGORY ) {
-                                       /**
-                                        * Strip the whitespace Category links produce, see T2087
-                                        */
-                                       $s = rtrim( $s . $prefix ); # T2087, T87753
-                                       $s .= rtrim( $trail, "\n" );
+                                       $s = rtrim( $s . "\n" ); # T2087
 
                                        if ( $wasblank ) {
                                                $sortkey = $this->getDefaultSort();
@@ -2368,6 +2361,11 @@ class Parser {
                                        $sortkey = $this->getConverterLanguage()->convertCategoryKey( $sortkey );
                                        $this->mOutput->addCategory( $nt->getDBkey(), $sortkey );
 
+                                       /**
+                                        * Strip the whitespace Category links produce, see T2087
+                                        */
+                                       $s .= trim( $prefix . $trail, "\n" ) == '' ? '' : $prefix . $trail;
+
                                        continue;
                                }
                        }
index 2fa3cb0..ab79b59 100644 (file)
@@ -15807,26 +15807,6 @@ parsoid=wt2html
 <link rel="mw:PageProp/Category" href="./Category:Baz" data-parsoid='{"stx":"simple","a":{"href":"./Category:Baz"},"sa":{"href":"Category:Baz"}}'/>
 !! end
 
-!! test
-9. Categories and newlines: should behave properly with linkprefix (T87753)
-!! options
-language=ar
-!! wikitext
-foo bar
-foo bar
-[[تصنيف:Foo]]
-[[تصنيف:Bar]]
-!! html/php
-<p>foo bar
-foo bar
-</p>
-!! html/parsoid
-<p>foo bar
-foo bar</p>
-<link rel="mw:PageProp/Category" href="./تصنيف:Foo"/>
-<link rel="mw:PageProp/Category" href="./تصنيف:Bar"/>
-!! end
-
 !! test
 Category links with multiple namespaces
 !! wikitext
@@ -15874,20 +15854,6 @@ x[[Category:Foo]]y
 <p>x<link rel="mw:PageProp/Category" href="./Flokkur:Foo" data-parsoid=""/>y</p>
 !! end
 
-!! test
-Link prefix/suffixes aren't applied to language links
-!! options
-parsoid=wt2html
-language=is
-!! wikitext
-x[[es:Foo]]y
-!! html/php
-<p>xy
-</p>
-!! html/parsoid
-<p>x<link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Foo" data-parsoid=""/>y</p>
-!! end
-
 !! test
 Parsoid: Serialize link to file page with colon escape
 !! options