Index: trunk/phase3/tests/parser/parserTests.txt |
— | — | @@ -1563,6 +1563,46 @@ |
1564 | 1564 | </table></dd></dl> |
1565 | 1565 | |
1566 | 1566 | !! end |
| 1567 | + |
| 1568 | +!! test |
| 1569 | +Arbitrary whitespace should not be prepended |
| 1570 | +!! input |
| 1571 | +{| |
| 1572 | +| 1 || 2 |
| 1573 | + |
| 1574 | +|- |
| 1575 | + |
| 1576 | + |
| 1577 | +| 3 || 4 |
| 1578 | +|- |
| 1579 | + |
| 1580 | +| 6 || 8 |
| 1581 | +|} |
| 1582 | +!! result |
| 1583 | +<table> |
| 1584 | +<tr> |
| 1585 | +<td>1 |
| 1586 | +</td> |
| 1587 | +<td>2 |
| 1588 | +</td> |
| 1589 | +</tr> |
| 1590 | +<tr> |
| 1591 | +<td>3 |
| 1592 | +</td> |
| 1593 | +<td>4 |
| 1594 | +</td> |
| 1595 | +</tr> |
| 1596 | +<tr> |
| 1597 | +<td>6 |
| 1598 | +</td> |
| 1599 | +<td>8 |
| 1600 | +</td> |
| 1601 | +</tr> |
| 1602 | +</table> |
| 1603 | + |
| 1604 | +!! end |
| 1605 | + |
| 1606 | + |
1567 | 1607 | ### |
1568 | 1608 | ### Internal links |
1569 | 1609 | ### |
— | — | @@ -5693,7 +5733,6 @@ |
5694 | 5734 | !!result |
5695 | 5735 | <p><a rel="nofollow" class="external free" href="http://===r:::https://b">http://===r:::https://b</a> |
5696 | 5736 | </p> |
5697 | | - |
5698 | 5737 | !! end |
5699 | 5738 | |
5700 | 5739 | # Known to produce bad XML for now |
— | — | @@ -5731,8 +5770,7 @@ |
5732 | 5771 | <p>{{{| |
5733 | 5772 | </p><p><u class="|">}}}} > |
5734 | 5773 | </p><p><br style="onmouseover='alert(document.cookie);'" /> |
5735 | | -</p><p><br /> |
5736 | | -MOVE YOUR MOUSE CURSOR OVER THIS TEXT |
| 5774 | +</p><p>MOVE YOUR MOUSE CURSOR OVER THIS TEXT |
5737 | 5775 | </p> |
5738 | 5776 | <table> |
5739 | 5777 | <tr> |
— | — | @@ -7918,7 +7956,8 @@ |
7919 | 7957 | </td> |
7920 | 7958 | <td>4 |
7921 | 7959 | </td> |
7922 | | -</tr></table> |
| 7960 | +</tr> |
| 7961 | +</table> |
7923 | 7962 | <p>y |
7924 | 7963 | </p> |
7925 | 7964 | !! end |
Index: trunk/phase3/includes/parser/Parser.php |
— | — | @@ -829,8 +829,13 @@ |
830 | 830 | foreach ( $lines as $outLine ) { |
831 | 831 | $line = trim( $outLine ); |
832 | 832 | |
833 | | - if ( $line === '' ) { // empty line, go to next line |
834 | | - $out .= $outLine . "\n"; |
| 833 | + # empty line, go to next line, |
| 834 | + # but only append \n if outside of table |
| 835 | + if ( $line === '' ) { |
| 836 | + $out .= $outLine; |
| 837 | + if ( !isset( $tables[0] ) ) { |
| 838 | + $out .= "\n"; |
| 839 | + } |
835 | 840 | continue; |
836 | 841 | } |
837 | 842 | $firstChars = $line[0]; |
— | — | @@ -877,8 +882,14 @@ |
878 | 883 | if ( empty( $lastRow ) ) { |
879 | 884 | $lastRow = NULL; |
880 | 885 | } |
| 886 | + $o = ''; |
881 | 887 | $curtable = array_pop( $tables ); |
882 | | - $o = $this->generateTableHTML( $curtable ) . $line; |
| 888 | + |
| 889 | + #Add a line-ending before the table, but only if there isn't one already |
| 890 | + if ( substr( $out, -1 ) !== "\n" ) { |
| 891 | + $o .= "\n"; |
| 892 | + } |
| 893 | + $o .= $this->generateTableHTML( $curtable ) . $line . "\n"; |
883 | 894 | |
884 | 895 | if ( count( $tables ) > 0 ) { |
885 | 896 | $table =& $this->last( $tables ); |
— | — | @@ -968,7 +979,12 @@ |
969 | 980 | if ( isset( $tables ) && count( $tables ) > 0 ) { |
970 | 981 | for ( $i = 0; $i < count( $tables ); $i++ ) { |
971 | 982 | $curtable = array_pop( $tables ); |
972 | | - $out .= $this->generateTableHTML( $curtable ); |
| 983 | + $curtable = $this->generateTableHTML( $curtable ); |
| 984 | + #Add a line-ending before the table, but only if there isn't one already |
| 985 | + if ( substr( $out, -1 ) !== "\n" && $curtable !== "" ) { |
| 986 | + $out .= "\n"; |
| 987 | + } |
| 988 | + $out .= $curtable; |
973 | 989 | } |
974 | 990 | } |
975 | 991 | |
— | — | @@ -1018,7 +1034,7 @@ |
1019 | 1035 | * @private |
1020 | 1036 | */ |
1021 | 1037 | function generateTableHTML ( &$table ) { |
1022 | | - $return = "\n"; |
| 1038 | + $return = ""; |
1023 | 1039 | $return .= str_repeat( '<dl><dd>' , $table['indent'] ); |
1024 | 1040 | $return .= '<table'; |
1025 | 1041 | $return .= isset( $table['attributes'] ) ? $table['attributes'] : ''; |