}
} else if ( $firstChars === '|+' ) {
- // a table caption
- $line = substr ( $line , 2 );
-
- $c = $this->getCellAttr( $line , 'caption' );
- $table['caption'] = array();
- $table['caption']['content'] = $c[0];
- if ( isset( $c[1] ) ) $table['caption']['attributes'] = $c[1];
- unset( $c );
-
- $output =& $table['caption'];
+ // a table caption, but only proceed if there isn't one already
+ if ( !isset ( $table['caption'] ) ) {
+ $line = substr ( $line , 2 );
+
+ $c = $this->getCellAttr( $line , 'caption' );
+ $table['caption'] = array();
+ $table['caption']['content'] = $c[0];
+ if ( isset( $c[1] ) ) $table['caption']['attributes'] = $c[1];
+ unset( $c );
+ $output =& $table['caption']['content'];
+ }
} else if ( $firstChars === '|' || $firstChars === '!' || $firstChars === '!+' ) {
// Which kind of cells are we dealing with
$currentTag = 'td';
</tr></tbody>
</table>
+!! end
+
+!! test
+Table with multiple captions: Only keep first
+!! input
+{|
+|+ caption 1
+|+ caption 2
+|}
+!! result
+<table>
+<caption>caption 1
+</caption>
+<tr><td></td></tr>
+</table>
+
+!! end
+
+!! test
+Table with multiline caption
+!! input
+{|
+|+ caption 1
+further caption
+|}
+!! result
+<table>
+<caption>caption 1
+further caption
+</caption>
+<tr><td></td></tr>
+</table>
+
!! end
!! test
Table with multiple thead