Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions lib/marked.js
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ Lexer.prototype.token = function(src, top) {

item = {
type: 'table',
header: cap[1].replace(/^ *| *\| *$/g, '').split(/ *\| */),
header: splitCells(cap[1].replace(/^ *| *\| *$/g, '')),
align: cap[2].replace(/^ *|\| *$/g, '').split(/ *\| */),
cells: cap[3].replace(/\n$/, '').split('\n')
};
Expand All @@ -267,7 +267,7 @@ Lexer.prototype.token = function(src, top) {
}

for (i = 0; i < item.cells.length; i++) {
item.cells[i] = item.cells[i].split(/ *\| */);
item.cells[i] = splitCells(item.cells[i]);
}

this.tokens.push(item);
Expand Down Expand Up @@ -416,7 +416,7 @@ Lexer.prototype.token = function(src, top) {

item = {
type: 'table',
header: cap[1].replace(/^ *| *\| *$/g, '').split(/ *\| */),
header: splitCells(cap[1].replace(/^ *| *\| *$/g, '')),
align: cap[2].replace(/^ *|\| *$/g, '').split(/ *\| */),
cells: cap[3].replace(/(?: *\| *)?\n$/, '').split('\n')
};
Expand All @@ -434,9 +434,8 @@ Lexer.prototype.token = function(src, top) {
}

for (i = 0; i < item.cells.length; i++) {
item.cells[i] = item.cells[i]
.replace(/^ *\| *| *\| *$/g, '')
.split(/ *\| */);
item.cells[i] = splitCells(
item.cells[i].replace(/^ *\| *| *\| *$/g, ''));
}

this.tokens.push(item);
Expand Down Expand Up @@ -1311,6 +1310,16 @@ function merge(obj) {
return obj;
}

function splitCells(tableRow) {
var cells = tableRow.replace(/([^\\])\|/g, '$1 |').split(/ +\| */),
i = 0;

for (; i < cells.length; i++) {
cells[i] = cells[i].replace(/\\\|/g, '|');
}
return cells;
}

/**
* Marked
*/
Expand Down
3 changes: 1 addition & 2 deletions test/specs/gfm/gfm-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ var messenger = new Messenger();
describe('GFM 0.28 Tables', function() {
var section = 'Tables';

// TODO: Verify exmaple 193 is valid and passing
var shouldPassButFails = [192, 193, 195, 196, 197];
var shouldPassButFails = [192, 195, 196, 197];

var willNotBeAttemptedByCoreTeam = [];

Expand Down