r86144 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r86143‎ | r86144 | r86145 >
Date:22:36, 15 April 2011
Author:diebuche
Status:ok
Tags:
Comment:
r85922: Fixing another table bordercase
Modified paths:
  • /trunk/phase3/includes/parser/Parser.php (modified) (history)
  • /trunk/phase3/tests/parser/parserTests.txt (modified) (history)

Diff [purge]

Index: trunk/phase3/tests/parser/parserTests.txt
@@ -1271,6 +1271,32 @@
12721272 !! end
12731273
12741274 !! test
 1275+Table inside unclosed table w/o cells
 1276+!! input
 1277+{|
 1278+{|
 1279+| foo bar
 1280+|}
 1281+
 1282+!! result
 1283+<table>
 1284+<tr>
 1285+<td>
 1286+<table>
 1287+<tr>
 1288+<td>foo bar
 1289+</td>
 1290+</tr>
 1291+</table>
 1292+<p><br />
 1293+</p>
 1294+</td>
 1295+</tr>
 1296+</table>
 1297+
 1298+!! end
 1299+
 1300+!! test
12751301 Table with thead
12761302 !! input
12771303 {|
Index: trunk/phase3/includes/parser/Parser.php
@@ -846,7 +846,6 @@
847847 $table =& $this->last( $tables );
848848 $table[0] = array(); // first row
849849 $currentRow =& $table[0];
850 -
851850 $table['indent'] = strlen( $matches[1] );
852851
853852 $attributes = $this->mStripState->unstripBoth( $matches[2] );
@@ -881,7 +880,7 @@
882881 }
883882 $o = '';
884883 $curtable = array_pop( $tables );
885 -
 884+
886885 #Add a line-ending before the table, but only if there isn't one already
887886 if ( substr( $out, -1 ) !== "\n" ) {
888887 $o .= "\n";
@@ -1052,6 +1051,7 @@
10531052 // If we only have tbodies, mark table as simple
10541053 for ( $i = 0; isset( $table[$i] ); $i++ ) {
10551054 if ( !count( $table[$i] ) ) continue;
 1055+ if ( !isset( $table[$i]['type'] ) ) $table[$i]['type'] = 'tbody';
10561056 if ( !$lastSection ) {
10571057 $lastSection = $table[$i]['type'];
10581058 } else if ( $lastSection != $table[$i]['type'] ) {
@@ -1075,6 +1075,7 @@
10761076 $return .= isset( $table[$i]['attributes'] ) ? $table[$i]['attributes'] : '';
10771077 $return .= '>';
10781078 for ( $j = 0; isset( $table[$i][$j] ); $j++ ) {
 1079+ if ( !isset( $table[$i][$j]['type'] ) ) $table[$i][$j]['type'] = 'td';
10791080 $return .= "\n<" . $table[$i][$j]['type'];
10801081 $return .= isset( $table[$i][$j]['attributes'] ) ? $table[$i][$j]['attributes'] : '';
10811082 $return .= '>';

Sign-offs

UserFlagDate
Nikerabbittested07:15, 16 April 2011

Follow-up revisions

RevisionCommit summaryAuthorDate
r96906Updated r86144 code due to reverts in r96889 (specifically of Parser.php chan...aaron21:15, 12 September 2011
r100216remove duplicate '!!test' line...hashar10:19, 19 October 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r85922diebuche21:27, 12 April 2011

Status & tagging log