From ba00a957fb44501725fd0b148efc5919b6c75785 Mon Sep 17 00:00:00 2001 From: Arlo Breault Date: Fri, 3 Jul 2015 11:53:06 -0700 Subject: [PATCH] Cleanup in doTableStuff Change-Id: I75c0a943b24f96a30c6ee1efc3f0b11388f892b7 --- includes/parser/Parser.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php index 55066845b7..7f925901fd 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -1023,6 +1023,7 @@ class Parser { } $first_character = $line[0]; + $first_two = substr( $line, 0, 2 ); $matches = array(); if ( preg_match( '/^(:*)\{\|(.*)$/', $line, $matches ) ) { @@ -1042,7 +1043,7 @@ class Parser { # Don't do any of the following $out .= $outLine . "\n"; continue; - } elseif ( substr( $line, 0, 2 ) === '|}' ) { + } elseif ( $first_two === '|}' ) { # We are ending a table $line = '' . substr( $line, 2 ); $last_tag = array_pop( $last_tag_history ); @@ -1060,7 +1061,7 @@ class Parser { } array_pop( $tr_attributes ); $outLine = $line . str_repeat( '', $indent_level ); - } elseif ( substr( $line, 0, 2 ) === '|-' ) { + } elseif ( $first_two === '|-' ) { # Now we have a table row $line = preg_replace( '#^\|-+#', '', $line ); @@ -1089,16 +1090,16 @@ class Parser { array_push( $last_tag_history, '' ); } elseif ( $first_character === '|' || $first_character === '!' - || substr( $line, 0, 2 ) === '|+' + || $first_two === '|+' ) { # This might be cell elements, td, th or captions - if ( substr( $line, 0, 2 ) === '|+' ) { + if ( $first_two === '|+' ) { $first_character = '+'; + $line = substr( $line, 2 ); + } else { $line = substr( $line, 1 ); } - $line = substr( $line, 1 ); - if ( $first_character === '!' ) { $line = str_replace( '!!', '||', $line ); } -- 2.20.1