diff --git a/lib/marked.js b/lib/marked.js index ac39650c77..076eeceeeb 100644 --- a/lib/marked.js +++ b/lib/marked.js @@ -452,7 +452,7 @@ Lexer.prototype.token = function(src, top) { type: 'table', header: splitCells(cap[1].replace(/^ *| *\| *$/g, '')), align: cap[2].replace(/^ *|\| *$/g, '').split(/ *\| */), - cells: cap[3] ? cap[3].replace(/(?: *\| *)?\n$/, '').split('\n') : [] + cells: cap[3] ? cap[3].replace(/\n$/, '').split('\n') : [] }; if (item.header.length === item.align.length) { diff --git a/test/specs/marked/marked.json b/test/specs/marked/marked.json index 5dd1a065c8..2569825c51 100644 --- a/test/specs/marked/marked.json +++ b/test/specs/marked/marked.json @@ -119,6 +119,30 @@ "html": "

test. test: test! test? test-

", "example": 15 }, + { + "section": "Table cells", + "markdown": "1|2\n-|-\n1\\|\\\\|2\\|\\\\", + "html": "
12
1|\\2|\\
", + "example": 19 + }, + { + "section": "Table cells", + "markdown": "1|2\n-|-\n |2", + "html": "
12
2
", + "example": 20 + }, + { + "section": "Table cells", + "markdown": "1|2\n-|-\n1|2\\|\n\n1|2\n-|-\n1|2\\|", + "html": "
12
12|
\n\n
12
12|
", + "example": 21 + }, + { + "section": "Table cells", + "markdown": "|1|2|\n|-|-|\n|1|2\\||\n\n|1|2|\n|-|-|\n|1|2\\||", + "html": "
12
12|
\n\n
12
12|
", + "example": 22 + }, { "section": "Links", "markdown": "[One](https://example.com/1) ([Two](https://example.com/2)) [Three](https://example.com/3)",