diff --git a/lib/index.js b/lib/index.js index 8f28275..3f73b85 100644 --- a/lib/index.js +++ b/lib/index.js @@ -1,4 +1,4 @@ -// Main perser class +// Main parser class 'use strict'; diff --git a/lib/rules_block/table.js b/lib/rules_block/table.js index 6993928..cb7c3f9 100644 --- a/lib/rules_block/table.js +++ b/lib/rules_block/table.js @@ -143,9 +143,12 @@ module.exports = function table(state, startLine, endLine, silent) { for (nextLine = startLine + 2; nextLine < endLine; nextLine++) { if (state.sCount[nextLine] < state.blkIndent) { break; } - lineText = getLine(state, nextLine).trim(); + lineText = getLine(state, nextLine); if (lineText.indexOf('|') === -1) { break; } - columns = escapedSplit(lineText.replace(/^\||\|$/g, '')); + + // keep spaces at beginning of line to indicate an empty first cell, but + // strip trailing whitespace + columns = escapedSplit(lineText.replace(/^\||\|\s*$/g, '')); token = state.push('tr_open', 'tr', 1); for (i = 0; i < columnCount; i++) { diff --git a/test/fixtures/markdown-it/tables.txt b/test/fixtures/markdown-it/tables.txt index 4f732b5..c168be5 100644 --- a/test/fixtures/markdown-it/tables.txt +++ b/test/fixtures/markdown-it/tables.txt @@ -470,3 +470,35 @@ Allow one-column tables (issue #171): . + + +Allow tables with missing values: +. +0,0 | 0,1 | 0,2 +--- | --- | --- +1,0 | | 1,2 + | 2,1 | + +. + + + + + + + + + + + + + + + + + + + + +
0,00,10,2
1,01,2
2,1
+.