Browse Source

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
Estevao Soares dos Santos 7 years ago
parent
commit
66bdd21312

+ 1 - 1
dist/showdown.js

@@ -2845,7 +2845,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)) {

File diff suppressed because it is too large
+ 0 - 0
dist/showdown.js.map


File diff suppressed because it is too large
+ 0 - 0
dist/showdown.min.js


File diff suppressed because it is too large
+ 0 - 0
dist/showdown.min.js.map


+ 1 - 1
src/subParsers/tables.js

@@ -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)) {

+ 15 - 0
test/features/tables/#442.trailing-spaces-break-one-column-tables.html

@@ -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>

+ 4 - 0
test/features/tables/#442.trailing-spaces-break-one-column-tables.md

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

Some files were not shown because too many files changed in this diff