Merge "Http::getProxy() method to get proxy configuration"
[lhc/web/wiklou.git] / includes / tidy / RaggettWrapper.php
index 083f402..ab19142 100644 (file)
@@ -40,17 +40,22 @@ class RaggettWrapper {
 
                // Replace <mw:editsection> elements with placeholders
                $wrappedtext = preg_replace_callback( ParserOutput::EDITSECTION_REGEX,
-                       array( &$this, 'replaceCallback' ), $text );
+                       [ &$this, 'replaceCallback' ], $text );
                // ...and <mw:toc> markers
                $wrappedtext = preg_replace_callback( '/\<\\/?mw:toc\>/',
-                       array( &$this, 'replaceCallback' ), $wrappedtext );
+                       [ &$this, 'replaceCallback' ], $wrappedtext );
                // ... and <math> tags
                $wrappedtext = preg_replace_callback( '/\<math(.*?)\<\\/math\>/s',
-                       array( &$this, 'replaceCallback' ), $wrappedtext );
+                       [ &$this, 'replaceCallback' ], $wrappedtext );
                // Modify inline Microdata <link> and <meta> elements so they say <html-link> and <html-meta> so
                // we can trick Tidy into not stripping them out by including them in tidy's new-empty-tags config
                $wrappedtext = preg_replace( '!<(link|meta)([^>]*?)(/{0,1}>)!', '<html-$1$2$3', $wrappedtext );
 
+               // Preserve empty li elements (T49673) by abusing Tidy's datafld hack
+               // The whitespace class is as in TY_(InitMap)
+               $wrappedtext = preg_replace( "!<li>([ \r\n\t\f]*)</li>!",
+                       '<li datafld="" class="mw-empty-li">\1</li>', $wrappedtext );
+
                // Wrap the whole thing in a doctype and body for Tidy.
                $wrappedtext = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"' .
                        ' "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html>' .
@@ -79,6 +84,9 @@ class RaggettWrapper {
                // Revert <html-{link,meta}> back to <{link,meta}>
                $text = preg_replace( '!<html-(link|meta)([^>]*?)(/{0,1}>)!', '<$1$2$3', $text );
 
+               // Remove datafld
+               $text = str_replace( '<li datafld=""', '<li', $text );
+
                // Restore the contents of placeholder tokens
                $text = $this->mTokens->replace( $text );
 
@@ -86,4 +94,3 @@ class RaggettWrapper {
        }
 
 }
-?>