Skip to content

Commit

Permalink
fix(tables): trailing spaces no longer prevent table parsing
Browse files Browse the repository at this point in the history
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
  • Loading branch information
tivie committed Oct 6, 2017
1 parent d88b095 commit 66bdd21
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 5 deletions.
2 changes: 1 addition & 1 deletion dist/showdown.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/showdown.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/showdown.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/showdown.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/subParsers/tables.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
| Single column |
|:--------------|
| Row one |
| Row two |

0 comments on commit 66bdd21

Please sign in to comment.