diff --git a/dist/showdown.js b/dist/showdown.js index 644a798..20628cf 100644 Binary files a/dist/showdown.js and b/dist/showdown.js differ diff --git a/dist/showdown.js.map b/dist/showdown.js.map index 0ef7e5b..37bf9f2 100644 Binary files a/dist/showdown.js.map and b/dist/showdown.js.map differ diff --git a/dist/showdown.min.js b/dist/showdown.min.js index 6884ac2..8114fd9 100644 Binary files a/dist/showdown.min.js and b/dist/showdown.min.js differ diff --git a/dist/showdown.min.js.map b/dist/showdown.min.js.map index bf48673..15e9b46 100644 Binary files a/dist/showdown.min.js.map and b/dist/showdown.min.js.map differ diff --git a/src/subParsers/tables.js b/src/subParsers/tables.js index 6ce7bc6..567823c 100644 --- a/src/subParsers/tables.js +++ b/src/subParsers/tables.js @@ -5,7 +5,9 @@ showdown.subParser('tables', function (text, options, globals) { return text; } - var tableRgx = /^ {0,3}\|?.+\|.+\n[ \t]{0,3}\|?[ \t]*:?[ \t]*(?:-|=){2,}[ \t]*:?[ \t]*\|[ \t]*:?[ \t]*(?:-|=){2,}[\s\S]+?(?:\n\n|¨0)/gm; + var tableRgx = /^ {0,3}\|?.+\|.+\n {0,3}\|?[ \t]*:?[ \t]*(?:[-=]){2,}[ \t]*:?[ \t]*\|[ \t]*:?[ \t]*(?:[-=]){2,}[\s\S]+?(?:\n\n|¨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|¨0)/gm; function parseStyles (sLine) { if (/^:[ \t]*--*$/.test(sLine)) { @@ -56,14 +58,7 @@ showdown.subParser('tables', function (text, options, globals) { return tb; } - text = globals.converter._dispatch('tables.before', text, options, globals); - - // find escaped pipe characters - text = text.replace(/\\(\|)/g, showdown.helper.escapeCharactersCallback); - - // parse tables - text = text.replace(tableRgx, function (rawTable) { - + function parseTable (rawTable) { var i, tableLines = rawTable.split('\n'); // strip wrong first and last column if wrapped tables are used @@ -126,7 +121,18 @@ showdown.subParser('tables', function (text, options, globals) { } return buildTable(headers, cells); - }); + } + + text = globals.converter._dispatch('tables.before', text, options, globals); + + // find escaped pipe characters + text = text.replace(/\\(\|)/g, showdown.helper.escapeCharactersCallback); + + // parse multi column tables + text = text.replace(tableRgx, parseTable); + + // parse one column tables + text = text.replace(singeColTblRgx, parseTable); text = globals.converter._dispatch('tables.after', text, options, globals); diff --git a/test/features/tables/#406.does-not-render-one-column-tables.html b/test/features/tables/#406.does-not-render-one-column-tables.html new file mode 100644 index 0000000..841e371 --- /dev/null +++ b/test/features/tables/#406.does-not-render-one-column-tables.html @@ -0,0 +1,81 @@ + + + + + + + + + + + +
some header
some content
+ + + + + + + + +
some header
+ + + + + + + + + + + + + + + + + + + + + + + +
some header
some content
some content
some content
some content
some content
+ + + + + + + + + + + +
some header
some content
+ + + + + + + + + + + +
some header
some content
+ + + + + + + + + + + +
some header
some content
diff --git a/test/features/tables/#406.does-not-render-one-column-tables.md b/test/features/tables/#406.does-not-render-one-column-tables.md new file mode 100644 index 0000000..3a5aee1 --- /dev/null +++ b/test/features/tables/#406.does-not-render-one-column-tables.md @@ -0,0 +1,26 @@ +|some header | +|------------| +|some content| + +|some header | +|------------| + +|some header | +|------------| +|some content| +|some content| +|some content| +|some content| +|some content| + +|some header | +|:-----------| +|some content| + +|some header | +|-----------:| +|some content| + +|some header | +|:----------:| +|some content| \ No newline at end of file