fix(tables): trailing spaces no longer prevent table parsing

If there were a trailing space following the closing | of a single column
table, the table does not get rendered. This fixes the issue.

Closes #442
This commit is contained in:
Estevao Soares dos Santos 2017-10-06 12:52:20 +01:00
parent d88b095f05
commit 66bdd21312
7 changed files with 20 additions and 1 deletions

BIN
dist/showdown.js vendored

Binary file not shown.

BIN
dist/showdown.js.map vendored

Binary file not shown.

BIN
dist/showdown.min.js vendored

Binary file not shown.

Binary file not shown.

View File

@ -7,7 +7,7 @@ showdown.subParser('tables', function (text, options, globals) {
var tableRgx = /^ {0,3}\|?.+\|.+\n {0,3}\|?[ \t]*:?[ \t]*(?:[-=]){2,}[ \t]*:?[ \t]*\|[ \t]*:?[ \t]*(?:[-=]){2,}[\s\S]+?(?:\n\n|<ol|<ul|¨0)/gm,
//singeColTblRgx = /^ {0,3}\|.+\|\n {0,3}\|[ \t]*:?[ \t]*(?:[-=]){2,}[ \t]*:?[ \t]*\|[ \t]*\n(?: {0,3}\|.+\|\n)+(?:\n\n|¨0)/gm;
singeColTblRgx = /^ {0,3}\|.+\|\n {0,3}\|[ \t]*:?[ \t]*(?:[-=]){2,}[ \t]*:?[ \t]*\|\n( {0,3}\|.+\|\n)*(?:\n|<ol|<ul|¨0)/gm;
singeColTblRgx = /^ {0,3}\|.+\|[ \t]*\n {0,3}\|[ \t]*:?[ \t]*(?:[-=]){2,}[ \t]*:?[ \t]*\|[ \t]*\n( {0,3}\|.+\|[ \t]*\n)*(?:\n|<ol|<ul|¨0)/gm;
function parseStyles (sLine) {
if (/^:[ \t]*--*$/.test(sLine)) {

View File

@ -0,0 +1,15 @@
<table>
<thead>
<tr>
<th style="text-align:left;">Single column</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left;">Row one</td>
</tr>
<tr>
<td style="text-align:left;">Row two</td>
</tr>
</tbody>
</table>

View File

@ -0,0 +1,4 @@
| Single column |
|:--------------|
| Row one |
| Row two |