* @return string
*/
public function doTableStuff( $text ) {
-
$lines = StringUtils::explode( "\n", $text );
$out = '';
$td_history = []; # Is currently a td tag open?
* @return string
*/
public function internalParse( $text, $isMain = true, $frame = false ) {
-
$origText = $text;
// Avoid PHP 7.1 warning from passing $this by reference
* @return string
*/
public function replaceExternalLinks( $text ) {
-
$bits = preg_split( $this->mExtLinkBracketedRegex, $text, -1, PREG_SPLIT_DELIM_CAPTURE );
if ( $bits === false ) {
throw new MWException( "PCRE needs to be compiled with "
$link = $origLink;
}
- $noforce = ( substr( $origLink, 0, 1 ) !== ':' );
- if ( !$noforce ) {
- # Strip off leading ':'
- $link = substr( $link, 1 );
- }
-
$unstrip = $this->mStripState->unstripNoWiki( $link );
$nt = is_string( $unstrip ) ? Title::newFromText( $unstrip ) : null;
if ( $nt === null ) {
$ns = $nt->getNamespace();
$iw = $nt->getInterwiki();
+ $noforce = ( substr( $origLink, 0, 1 ) !== ':' );
+
if ( $might_be_img ) { # if this is actually an invalid link
if ( $ns == NS_FILE && $noforce ) { # but might be an image
$found = false;
$wasblank = ( $text == '' );
if ( $wasblank ) {
$text = $link;
+ if ( !$noforce ) {
+ # Strip off leading ':'
+ $text = substr( $text, 1 );
+ }
} else {
# T6598 madness. Handle the quotes only if they come from the alternate part
# [[Lista d''e paise d''o munno]] -> <a href="...">Lista d''e paise d''o munno</a>
}
$s = rtrim( $s . $prefix );
- $s .= trim( $trail, "\n" ) == '' ? '': $prefix . $trail;
+ $s .= trim( $trail, "\n" ) == '' ? '' : $prefix . $trail;
continue;
}
* @return string The text of the template
*/
public function braceSubstitution( $piece, $frame ) {
-
// Flags
// $text has been filled
* @return array
*/
public function argSubstitution( $piece, $frame ) {
-
$error = false;
$parts = $piece['parts'];
$nameWithSpaces = $frame->expand( $piece['title'] );
* @return string
*/
public function doDoubleUnderscore( $text ) {
-
# The position of __TOC__ needs to be recorded
$mw = MagicWord::get( 'toc' );
if ( $mw->match( $text ) ) {
# which may corrupt this parser instance via its wfMessage()->text() call-
# Signatures
- $sigText = $this->getUserSig( $user );
- $text = strtr( $text, [
- '~~~~~' => $d,
- '~~~~' => "$sigText $d",
- '~~~' => $sigText
- ] );
+ if ( strpos( $text, '~~~' ) !== false ) {
+ $sigText = $this->getUserSig( $user );
+ $text = strtr( $text, [
+ '~~~~~' => $d,
+ '~~~~' => "$sigText $d",
+ '~~~' => $sigText
+ ] );
+ # The main two signature forms used above are time-sensitive
+ $this->mOutput->setFlag( 'user-signature' );
+ }
# Context links ("pipe tricks"): [[|name]] and [[name (context)|]]
$tc = '[' . Title::legalChars() . ']';
* @return string HTML
*/
public function renderImageGallery( $text, $params ) {
-
$mode = false;
if ( isset( $params['mode'] ) ) {
$mode = $params['mode'];