From 10d6448b220f2d815bc5b814f0cee384179c6099 Mon Sep 17 00:00:00 2001 From: Sean Lang Date: Wed, 30 Mar 2016 19:59:34 -0400 Subject: [PATCH 1/2] support tables with missing values (and add supporting test case) --- lib/rules_block/table.js | 7 ++++-- test/fixtures/markdown-it/tables.txt | 32 ++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 2 deletions(-) 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
+. From 86eea8c1d353280e299d09e667f339ff78bca3cd Mon Sep 17 00:00:00 2001 From: Sean Lang Date: Fri, 1 Apr 2016 03:03:36 -0400 Subject: [PATCH 2/2] fix misspelling of "parser" --- lib/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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';