Index: trunk/phase3/tests/parser/parserTests.txt |
— | — | @@ -1331,7 +1331,40 @@ |
1332 | 1332 | </table> |
1333 | 1333 | |
1334 | 1334 | !! end |
| 1335 | + |
1335 | 1336 | !! test |
| 1337 | +Table with multiple captions: Only keep first |
| 1338 | +!! input |
| 1339 | +{| |
| 1340 | +|+ caption 1 |
| 1341 | +|+ caption 2 |
| 1342 | +|} |
| 1343 | +!! result |
| 1344 | +<table> |
| 1345 | +<caption>caption 1 |
| 1346 | +</caption> |
| 1347 | +<tr><td></td></tr> |
| 1348 | +</table> |
| 1349 | + |
| 1350 | +!! end |
| 1351 | + |
| 1352 | +!! test |
| 1353 | +Table with multiline caption |
| 1354 | +!! input |
| 1355 | +{| |
| 1356 | +|+ caption 1 |
| 1357 | +further caption |
| 1358 | +|} |
| 1359 | +!! result |
| 1360 | +<table> |
| 1361 | +<caption>caption 1 |
| 1362 | +further caption |
| 1363 | +</caption> |
| 1364 | +<tr><td></td></tr> |
| 1365 | +</table> |
| 1366 | + |
| 1367 | +!! end |
| 1368 | +!! test |
1336 | 1369 | Table with multiple thead |
1337 | 1370 | !! input |
1338 | 1371 | {| |
Index: trunk/phase3/includes/parser/Parser.php |
— | — | @@ -913,16 +913,17 @@ |
914 | 914 | } |
915 | 915 | |
916 | 916 | } else if ( $firstChars === '|+' ) { |
917 | | - // a table caption |
918 | | - $line = substr ( $line , 2 ); |
919 | | - |
920 | | - $c = $this->getCellAttr( $line , 'caption' ); |
921 | | - $table['caption'] = array(); |
922 | | - $table['caption']['content'] = $c[0]; |
923 | | - if ( isset( $c[1] ) ) $table['caption']['attributes'] = $c[1]; |
924 | | - unset( $c ); |
925 | | - |
926 | | - $output =& $table['caption']; |
| 917 | + // a table caption, but only proceed if there isn't one already |
| 918 | + if ( !isset ( $table['caption'] ) ) { |
| 919 | + $line = substr ( $line , 2 ); |
| 920 | + |
| 921 | + $c = $this->getCellAttr( $line , 'caption' ); |
| 922 | + $table['caption'] = array(); |
| 923 | + $table['caption']['content'] = $c[0]; |
| 924 | + if ( isset( $c[1] ) ) $table['caption']['attributes'] = $c[1]; |
| 925 | + unset( $c ); |
| 926 | + $output =& $table['caption']['content']; |
| 927 | + } |
927 | 928 | } else if ( $firstChars === '|' || $firstChars === '!' || $firstChars === '!+' ) { |
928 | 929 | // Which kind of cells are we dealing with |
929 | 930 | $currentTag = 'td'; |