diff --git a/lib/index.js b/lib/index.js index 8f28275b0..7aa66faef 100644 --- a/lib/index.js +++ b/lib/index.js @@ -13,7 +13,6 @@ var LinkifyIt = require('linkify-it'); var mdurl = require('mdurl'); var punycode = require('punycode'); - var config = { 'default': require('./presets/default'), zero: require('./presets/zero'), diff --git a/lib/rules_block/table.js b/lib/rules_block/table.js index 6993928ae..cb7c3f97c 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 4f732b52c..c168be5df 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
+.