Merge pull request #1239 from tomtheisen/escapedpipes

Escapedpipes
This commit is contained in:
Josh Bruce 2018-04-25 08:36:40 -04:00 committed by GitHub
commit c5cc03775a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 8 deletions

View File

@ -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')
};
@ -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);
@ -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')
};
@ -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);
@ -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
*/

View File

@ -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 = [];